A Discrete-Event Network Simulator
API
ie-dot11s-configuration.cc
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  * Authors: Kirill Andreev <andreev@iitp.ru>
18  * Aleksey Kovalenko <kovalenko@iitp.ru>
19  */
20 
22 
23 #include "ns3/packet.h"
24 
25 namespace ns3
26 {
27 namespace dot11s
28 {
29 
31  : acceptPeerLinks(true),
32  MCCASupported(false),
33  MCCAEnabled(false),
34  forwarding(true),
35  beaconTimingReport(true),
36  TBTTAdjustment(true),
37  powerSaveLevel(false)
38 {
39 }
40 
41 uint8_t
43 {
44  return 1;
45 }
46 
47 uint8_t
48 Dot11sMeshCapability::GetUint8() const // IEEE 802.11-2012 8.4.2.100.8 Mesh Capability
49 {
50  uint8_t result = 0;
51  if (acceptPeerLinks)
52  {
53  result |= 1 << 0; // The Accepting Additional Mesh Peerings subfield is set to 1 if the mesh
54  // STA is willing to establish additional mesh peerings with other mesh
55  // STAs and set to 0 otherwise
56  }
57  if (MCCASupported) // The MCCA Supported subfield is set to 1 if the mesh STA implements MCCA
58  // and set to 0 otherwise
59  {
60  result |= 1 << 1;
61  }
62  if (MCCAEnabled)
63  {
64  result |= 1 << 2;
65  }
66  if (forwarding)
67  {
68  result |= 1 << 3;
69  }
71  {
72  result |= 1 << 4;
73  }
74  if (TBTTAdjustment)
75  {
76  result |= 1 << 5;
77  }
78  if (powerSaveLevel)
79  {
80  result |= 1 << 6;
81  }
82  return result;
83 }
84 
87 {
88  i.WriteU8(GetUint8());
89  return i;
90 }
91 
94 {
95  uint8_t cap = i.ReadU8();
96  acceptPeerLinks = Is(cap, 0);
97  MCCASupported = Is(cap, 1);
98  MCCAEnabled = Is(cap, 2);
99  forwarding = Is(cap, 3);
100  beaconTimingReport = Is(cap, 4);
101  TBTTAdjustment = Is(cap, 5);
102  powerSaveLevel = Is(cap, 6);
103  return i;
104 }
105 
106 bool
107 Dot11sMeshCapability::Is(uint8_t cap, uint8_t n) const
108 {
109  uint16_t mask = 1 << n;
110  return (cap & mask);
111 }
112 
115 {
116  return IE_MESH_CONFIGURATION;
117 }
118 
120  : m_APSPId(PROTOCOL_HWMP),
121  m_APSMId(METRIC_AIRTIME),
122  m_CCMId(CONGESTION_NULL),
123  m_SPId(SYNC_NEIGHBOUR_OFFSET),
124  m_APId(AUTH_NULL),
125  m_neighbors(0)
126 {
127 }
128 
129 uint16_t
131 {
132  return 0 // Version
133  + 1 // APSPId
134  + 1 // APSMId
135  + 1 // CCMId
136  + 1 // SPId
137  + 1 // APId
138  + 1 // Mesh formation info (see 7.3.2.86.6 of 802.11s draft 3.0)
140 }
141 
142 void
144 {
145  // Active Path Selection Protocol ID:
146  i.WriteU8(m_APSPId);
147  // Active Path Metric ID:
148  i.WriteU8(m_APSMId);
149  // Congestion Control Mode ID:
150  i.WriteU8(m_CCMId);
151  // Sync:
152  i.WriteU8(m_SPId);
153  // Auth:
154  i.WriteU8(m_APId);
155  i.WriteU8(m_neighbors << 1);
156  m_meshCap.Serialize(i);
157 }
158 
159 uint16_t
161 {
163  // Active Path Selection Protocol ID:
165  // Active Path Metric ID:
167  // Congestion Control Mode ID:
171  m_neighbors = (i.ReadU8() >> 1) & 0xF;
172  i = m_meshCap.Deserialize(i);
173  return i.GetDistanceFrom(start);
174 }
175 
176 void
177 IeConfiguration::Print(std::ostream& os) const
178 {
179  os << "MeshConfiguration=(neighbors=" << (uint16_t)m_neighbors
180  << ", Active Path Selection Protocol ID=" << (uint32_t)m_APSPId
181  << ", Active Path Selection Metric ID=" << (uint32_t)m_APSMId
182  << ", Congestion Control Mode ID=" << (uint32_t)m_CCMId
183  << ", Synchronize protocol ID=" << (uint32_t)m_SPId
184  << ", Authentication protocol ID=" << (uint32_t)m_APId
185  << ", Capabilities=" << m_meshCap.GetUint8();
186  os << ")";
187 }
188 
189 void
191 {
192  m_APSPId = routingId;
193 }
194 
195 void
197 {
198  m_APSMId = metricId;
199 }
200 
201 bool
203 {
204  return (m_APSPId == PROTOCOL_HWMP);
205 }
206 
207 bool
209 {
210  return (m_APSMId == METRIC_AIRTIME);
211 }
212 
213 void
215 {
216  m_neighbors = (neighbors > 31) ? 31 : neighbors;
217 }
218 
219 uint8_t
221 {
222  return m_neighbors;
223 }
224 
227 {
228  return m_meshCap;
229 }
230 
231 bool
233 {
234  return ((a.acceptPeerLinks == b.acceptPeerLinks) && (a.MCCASupported == b.MCCASupported) &&
235  (a.MCCAEnabled == b.MCCAEnabled) && (a.forwarding == b.forwarding) &&
238 }
239 
240 bool
242 {
243  return ((a.m_APSPId == b.m_APSPId) && (a.m_APSMId == b.m_APSMId) && (a.m_CCMId == b.m_CCMId) &&
244  (a.m_SPId == b.m_SPId) && (a.m_APId == b.m_APId) && (a.m_neighbors == b.m_neighbors) &&
245  (a.m_meshCap == b.m_meshCap));
246 }
247 
248 std::ostream&
249 operator<<(std::ostream& os, const IeConfiguration& a)
250 {
251  a.Print(os);
252  return os;
253 }
254 } // namespace dot11s
255 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
A set of values indicating whether a mesh STA is a possible candidate for mesh peering establishment ...
uint8_t GetUint8() const
The Mesh Capability is expressed in terms of 8 single bit fields.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize to a buffer.
uint8_t GetSerializedSize() const
Size of the field in bytes when serialized.
bool Is(uint8_t cap, uint8_t n) const
This is a utility function to test if the bit at position n is true.
bool beaconTimingReport
beacon timing report
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize from a buffer.
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
void SetNeighborCount(uint8_t neighbors)
Set neighbor count.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
Dot11sMeshCapability m_meshCap
Mesh capability.
void SetMetric(Dot11sPathSelectionMetric metricId)
Set metric value.
const Dot11sMeshCapability & MeshCapability()
Mesh capability.
Dot11sPathSelectionMetric m_APSMId
Active Path Metric ID.
Dot11sAuthenticationProtocol m_APId
Auth protocol ID.
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)
Dot11sCongestionControlMode m_CCMId
Congestion Control Mode ID.
Dot11sSynchronizationProtocolIdentifier m_SPId
Sync protocol ID.
Dot11sPathSelectionProtocol m_APSPId
Active Path Selection Protocol ID.
uint8_t GetNeighborCount() const
Get neighbor count.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
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 SetRouting(Dot11sPathSelectionProtocol routingId)
Set routing value.
bool IsAirtime()
Is airtime function.
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.
#define IE_MESH_CONFIGURATION