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 (PeerLinkFrameStart);
30 
32  m_subtype (255), m_capability (0), m_aid (0), m_rates (SupportedRates ()), m_meshId (),
33  m_config (IeConfiguration ())
34 {
35 }
36 void
38 {
39  m_subtype = subtype;
40 }
41 void
43 {
44  m_subtype = fields.subtype;
45 
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  //reasonCode not used here
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 
83  return retval;
84 }
85 TypeId
87 {
88  static TypeId tid = TypeId ("ns3::dot11s::PeerLinkFrameStart")
89  .SetParent<Header> ()
90  .SetGroupName ("Mesh")
91  .AddConstructor<PeerLinkFrameStart> ()
92  ;
93  return tid;
94 }
95 TypeId
97 {
98  return GetTypeId ();
99 }
100 void
101 PeerLinkFrameStart::Print (std::ostream &os) const
102 {
103  os << "subtype = " << (uint16_t) m_subtype << std::endl << "capability = " << m_capability << std::endl << "laid = "
104  << (uint16_t) m_aid << std::endl << "rates = " << m_rates << std::endl << "meshId = ";
105  m_meshId.Print (os);
106  os << std::endl << "configuration = ";
107  m_config.Print (os);
108  os << std::endl << "reason code = " << m_reasonCode;
109 }
110 uint32_t
112 {
113  uint32_t size =0; //Peering protocol
114  NS_ASSERT (m_subtype < 4);
116  {
117  size += 2; //capability
118  }
120  {
121  size += 2; //AID of remote peer
122  }
124  {
125  size += m_rates.GetSerializedSize ();
127  }
129  {
130  size += m_meshId.GetInformationFieldSize () + 2;
131  }
133  {
134  size += m_config.GetInformationFieldSize () + 2;
135  }
136  else
137  {
138  //reasonCode not used here
139  }
140  return size;
141 }
142 void
144 {
146  NS_ASSERT (m_subtype < 4);
147 
149  {
151  }
153  {
154  i.WriteHtolsbU16 (m_aid);
155  }
157  {
158  i = m_rates.Serialize (i);
159  i = m_rates.extended.Serialize (i);
160  }
162  {
163  i = m_meshId.Serialize (i);
164  }
166  {
167  i = m_config.Serialize (i);
168  }
169  else
170  {
171  //reasonCode not used here
172  }
173 }
174 uint32_t
176 {
178  NS_ASSERT (m_subtype < 4);
179 
181  {
183  }
185  {
186  m_aid = i.ReadLsbtohU16 ();
187  }
189  {
190  i = m_rates.Deserialize (i);
192  }
194  {
195  uint8_t id = i.ReadU8 ();
196  uint8_t length = i.ReadU8 ();
199  {
200  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
201  }
203  }
205  {
206  uint8_t id = i.ReadU8 ();
207  uint8_t length = i.ReadU8 ();
210  {
211  NS_FATAL_ERROR ("Broken frame: Element ID does not match IE itself!");
212  }
214  }
215  else
216  {
217  //reasonCode not used here
218  }
219  return i.GetDistanceFrom (start);
220 }
221 bool
223 {
224  return ((a.m_subtype == b.m_subtype) && (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid)
225  && (a.m_meshId.IsEqual (b.m_meshId)) && (a.m_config == b.m_config));
226 
227 }
228 } // namespace dot11s
229 } // namespace ns3
230 
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:44
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:1482
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:67
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
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
ExtendedSupportedRatesIE extended
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:852
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
Own unique Element ID.
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: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.
a unique identifier for an interface.
Definition: type-id.h:57
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
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...