A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 (PeerLinkFrameStart);
30 
32  m_subtype (255), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
33  m_config (IeConfiguration ()), m_reasonCode ((uint16_t)REASON11S_RESERVED)
34 {
35 }
36 void
38 {
39  m_subtype = subtype;
40 }
41 void
43 {
44  m_subtype = fields.subtype;
45  m_protocol = fields.protocol;
47  {
48  m_capability = fields.capability;
49  }
51  {
52  m_aid = fields.aid;
53  }
55  {
56  m_rates = fields.rates;
57  }
59  {
60  m_meshId = fields.meshId;
61  }
63  {
64  m_config = fields.config;
65  }
66  else
67  {
68  m_reasonCode = fields.reasonCode;
69  }
70 }
73 {
74  PlinkFrameStartFields retval;
76  retval.subtype = m_subtype;
77  retval.capability = m_capability;
78  retval.aid = m_aid;
79  retval.rates = m_rates;
80  retval.meshId = m_meshId;
81  retval.config = m_config;
82  retval.reasonCode = m_reasonCode;
83  return retval;
84 }
85 TypeId
87 {
88  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkFrameStart").SetParent<Header> ().AddConstructor<
90  return tid;
91 }
92 TypeId
94 {
95  return GetTypeId ();
96 }
97 void
98 PeerLinkFrameStart::Print (std::ostream &os) const
99 {
100  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
101  << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
102  m_meshId.Print (os);
103  os << std::endl << "configuration = ";
104  m_config.Print (os);
105  os << std::endl << "reason code = " << m_reasonCode;
106 }
107 uint32_t
109 {
110  uint32_t size = 3; //Peering protocol
111  NS_ASSERT (m_subtype < 3);
113  {
114  size += 2; //capability
115  }
117  {
118  size += 2; //AID of remote peer
119  }
121  {
122  size += m_rates.GetSerializedSize ();
124  }
126  {
127  size += m_meshId.GetInformationFieldSize () + 2;
128  }
130  {
131  size += m_config.GetInformationFieldSize () + 2;
132  }
133  else
134  {
135  size += 2; //reasonCode
136  }
137  return size;
138 }
139 void
141 {
143  NS_ASSERT (m_subtype < 3);
144  i = m_protocol.Serialize (i);
146  {
148  }
150  {
151  i.WriteHtolsbU16 (m_aid);
152  }
154  {
155  i = m_rates.Serialize (i);
156  i = m_rates.extended.Serialize (i);
157  }
159  {
160  i = m_meshId.Serialize (i);
161  }
163  {
164  i = m_config.Serialize (i);
165  }
166  else
167  {
169  }
170 }
171 uint32_t
173 {
175  NS_ASSERT (m_subtype < 3);
176  {
177  uint8_t id = i.ReadU8 ();
178  uint8_t length = i.ReadU8 ();
181  {
182  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
183  }
185  }
187  {
189  }
191  {
192  m_aid = i.ReadLsbtohU16 ();
193  }
195  {
196  i = m_rates.Deserialize (i);
198  }
200  {
201  uint8_t id = i.ReadU8 ();
202  uint8_t length = i.ReadU8 ();
205  {
206  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
207  }
209  }
211  {
212  uint8_t id = i.ReadU8 ();
213  uint8_t length = i.ReadU8 ();
216  {
217  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
218  }
220  }
221  else
222  {
224  }
225  return i.GetDistanceFrom (start);
226 }
227 bool
229 {
230  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
231  && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)
232  && (a.m_reasonCode == b.m_reasonCode));
233 }
234 } // namespace dot11s
235 } // namespace ns3
236 
Protocol header serialization and deserialization.
Definition: header.h:42
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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) ...
uint16_t GetSerializedSize() const
Return the serialized size of this supported rates information element.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
bool operator==(const MeshHeader &a, const MeshHeader &b)
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE, which must be present.
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:811
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
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) ...
ExtendedSupportedRatesIE extended
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
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:852
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
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
Own unique Element ID.
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 WifiInformationElementId ElementId() const
Own unique Element ID.
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:939
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
uint8_t ReadU8(void)
Definition: buffer.h:1028
bool IsEqual(IeMeshId const &o) const
Definition: ie-dot11s-id.cc:58
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1094
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
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...