src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h
author Kirill Andreev <andreev@iitp.ru>
Wed, 22 Jul 2009 16:43:43 +0400
changeset 5132 aee541a30256
parent 5129 5688b8da4526
child 5156 5b499f25655a
permissions -rw-r--r--
Restored newline at namespace
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
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    21
#ifndef WIFI_TIMING_ELEMENT_H
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    22
#define WIFI_TIMING_ELEMENT_H
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    23
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    24
#include <vector>
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    25
#include "ns3/nstime.h"
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    26
#include "ns3/wifi-information-element.h"
4862
6a14f272a033 PeerLink refactored (use peer-link.h)
Pavel Boyko <boyko@iitp.ru>
parents: 4852
diff changeset
    27
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    28
namespace ns3 {
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    29
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
    30
/**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    31
 * \ingroup dot11s
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    32
 * \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
    33
 */
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    34
class IeBeaconTimingUnit : public RefCountBase
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    35
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    36
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
    37
  IeBeaconTimingUnit ();
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    38
  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
    39
  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
    40
  void SetBeaconInterval (uint16_t beacon_interval);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    41
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    42
  uint8_t GetAid () const;
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    43
  uint16_t GetLastBeacon () const;
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    44
  uint16_t GetBeaconInterval () const;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    45
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    46
private:
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    47
  /// Least significant octet of AID:
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    48
  uint8_t m_aid;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    49
  /// 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
    50
  uint16_t m_lastBeacon;
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 4951
diff changeset
    51
  /// 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
    52
  uint16_t m_beaconInterval;
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    53
  friend bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    54
};
4807
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    55
a1f43e372f9f 1. HIDE_UNDOC_CLASSES is temporary set to NO in doxygen.conf
Pavel Boyko <boyko@iitp.ru>
parents: 4793
diff changeset
    56
/**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    57
 * \ingroup dot11s
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    58
 * \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
    59
 */
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    60
class IeBeaconTiming : public WifiInformationElement
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    61
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    62
public:
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    63
  /**
4851
44a5075d854e 11s information elements commented as "\ingroup dot11s" for doxygen
Pavel Boyko <boyko@iitp.ru>
parents: 4850
diff changeset
    64
   * \ingroup dot11s
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    65
   * 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
    66
   */
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
    67
  typedef std::vector< Ptr<IeBeaconTimingUnit> > NeighboursTimingUnitsList;
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    68
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    69
  IeBeaconTiming ();
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    70
  /**
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    71
   * This methods are needed for beacon collision
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    72
   * avoidance module:
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    73
   */
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    74
  NeighboursTimingUnitsList GetNeighboursTimingElementsList ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    75
  void AddNeighboursTimingElementUnit (
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    76
    uint16_t aid,
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    77
    Time last_beacon,
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    78
    Time beacon_interval
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    79
  );
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    80
  void   DelNeighboursTimingElementUnit (
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    81
    uint16_t aid,
4847
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    82
    Time  last_beacon,
695b7aca9f88 Fixes with comments
Kirill Andreev <andreev@iitp.ru>
parents: 4838
diff changeset
    83
    Time  beacon_interval
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    84
  );
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    85
  void   ClearTimingElement ();
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    86
private:
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5063
diff changeset
    87
  WifiElementId ElementId () const;
4838
ce31277d72ad Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents: 4835
diff changeset
    88
  uint8_t  GetInformationSize () const;
4831
6a2923d9f526 Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    89
  void SerializeInformation (Buffer::Iterator i) const;
4838
ce31277d72ad Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents: 4835
diff changeset
    90
  uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    91
  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
    92
  /**
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    93
   * Converters:
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
    94
   */
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4851
diff changeset
    95
  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
    96
  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
    97
  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
    98
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
    99
  NeighboursTimingUnitsList  m_neighbours;
4850
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   100
  /**
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   101
   * Timing element parameters:
c3ee1deaa07a Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents: 4847
diff changeset
   102
   */
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4810
diff changeset
   103
  uint16_t  m_numOfUnits;
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   104
  friend bool operator== (const IeBeaconTiming & a, const IeBeaconTiming & b);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   105
};
4951
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   106
bool operator== (const IeBeaconTiming & a, const IeBeaconTiming & b);
acaf07eb8542 Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents: 4899
diff changeset
   107
bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   108
} // namespace dot11s
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   109
} //namespace ns3
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   110
#endif