A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ie-dot11s-configuration.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008,2009 IITP RAS
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Kirill Andreev <andreev@iitp.ru>
19
* Aleksey Kovalenko <kovalenko@iitp.ru>
20
*/
21
22
#include "
ie-dot11s-configuration.h
"
23
#include "ns3/packet.h"
24
namespace
ns3 {
25
namespace
dot11s {
26
27
Dot11sMeshCapability::Dot11sMeshCapability
() :
28
acceptPeerLinks (true), MCCASupported (false), MCCAEnabled (false), forwarding (true), beaconTimingReport (
29
true), TBTTAdjustment (true), powerSaveLevel (false)
30
{
31
}
32
uint8_t
33
Dot11sMeshCapability::GetSerializedSize
()
const
34
{
35
return
2;
36
}
37
uint16_t
38
Dot11sMeshCapability::GetUint16
()
const
39
{
40
uint16_t result = 0;
41
if
(
acceptPeerLinks
)
42
{
43
result |= 1 << 0;
44
}
45
if
(
MCCASupported
)
46
{
47
result |= 1 << 1;
48
}
49
if
(
MCCAEnabled
)
50
{
51
result |= 1 << 2;
52
}
53
if
(
forwarding
)
54
{
55
result |= 1 << 3;
56
}
57
if
(
beaconTimingReport
)
58
{
59
result |= 1 << 4;
60
}
61
if
(
TBTTAdjustment
)
62
{
63
result |= 1 << 5;
64
}
65
if
(
powerSaveLevel
)
66
{
67
result |= 1 << 6;
68
}
69
return
result;
70
}
71
Buffer::Iterator
72
Dot11sMeshCapability::Serialize
(
Buffer::Iterator
i)
const
73
{
74
i.
WriteHtolsbU16
(
GetUint16
());
75
return
i;
76
}
77
Buffer::Iterator
78
Dot11sMeshCapability::Deserialize
(
Buffer::Iterator
i)
79
{
80
uint16_t cap = i.
ReadLsbtohU16
();
81
acceptPeerLinks
=
Is
(cap, 0);
82
MCCASupported
=
Is
(cap, 1);
83
MCCAEnabled
=
Is
(cap, 2);
84
forwarding
=
Is
(cap, 3);
85
beaconTimingReport
=
Is
(cap, 4);
86
TBTTAdjustment
=
Is
(cap, 5);
87
powerSaveLevel
=
Is
(cap, 6);
88
return
i;
89
}
90
bool
91
Dot11sMeshCapability::Is
(uint16_t cap, uint8_t n)
const
92
{
93
uint16_t mask = 1 << n;
94
return
(cap & mask);
95
}
96
WifiInformationElementId
97
IeConfiguration::ElementId
()
const
98
{
99
return
IE11S_MESH_CONFIGURATION
;
100
}
101
102
IeConfiguration::IeConfiguration
() :
103
m_APSPId (
PROTOCOL_HWMP
), m_APSMId (
METRIC_AIRTIME
), m_CCMId (
CONGESTION_NULL
), m_SPId (
104
SYNC_NEIGHBOUR_OFFSET
), m_APId (
AUTH_NULL
), m_neighbors (0)
105
{
106
}
107
uint8_t
108
IeConfiguration::GetInformationFieldSize
()
const
109
{
110
return
1
// Version
111
+ 4
// APSPId
112
+ 4
// APSMId
113
+ 4
// CCMId
114
+ 4
// SPId
115
+ 4
// APId
116
+ 1
// Mesh formation info (see 7.3.2.86.6 of 802.11s draft 3.0)
117
+
m_meshCap
.
GetSerializedSize
();
118
}
119
void
120
IeConfiguration::SerializeInformationField
(
Buffer::Iterator
i)
const
121
{
122
i.
WriteU8
(1);
//Version
123
// Active Path Selection Protocol ID:
124
i.
WriteHtolsbU32
(
m_APSPId
);
125
// Active Path Metric ID:
126
i.
WriteHtolsbU32
(
m_APSMId
);
127
// Congestion Control Mode ID:
128
i.
WriteHtolsbU32
(
m_CCMId
);
129
// Sync:
130
i.
WriteHtolsbU32
(
m_SPId
);
131
// Auth:
132
i.
WriteHtolsbU32
(
m_APId
);
133
i.
WriteU8
(
m_neighbors
<< 1);
134
m_meshCap
.
Serialize
(i);
135
}
136
uint8_t
137
IeConfiguration::DeserializeInformationField
(
Buffer::Iterator
i, uint8_t length)
138
{
139
Buffer::Iterator
start
= i;
140
uint8_t
version
;
141
version = i.
ReadU8
();
142
if
(version != 1)
143
{
144
NS_FATAL_ERROR
(
"Other versions not supported yet"
);
145
}
146
// Active Path Selection Protocol ID:
147
m_APSPId
= (
dot11sPathSelectionProtocol
) i.
ReadLsbtohU32
();
148
// Active Path Metric ID:
149
m_APSMId
= (
dot11sPathSelectionMetric
) i.
ReadLsbtohU32
();
150
// Congestion Control Mode ID:
151
m_CCMId
= (
dot11sCongestionControlMode
) i.
ReadLsbtohU32
();
152
m_SPId
= (
dot11sSynchronizationProtocolIdentifier
) i.
ReadLsbtohU32
();
153
m_APId
= (
dot11sAuthenticationProtocol
) i.
ReadLsbtohU32
();
154
m_neighbors
= (i.
ReadU8
() >> 1) & 0xF;
155
i =
m_meshCap
.
Deserialize
(i);
156
return
i.
GetDistanceFrom
(start);
157
}
158
void
159
IeConfiguration::Print
(std::ostream& os)
const
160
{
161
os << std::endl <<
"<information_element id="
<<
ElementId
() <<
">"
<< std::endl;
162
os <<
"Number of neighbors: = "
<< (uint16_t)
m_neighbors
163
<< std::endl <<
"Active Path Selection Protocol ID: = "
<< (uint32_t)
m_APSPId
164
<< std::endl <<
"Active Path Selection Metric ID: = "
<< (uint32_t)
m_APSMId
165
<< std::endl <<
"Congestion Control Mode ID: = "
<< (uint32_t)
m_CCMId
166
<< std::endl <<
"Synchronize protocol ID: = "
<< (uint32_t)
m_SPId
167
<< std::endl <<
"Authentication protocol ID: = "
<< (uint32_t)
m_APId
168
<< std::endl <<
"Capabilities: = "
<<
m_meshCap
.
GetUint16
() << std::endl;
169
os <<
"</information_element>"
<< std::endl;
170
}
171
void
172
IeConfiguration::SetRouting
(
dot11sPathSelectionProtocol
routingId)
173
{
174
m_APSPId
= routingId;
175
}
176
void
177
IeConfiguration::SetMetric
(
dot11sPathSelectionMetric
metricId)
178
{
179
m_APSMId
= metricId;
180
}
181
bool
182
IeConfiguration::IsHWMP
()
183
{
184
return
(
m_APSPId
==
PROTOCOL_HWMP
);
185
}
186
bool
187
IeConfiguration::IsAirtime
()
188
{
189
return
(
m_APSMId
==
METRIC_AIRTIME
);
190
}
191
void
192
IeConfiguration::SetNeighborCount
(uint8_t neighbors)
193
{
194
m_neighbors
= (neighbors > 31) ? 31 : neighbors;
195
}
196
uint8_t
197
IeConfiguration::GetNeighborCount
()
198
{
199
return
m_neighbors
;
200
}
201
Dot11sMeshCapability
const
&
202
IeConfiguration::MeshCapability
()
203
{
204
return
m_meshCap
;
205
}
206
bool
207
operator==
(
const
Dot11sMeshCapability
& a,
const
Dot11sMeshCapability
& b)
208
{
209
return
((a.
acceptPeerLinks
== b.
acceptPeerLinks
) && (a.
MCCASupported
== b.
MCCASupported
) && (a.
MCCAEnabled
210
== b.
MCCAEnabled
) && (a.
forwarding
== b.
forwarding
) && (a.
beaconTimingReport
== b.
beaconTimingReport
)
211
&& (a.
TBTTAdjustment
== b.
TBTTAdjustment
) && (a.
powerSaveLevel
== b.
powerSaveLevel
));
212
}
213
bool
214
operator==
(
const
IeConfiguration
& a,
const
IeConfiguration
& b)
215
{
216
return
((a.
m_APSPId
== b.
m_APSPId
) && (a.
m_APSMId
== b.
m_APSMId
) && (a.
m_CCMId
== b.
m_CCMId
) && (a.
m_SPId
217
== b.
m_SPId
) && (a.
m_APId
== b.
m_APId
) && (a.
m_neighbors
== b.
m_neighbors
) && (a.
m_meshCap
218
== b.
m_meshCap
));
219
}
220
std::ostream &
221
operator <<
(std::ostream &os,
const
IeConfiguration
&a)
222
{
223
a.
Print
(os);
224
return
os;
225
}
226
}
// namespace dot11s
227
}
// namespace ns3
228
src
mesh
model
dot11s
ie-dot11s-configuration.cc
Generated on Tue Nov 13 2012 10:32:18 for ns-3 by
1.8.1.2