A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-beacon-timing.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#ifndef WIFI_TIMING_ELEMENT_H
21#define WIFI_TIMING_ELEMENT_H
22
23#include "ns3/mesh-information-element-vector.h"
24#include "ns3/nstime.h"
25
26#include <vector>
27
28namespace ns3
29{
30namespace dot11s
31{
32/**
33 * \ingroup dot11s
34 * \brief Information element describing one unit of beacon timing element
35 */
36class IeBeaconTimingUnit : public SimpleRefCount<IeBeaconTimingUnit>
37{
38 public:
40 /**
41 * Set AID value
42 * \param aid the AID
43 */
44 void SetAid(uint8_t aid);
45 /**
46 * Set last beacon value
47 * \param lastBeacon the last beacon
48 */
49 void SetLastBeacon(uint16_t lastBeacon);
50 /**
51 * Set beacon interval value
52 * \param beaconInterval the beacon interval
53 */
54 void SetBeaconInterval(uint16_t beaconInterval);
55
56 /**
57 * Get AID value
58 * \returns the AID
59 */
60 uint8_t GetAid() const;
61 /**
62 * Get last beacon value
63 * \returns the last beacon
64 */
65 uint16_t GetLastBeacon() const;
66 /**
67 * Get beacon interval
68 * \returns the beacon interval
69 */
70 uint16_t GetBeaconInterval() const;
71
72 private:
73 /// Least significant octet of AID:
74 uint8_t m_aid;
75 /// Last time we received a beacon in accordance with a local TSF measured in 256 microseconds
76 /// unit
77 uint16_t m_lastBeacon;
78 /// Beacon interval of remote mesh point
80 /**
81 * equality operator
82 *
83 * \param a lhs
84 * \param b rhs
85 * \returns true if equal
86 */
87 friend bool operator==(const IeBeaconTimingUnit& a, const IeBeaconTimingUnit& b);
88};
89
90/**
91 * \ingroup dot11s
92 * \brief See 7.3.2.89 of 802.11s draft 2.07
93 */
95{
96 public:
97 /**
98 * \ingroup dot11s
99 * This type is a list of timing elements obtained from neighbours with their beacons:
100 */
101 typedef std::vector<Ptr<IeBeaconTimingUnit>> NeighboursTimingUnitsList;
102
104 /**
105 * This methods are needed for beacon collision
106 * avoidance module:
107 * \returns the neighbor timing elements list
108 */
110 /**
111 * Add neighbors timing element unit
112 * \param aid the AID
113 * \param last_beacon the last beacon time
114 * \param beacon_interval the beacon interval
115 */
116 void AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval);
117 /**
118 * Delete neighbors timing element unit
119 * \param aid the AID
120 * \param last_beacon the last beacon time
121 * \param beacon_interval the beacon interval
122 */
123 void DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval);
124 /// Clear timing element
125 void ClearTimingElement();
126
127 // Inherited from WifiInformationElement
128 WifiInformationElementId ElementId() const override;
129 uint16_t GetInformationFieldSize() const override;
130 void SerializeInformationField(Buffer::Iterator i) const override;
131 uint16_t DeserializeInformationField(Buffer::Iterator i, uint16_t length) override;
132 void Print(std::ostream& os) const override;
133
134 /**
135 * equality operator
136 *
137 * \param a lhs
138 * \returns true if equal
139 */
140 bool operator==(const WifiInformationElement& a) const override;
141
142 private:
143 // Converters:
144 /**
145 * Timestamp to U16 function
146 * \param x the timestamp
147 * \returns the U16
148 */
149 static uint16_t TimestampToU16(Time x);
150 /**
151 * Beacon interval to U16 function
152 * \param x the beacon interval
153 * \returns the U16
154 */
155 static uint16_t BeaconIntervalToU16(Time x);
156 /**
157 * Aid to U8 function
158 * \param x the U16
159 * \returns the AID
160 */
161 static uint8_t AidToU8(uint16_t x);
162
164 /**
165 * Timing element parameters:
166 */
167 uint16_t m_numOfUnits;
168};
169
170bool operator==(const IeBeaconTimingUnit& a, const IeBeaconTimingUnit& b);
171std::ostream& operator<<(std::ostream& os, const IeBeaconTiming& beaconTiming);
172} // namespace dot11s
173} // namespace ns3
174#endif
iterator in a Buffer instance
Definition: buffer.h:100
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Information element, as defined in 802.11-2007 standard.
See 7.3.2.89 of 802.11s draft 2.07.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval)
Add neighbors timing element unit.
static uint16_t BeaconIntervalToU16(Time x)
Beacon interval to U16 function.
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool operator==(const WifiInformationElement &a) const override
equality operator
uint16_t DeserializeInformationField(Buffer::Iterator i, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
void ClearTimingElement()
Clear timing element.
uint16_t m_numOfUnits
Timing element parameters:
NeighboursTimingUnitsList GetNeighboursTimingElementsList()
This methods are needed for beacon collision avoidance module:
static uint8_t AidToU8(uint16_t x)
Aid to U8 function.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
NeighboursTimingUnitsList m_neighbours
the neighbors
static uint16_t TimestampToU16(Time x)
Timestamp to U16 function.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
void DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval)
Delete neighbors timing element unit.
Information element describing one unit of beacon timing element.
uint16_t m_lastBeacon
Last time we received a beacon in accordance with a local TSF measured in 256 microseconds unit.
void SetBeaconInterval(uint16_t beaconInterval)
Set beacon interval value.
friend bool operator==(const IeBeaconTimingUnit &a, const IeBeaconTimingUnit &b)
equality operator
uint16_t m_beaconInterval
Beacon interval of remote mesh point.
uint16_t GetBeaconInterval() const
Get beacon interval.
void SetAid(uint8_t aid)
Set AID value.
void SetLastBeacon(uint16_t lastBeacon)
Set last beacon value.
uint16_t GetLastBeacon() const
Get last beacon value.
uint8_t GetAid() const
Get AID value.
uint8_t m_aid
Least significant octet of AID:
std::vector< Ptr< IeBeaconTimingUnit > > NeighboursTimingUnitsList
This type is a list of timing elements obtained from neighbours with their beacons:
bool operator==(const MeshHeader &a, const MeshHeader &b)
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.