A Discrete-Event Network Simulator
API
peer-link-frame.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 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 */
20
21#include "peer-link-frame.h"
23#include "ns3/mesh-wifi-interface-mac.h"
24#include "ns3/test.h"
25#include "ns3/packet.h"
26
27namespace ns3 {
28namespace dot11s {
29NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenStart);
30
32 m_capability (0), m_rates (SupportedRates ()), m_meshId (),
33 m_config (IeConfiguration ())
34{
35}
36void
38{
39 m_capability = fields.capability;
40 m_rates = fields.rates;
41 m_meshId = fields.meshId;
42 m_config = fields.config;
43}
46{
49 retval.capability = m_capability;
50 retval.rates = m_rates;
51 retval.meshId = m_meshId;
52 retval.config = m_config;
53
54 return retval;
55}
58{
59 static TypeId tid = TypeId ("ns3::dot11s::PeerLinkOpenStart")
60 .SetParent<Header> ()
61 .SetGroupName ("Mesh")
62 .AddConstructor<PeerLinkOpenStart> ()
63 ;
64 return tid;
65}
68{
69 return GetTypeId ();
70}
71void
72PeerLinkOpenStart::Print (std::ostream &os) const
73{
74 os << "capability=" << m_capability << ", rates=" << m_rates;
75 os << ", ";
76 m_meshId.Print (os);
77 os << ", ";
78 m_config.Print (os);
79}
82{
83 uint32_t size =0; //Peering protocol
84 size += 2; //capability
85 size += m_rates.GetSerializedSize ();
87 size += m_meshId.GetInformationFieldSize () + 2;
88 size += m_config.GetInformationFieldSize () + 2;
89 return size;
90}
91void
93{
95
97 i = m_rates.Serialize (i);
99 i = m_meshId.Serialize (i);
100 i = m_config.Serialize (i);
101}
104{
106
108 i = m_rates.Deserialize (i);
110 uint8_t id = i.ReadU8 ();
111 uint8_t length = i.ReadU8 ();
114 {
115 NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
116 }
118 id = i.ReadU8 ();
119 length = i.ReadU8 ();
122 {
123 NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
124 }
126
127 return i.GetDistanceFrom (start);
128}
129bool
131{
132 return ((a.m_capability == b.m_capability)
133 && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
134
135}
137
139 m_meshId ()
140{
141}
142void
144{
145 m_meshId = fields.meshId;
146}
149{
152 retval.meshId = m_meshId;
153
154 return retval;
155}
156TypeId
158{
159 static TypeId tid = TypeId ("ns3::dot11s::PeerLinkCloseStart")
160 .SetParent<Header> ()
161 .SetGroupName ("Mesh")
162 .AddConstructor<PeerLinkCloseStart> ()
163 ;
164 return tid;
165}
166TypeId
168{
169 return GetTypeId ();
170}
171void
172PeerLinkCloseStart::Print (std::ostream &os) const
173{
174 m_meshId.Print (os);
175}
178{
179 uint32_t size =0; //Peering protocol
180 size += m_meshId.GetInformationFieldSize () + 2;
181 return size;
182}
183void
185{
187 i = m_meshId.Serialize (i);
188}
191{
193
194 uint8_t id = i.ReadU8 ();
195 uint8_t length = i.ReadU8 ();
198 {
199 NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
200 }
202 return i.GetDistanceFrom (start);
203}
204bool
206{
207 return ((a.m_meshId.IsEqual (b.m_meshId)));
208}
210
212 m_capability (0), m_aid (0), m_rates (SupportedRates ()),
213 m_config (IeConfiguration ())
214{
215}
216void
218{
219 m_capability = fields.capability;
220 m_aid = fields.aid;
221 m_rates = fields.rates;
222 m_config = fields.config;
223}
226{
229 retval.capability = m_capability;
230 retval.aid = m_aid;
231 retval.rates = m_rates;
232 retval.config = m_config;
233
234 return retval;
235}
236TypeId
238{
239 static TypeId tid = TypeId ("ns3::dot11s::PeerLinkConfirmStart")
240 .SetParent<Header> ()
241 .SetGroupName ("Mesh")
242 .AddConstructor<PeerLinkConfirmStart> ()
243 ;
244 return tid;
245}
246TypeId
248{
249 return GetTypeId ();
250}
251void
252PeerLinkConfirmStart::Print (std::ostream &os) const
253{
254 os << "capability=" << m_capability << ", rates=" << m_rates;
255 os << ", ";
256 m_config.Print (os);
257}
260{
261 uint32_t size =0; //Peering protocol
262 size += 2; //capability
263 size += 2; //AID of remote peer
264 size += m_rates.GetSerializedSize ();
266 size += m_config.GetInformationFieldSize () + 2;
267 return size;
268}
269void
271{
273
276 i = m_rates.Serialize (i);
277 i = m_rates.extended.Serialize (i);
278 i = m_config.Serialize (i);
279}
282{
284
286 m_aid = i.ReadLsbtohU16 ();
287 i = m_rates.Deserialize (i);
289 uint8_t id = i.ReadU8 ();
290 uint8_t length = i.ReadU8 ();
293 {
294 NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
295 }
297 return i.GetDistanceFrom (start);
298}
299bool
301{
302 return ((a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
303 && (a.m_config == b.m_config));
304}
305} // namespace dot11s
306} // namespace ns3
307
iterator in a Buffer instance
Definition: buffer.h:99
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:911
void Next(void)
go forward by one byte
Definition: buffer.h:845
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1066
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
uint16_t GetSerializedSize() const override
Get the size of the serialized IE including Element ID and length fields.
Buffer::Iterator Serialize(Buffer::Iterator start) const override
Serialize entire IE including Element ID and length fields.
Protocol header serialization and deserialization.
Definition: header.h:43
The Supported Rates Information Element.
ExtendedSupportedRatesIE extended
extended supported rates info element
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE, which must be present.
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
Deserialize entire IE if it is present.
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
virtual uint8_t DeserializeInformationField(Buffer::Iterator i, uint8_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
virtual WifiInformationElementId ElementId() const
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
bool IsEqual(IeMeshId const &o) const
Equality test.
Definition: ie-dot11s-id.cc:58
virtual WifiInformationElementId ElementId() const
Definition: ie-dot11s-id.cc:53
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Definition: ie-dot11s-id.cc:86
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
virtual uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
bool operator==(const MeshHeader &a, const MeshHeader &b)
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.
def start()
Definition: core.py:1853