A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-configuration.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Kirill Andreev <andreev@iitp.ru>
7 * Aleksey Kovalenko <kovalenko@iitp.ru>
8 */
9
11
12#include "ns3/packet.h"
13
14namespace ns3
15{
16namespace dot11s
17{
18
20 : acceptPeerLinks(true),
21 MCCASupported(false),
22 MCCAEnabled(false),
23 forwarding(true),
24 beaconTimingReport(true),
25 TBTTAdjustment(true),
26 powerSaveLevel(false)
27{
28}
29
30uint8_t
32{
33 return 1;
34}
35
36uint8_t
37Dot11sMeshCapability::GetUint8() const // IEEE 802.11-2012 8.4.2.100.8 Mesh Capability
38{
39 uint8_t result = 0;
41 {
42 result |= 1 << 0; // The Accepting Additional Mesh Peerings subfield is set to 1 if the mesh
43 // STA is willing to establish additional mesh peerings with other mesh
44 // STAs and set to 0 otherwise
45 }
46 if (MCCASupported) // The MCCA Supported subfield is set to 1 if the mesh STA implements MCCA
47 // and set to 0 otherwise
48 {
49 result |= 1 << 1;
50 }
51 if (MCCAEnabled)
52 {
53 result |= 1 << 2;
54 }
55 if (forwarding)
56 {
57 result |= 1 << 3;
58 }
60 {
61 result |= 1 << 4;
62 }
64 {
65 result |= 1 << 5;
66 }
68 {
69 result |= 1 << 6;
70 }
71 return result;
72}
73
80
83{
84 uint8_t cap = i.ReadU8();
85 acceptPeerLinks = Is(cap, 0);
86 MCCASupported = Is(cap, 1);
87 MCCAEnabled = Is(cap, 2);
88 forwarding = Is(cap, 3);
89 beaconTimingReport = Is(cap, 4);
90 TBTTAdjustment = Is(cap, 5);
91 powerSaveLevel = Is(cap, 6);
92 return i;
93}
94
95bool
96Dot11sMeshCapability::Is(uint8_t cap, uint8_t n) const
97{
98 uint16_t mask = 1 << n;
99 return (cap & mask);
100}
101
107
109 : m_APSPId(PROTOCOL_HWMP),
110 m_APSMId(METRIC_AIRTIME),
111 m_CCMId(CONGESTION_NULL),
112 m_SPId(SYNC_NEIGHBOUR_OFFSET),
113 m_APId(AUTH_NULL),
114 m_neighbors(0)
115{
116}
117
118uint16_t
120{
121 return 0 // Version
122 + 1 // APSPId
123 + 1 // APSMId
124 + 1 // CCMId
125 + 1 // SPId
126 + 1 // APId
127 + 1 // Mesh formation info (see 7.3.2.86.6 of 802.11s draft 3.0)
129}
130
131void
133{
134 // Active Path Selection Protocol ID:
135 i.WriteU8(m_APSPId);
136 // Active Path Metric ID:
137 i.WriteU8(m_APSMId);
138 // Congestion Control Mode ID:
139 i.WriteU8(m_CCMId);
140 // Sync:
141 i.WriteU8(m_SPId);
142 // Auth:
143 i.WriteU8(m_APId);
144 i.WriteU8(m_neighbors << 1);
146}
147
148uint16_t
150{
151 Buffer::Iterator start = i;
152 // Active Path Selection Protocol ID:
154 // Active Path Metric ID:
156 // Congestion Control Mode ID:
160 m_neighbors = (i.ReadU8() >> 1) & 0xF;
161 i = m_meshCap.Deserialize(i);
162 return i.GetDistanceFrom(start);
163}
164
165void
166IeConfiguration::Print(std::ostream& os) const
167{
168 os << "MeshConfiguration=(neighbors=" << (uint16_t)m_neighbors
169 << ", Active Path Selection Protocol ID=" << (uint32_t)m_APSPId
170 << ", Active Path Selection Metric ID=" << (uint32_t)m_APSMId
171 << ", Congestion Control Mode ID=" << (uint32_t)m_CCMId
172 << ", Synchronize protocol ID=" << (uint32_t)m_SPId
173 << ", Authentication protocol ID=" << (uint32_t)m_APId
174 << ", Capabilities=" << m_meshCap.GetUint8();
175 os << ")";
176}
177
178void
183
184void
189
190bool
192{
193 return (m_APSPId == PROTOCOL_HWMP);
194}
195
196bool
201
202void
204{
205 m_neighbors = (neighbors > 31) ? 31 : neighbors;
206}
207
208uint8_t
210{
211 return m_neighbors;
212}
213
219
220bool
228
229bool
231{
232 return ((a.m_APSPId == b.m_APSPId) && (a.m_APSMId == b.m_APSMId) && (a.m_CCMId == b.m_CCMId) &&
233 (a.m_SPId == b.m_SPId) && (a.m_APId == b.m_APId) && (a.m_neighbors == b.m_neighbors) &&
234 (a.m_meshCap == b.m_meshCap));
235}
236
237std::ostream&
238operator<<(std::ostream& os, const IeConfiguration& a)
239{
240 a.Print(os);
241 return os;
242}
243} // namespace dot11s
244} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
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