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 
27 namespace ns3 {
28 namespace dot11s {
29 NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenStart);
30 
32  m_capability (0), m_rates (SupportedRates ()), m_meshId (),
33  m_config (IeConfiguration ())
34 {
35 }
36 void
38 {
39  m_capability = fields.capability;
40  m_rates = fields.rates;
41  m_meshId = fields.meshId;
42  m_config = fields.config;
43 }
46 {
47  PlinkOpenStartFields retval;
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 }
56 TypeId
58 {
59  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkOpenStart")
60  .SetParent<Header> ()
61  .SetGroupName ("Mesh")
62  .AddConstructor<PeerLinkOpenStart> ()
63  ;
64  return tid;
65 }
66 TypeId
68 {
69  return GetTypeId ();
70 }
71 void
72 PeerLinkOpenStart::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 }
80 uint32_t
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 }
91 void
93 {
95 
97  i = m_rates.Serialize (i);
98  i = m_rates.extended.Serialize (i);
99  i = m_meshId.Serialize (i);
100  i = m_config.Serialize (i);
101 }
102 uint32_t
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 }
129 bool
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 }
142 void
144 {
145  m_meshId = fields.meshId;
146 }
149 {
150  PlinkCloseStartFields retval;
152  retval.meshId = m_meshId;
153 
154  return retval;
155 }
156 TypeId
158 {
159  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkCloseStart")
160  .SetParent<Header> ()
161  .SetGroupName ("Mesh")
162  .AddConstructor<PeerLinkCloseStart> ()
163  ;
164  return tid;
165 }
166 TypeId
168 {
169  return GetTypeId ();
170 }
171 void
172 PeerLinkCloseStart::Print (std::ostream &os) const
173 {
174  m_meshId.Print (os);
175 }
176 uint32_t
178 {
179  uint32_t size =0; //Peering protocol
180  size += m_meshId.GetInformationFieldSize () + 2;
181  return size;
182 }
183 void
185 {
187  i = m_meshId.Serialize (i);
188 }
189 uint32_t
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 }
204 bool
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 }
216 void
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 }
236 TypeId
238 {
239  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkConfirmStart")
240  .SetParent<Header> ()
241  .SetGroupName ("Mesh")
242  .AddConstructor<PeerLinkConfirmStart> ()
243  ;
244  return tid;
245 }
246 TypeId
248 {
249  return GetTypeId ();
250 }
251 void
252 PeerLinkConfirmStart::Print (std::ostream &os) const
253 {
254  os << "capability=" << m_capability << ", rates=" << m_rates;
255  os << ", ";
256  m_config.Print (os);
257 }
258 uint32_t
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 }
269 void
271 {
273 
275  i.WriteHtolsbU16 (m_aid);
276  i = m_rates.Serialize (i);
277  i = m_rates.extended.Serialize (i);
278  i = m_config.Serialize (i);
279 }
280 uint32_t
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 }
299 bool
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 
Protocol header serialization and deserialization.
Definition: header.h:42
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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) ...
def start()
Definition: core.py:1806
uint16_t GetSerializedSize() const
Return the serialized size of this supported rates information element.
virtual WifiInformationElementId ElementId() const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE, which must be present.
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:786
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
iterator in a Buffer instance
Definition: buffer.h:98
ExtendedSupportedRatesIE extended
extended supported rates info element
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if there are more than 8 rates...
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
Deserialize entire IE if it is present.
void Next(void)
go forward by one byte
Definition: buffer.h:845
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) ...
virtual WifiInformationElementId ElementId() const
Definition: ie-dot11s-id.cc:53
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:913
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
uint8_t ReadU8(void)
Definition: buffer.h:1021
bool IsEqual(IeMeshId const &o) const
Equality test.
Definition: ie-dot11s-id.cc:58
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1068
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...