src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h
author Pavel Boyko <boyko@iitp.ru>
Mon, 15 Jun 2009 13:10:56 +0400
changeset 5063 97b947e83640
parent 4951 acaf07eb8542
child 5124 e206046b2e44
permissions -rw-r--r--
Faker's code review response
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     2
/*
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     4
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     8
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    13
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    17
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    19
 */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    20
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    21
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    22
#ifndef WIFI_TIMING_ELEMENT_H
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    23
#define WIFI_TIMING_ELEMENT_H
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    24
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    25
#include <vector>
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    26
#include "ns3/nstime.h"
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    27
#include "ns3/wifi-information-element.h"
4862
6a14f272a033 PeerLink refactored (use peer-link.h)
Pavel Boyko <boyko@iitp.ru>
parents: 4852
diff changeset
    28
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    29
namespace ns3 {
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
    30
namespace dot11s {
4807
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    31
/**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    32
 * \ingroup dot11s
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    33
 * \brief Describes one unit of beacon timing element
4807
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    34
 */
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    35
class IeBeaconTimingUnit : public RefCountBase
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    36
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    37
public:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    38
  IeBeaconTimingUnit ();
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    39
  void SetAid (uint8_t aid);
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    40
  void SetLastBeacon (uint16_t last_beacon);
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    41
  void SetBeaconInterval (uint16_t beacon_interval);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    42
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    43
  uint8_t GetAid () const;
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    44
  uint16_t GetLastBeacon () const;
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    45
  uint16_t GetBeaconInterval () const;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    46
  
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    47
private:
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    48
  /// Least significant octet of AID:
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    49
  uint8_t m_aid;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    50
  /// Last time we received a beacon in accordance with a local TSF measured in 256 microseconds unit
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    51
  uint16_t m_lastBeacon;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    52
  /// Beacon interval of remote mesh point
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    53
  uint16_t m_beaconInterval;
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    54
  friend bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    55
};
4807
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    56
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    57
/**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    58
 * \ingroup dot11s
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    59
 * \brief See 7.3.2.89 of 802.11s draft 2.07
4807
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    60
 */
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    61
class IeBeaconTiming : public WifiInformationElement
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    62
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    63
public:
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    64
  /**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    65
   * \ingroup dot11s
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    66
   * This type is a list of timing elements obtained from neigbours with their beacons:
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    67
   */
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    68
  typedef std::vector< Ptr<IeBeaconTimingUnit> > NeighboursTimingUnitsList;
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    69
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    70
  IeBeaconTiming ();
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    71
  /**
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    72
   * This methods are needed for beacon collision
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    73
   * avoidance module:
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    74
   */
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    75
  NeighboursTimingUnitsList GetNeighboursTimingElementsList ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    76
  void AddNeighboursTimingElementUnit (
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    77
    uint16_t aid,
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    78
    Time last_beacon,
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    79
    Time beacon_interval
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    80
  );
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    81
  void   DelNeighboursTimingElementUnit (
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    82
    uint16_t aid,
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    83
    Time  last_beacon,
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    84
    Time  beacon_interval
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    85
  );
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    86
  void   ClearTimingElement ();
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    87
private:
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    88
  WifiElementId ElementId () const {
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    89
    return IE11S_BEACON_TIMING;
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    90
  }
4838
ce31277d72ad Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents: 4835
diff changeset
    91
  uint8_t  GetInformationSize () const;
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    92
  void SerializeInformation (Buffer::Iterator i) const;
4838
ce31277d72ad Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents: 4835
diff changeset
    93
  uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    94
  void PrintInformation (std::ostream& os) const; 
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    95
  /**
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    96
   * Converters:
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    97
   */
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    98
  static uint16_t TimestampToU16 (Time x);
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    99
  static uint16_t BeaconIntervalToU16 (Time x);
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
   100
  static uint8_t AidToU8 (uint16_t x);
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   101
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
   102
  NeighboursTimingUnitsList  m_neighbours;
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   103
  /**
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   104
   * Timing element parameters:
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   105
   */
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
   106
  uint16_t  m_numOfUnits;
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   107
  friend bool operator== (const IeBeaconTiming & a, const IeBeaconTiming & b);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   108
};
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   109
bool operator== (const IeBeaconTiming & a, const IeBeaconTiming & b);
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   110
bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   111
} // namespace dot11s
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   112
} //namespace ns3
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   113
#endif