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  ;
31 
33  m_subtype (255), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
34  m_config (IeConfiguration ()), m_reasonCode ((uint16_t)REASON11S_RESERVED)
35 {
36 }
37 void
39 {
40  m_subtype = subtype;
41 }
42 void
44 {
45  m_subtype = fields.subtype;
46  m_protocol = fields.protocol;
48  {
49  m_capability = fields.capability;
50  }
52  {
53  m_aid = fields.aid;
54  }
56  {
57  m_rates = fields.rates;
58  }
60  {
61  m_meshId = fields.meshId;
62  }
64  {
65  m_config = fields.config;
66  }
67  else
68  {
69  m_reasonCode = fields.reasonCode;
70  }
71 }
74 {
75  PlinkFrameStartFields retval;
77  retval.subtype = m_subtype;
78  retval.capability = m_capability;
79  retval.aid = m_aid;
80  retval.rates = m_rates;
81  retval.meshId = m_meshId;
82  retval.config = m_config;
83  retval.reasonCode = m_reasonCode;
84  return retval;
85 }
86 TypeId
88 {
89  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkFrameStart").SetParent<Header> ().AddConstructor<
91  return tid;
92 }
93 TypeId
95 {
96  return GetTypeId ();
97 }
98 void
99 PeerLinkFrameStart::Print (std::ostream &os) const
100 {
101  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
102  << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
103  m_meshId.Print (os);
104  os << std::endl << "configuration = ";
105  m_config.Print (os);
106  os << std::endl << "reason code = " << m_reasonCode;
107 }
108 uint32_t
110 {
111  uint32_t size = 3; //Peering protocol
112  NS_ASSERT (m_subtype < 3);
114  {
115  size += 2; //capability
116  }
118  {
119  size += 2; //AID of remote peer
120  }
122  {
123  size += m_rates.GetSerializedSize ();
125  }
127  {
128  size += m_meshId.GetInformationFieldSize () + 2;
129  }
131  {
132  size += m_config.GetInformationFieldSize () + 2;
133  }
134  else
135  {
136  size += 2; //reasonCode
137  }
138  return size;
139 }
140 void
142 {
144  NS_ASSERT (m_subtype < 3);
145  i = m_protocol.Serialize (i);
147  {
149  }
151  {
152  i.WriteHtolsbU16 (m_aid);
153  }
155  {
156  i = m_rates.Serialize (i);
157  i = m_rates.extended.Serialize (i);
158  }
160  {
161  i = m_meshId.Serialize (i);
162  }
164  {
165  i = m_config.Serialize (i);
166  }
167  else
168  {
170  }
171 }
172 uint32_t
174 {
176  NS_ASSERT (m_subtype < 3);
177  {
178  uint8_t id = i.ReadU8 ();
179  uint8_t length = i.ReadU8 ();
182  {
183  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
184  }
186  }
188  {
190  }
192  {
193  m_aid = i.ReadLsbtohU16 ();
194  }
196  {
197  i = m_rates.Deserialize (i);
199  }
201  {
202  uint8_t id = i.ReadU8 ();
203  uint8_t length = i.ReadU8 ();
206  {
207  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
208  }
210  }
212  {
213  uint8_t id = i.ReadU8 ();
214  uint8_t length = i.ReadU8 ();
217  {
218  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
219  }
221  }
222  else
223  {
225  }
226  return i.GetDistanceFrom (start);
227 }
228 bool
230 {
231  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
232  && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config)
233  && (a.m_reasonCode == b.m_reasonCode));
234 }
235 } // namespace dot11s
236 } // namespace ns3
237 
Protocol header serialization and deserialization.
Definition: header.h:42
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)
Definition: assert.h:64
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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:807
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
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:666
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:935
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
uint8_t ReadU8(void)
Definition: buffer.h:819
bool IsEqual(IeMeshId const &o) const
Definition: ie-dot11s-id.cc:58
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1090
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:611
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...