A Discrete-Event Network Simulator
API
ie-dot11s-prep.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008,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  * Author: Kirill Andreev <andreev@iitp.ru>
19  */
20 
21 #include "ie-dot11s-prep.h"
22 #include "ns3/address-utils.h"
23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
25 namespace ns3 {
26 namespace dot11s {
27 /********************************
28  * IePrep
29  *******************************/
31 {
32 }
34  m_flags (0), m_hopcount (0), m_ttl (0), m_destinationAddress (Mac48Address::GetBroadcast ()),
35  m_destSeqNumber (0), m_lifetime (0), m_metric (0), m_originatorAddress (Mac48Address::GetBroadcast ()),
36  m_originatorSeqNumber (0)
37 {
38 }
41 {
42  return IE_PREP;
43 }
44 void
45 IePrep::SetFlags (uint8_t flags)
46 {
47  m_flags = flags;
48 }
49 void
50 IePrep::SetHopcount (uint8_t hopcount)
51 {
52  m_hopcount = hopcount;
53 }
54 void
55 IePrep::SetTtl (uint8_t ttl)
56 {
57  m_ttl = ttl;
58 }
59 void
60 IePrep::SetDestinationSeqNumber (uint32_t destSeqNumber)
61 {
62  m_destSeqNumber = destSeqNumber;
63 }
64 void
66 {
67  m_destinationAddress = destAddress;
68 }
69 void
70 IePrep::SetMetric (uint32_t metric)
71 {
72  m_metric = metric;
73 }
74 void
76 {
77  m_originatorAddress = originatorAddress;
78 }
79 void
80 IePrep::SetOriginatorSeqNumber (uint32_t originatorSeqNumber)
81 {
82  m_originatorSeqNumber = originatorSeqNumber;
83 }
84 void
85 IePrep::SetLifetime (uint32_t lifetime)
86 {
87  m_lifetime = lifetime;
88 }
89 uint8_t
91 {
92  return m_flags;
93 }
94 uint8_t
96 {
97  return m_hopcount;
98 }
99 uint32_t
101 {
102  return m_ttl;
103 }
104 uint32_t
106 {
107  return m_destSeqNumber;
108 }
111 {
112  return m_destinationAddress;
113 }
114 uint32_t
116 {
117  return m_metric;
118 }
121 {
122  return m_originatorAddress;
123 }
124 uint32_t
126 {
127  return m_originatorSeqNumber;
128 }
129 uint32_t
131 {
132  return m_lifetime;
133 }
134 void
136 {
137  m_ttl--;
138  m_hopcount++;
139 }
140 
141 void
142 IePrep::IncrementMetric (uint32_t metric)
143 {
144  m_metric += metric;
145 }
146 
147 void
149 {
150  i.WriteU8 (m_flags);
151  i.WriteU8 (m_hopcount);
152  i.WriteU8 (m_ttl);
159 }
160 uint8_t
162 {
164  m_flags = i.ReadU8 ();
165  m_hopcount = i.ReadU8 ();
166  m_ttl = i.ReadU8 ();
169  m_lifetime = i.ReadLsbtohU32 ();
170  m_metric = i.ReadLsbtohU32 ();
173  return i.GetDistanceFrom (start);
174 }
175 uint8_t
177 {
178  uint32_t retval = 1 //Flags
179  + 1 //Hopcount
180  + 1 //Ttl
181  + 6 //Dest address
182  + 4 //Dest seqno
183  + 4 //Lifetime
184  + 4 //metric
185  + 6 //Originator address
186  + 4; //Originator seqno
187  return retval;
188 }
189 void
190 IePrep::Print (std::ostream& os) const
191 {
192  os << "PREP=(Flags=" << m_flags << ", Hopcount=" << m_hopcount << ", TTL=" << m_ttl
193  << ",Destination=" << m_destinationAddress << ", Dest. seqnum=" << m_destSeqNumber
194  << ", Lifetime=" << m_lifetime << ", Metric=" << m_metric << ", Originator="
195  << m_originatorAddress << ", Orig. seqnum=" << m_originatorSeqNumber << ")";
196 }
197 bool
198 operator== (const IePrep & a, const IePrep & b)
199 {
200  return ((a.m_flags == b.m_flags) && (a.m_hopcount == b.m_hopcount) && (a.m_ttl == b.m_ttl)
202  && (a.m_lifetime == b.m_lifetime) && (a.m_metric == b.m_metric) && (a.m_originatorAddress
204 }
205 std::ostream &
206 operator << (std::ostream &os, const IePrep &a)
207 {
208  a.Print (os);
209  return os;
210 }
211 } // namespace dot11s
212 } // namespace ns3
213 
ns3::dot11s::IePrep::GetMetric
uint32_t GetMetric() const
Get metric function.
Definition: ie-dot11s-prep.cc:115
ns3::dot11s::IePrep::GetTtl
uint32_t GetTtl() const
Get TTL function.
Definition: ie-dot11s-prep.cc:100
ns3::dot11s::IePrep::DecrementTtl
void DecrementTtl()
Decrement TTL function.
Definition: ie-dot11s-prep.cc:135
ns3::dot11s::IePrep::GetDestinationSeqNumber
uint32_t GetDestinationSeqNumber() const
Get destination sequence number function.
Definition: ie-dot11s-prep.cc:105
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition: dot11s-mac-header.cc:172
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
ns3::dot11s::IePrep::m_metric
uint32_t m_metric
metric
Definition: ie-dot11s-prep.h:152
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition: buffer.h:1021
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition: buffer.h:869
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::dot11s::IePrep::ElementId
virtual WifiInformationElementId ElementId() const
Definition: ie-dot11s-prep.cc:40
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Definition: wifi-information-element.h:40
ns3::dot11s::IePrep::SetOriginatorAddress
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address function.
Definition: ie-dot11s-prep.cc:75
ns3::dot11s::IePrep::GetInformationFieldSize
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-prep.cc:176
visualizer.core.start
def start()
Definition: core.py:1855
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:918
ns3::dot11s::IePrep::~IePrep
~IePrep()
Definition: ie-dot11s-prep.cc:30
ns3::dot11s::IePrep::m_originatorSeqNumber
uint32_t m_originatorSeqNumber
originator sequence number
Definition: ie-dot11s-prep.h:154
ns3::dot11s::IePrep::m_ttl
uint8_t m_ttl
TTL.
Definition: ie-dot11s-prep.h:148
ns3::dot11s::IePrep::GetFlags
uint8_t GetFlags() const
Get flags function.
Definition: ie-dot11s-prep.cc:90
ns3::dot11s::IePrep::DeserializeInformationField
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)
Definition: ie-dot11s-prep.cc:161
ns3::dot11s::IePrep::Print
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
Definition: ie-dot11s-prep.cc:190
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1077
ns3::dot11s::IePrep::SetDestinationAddress
void SetDestinationAddress(Mac48Address dest_address)
Set destination address function.
Definition: ie-dot11s-prep.cc:65
ns3::dot11s::IePrep::SetDestinationSeqNumber
void SetDestinationSeqNumber(uint32_t dest_seq_number)
Set destination sequence number function.
Definition: ie-dot11s-prep.cc:60
ns3::dot11s::IePrep::SetOriginatorSeqNumber
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number function.
Definition: ie-dot11s-prep.cc:80
ns3::dot11s::IePrep::m_destinationAddress
Mac48Address m_destinationAddress
destination address
Definition: ie-dot11s-prep.h:149
ns3::dot11s::IePrep::IncrementMetric
void IncrementMetric(uint32_t metric)
Increment metric function.
Definition: ie-dot11s-prep.cc:142
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::dot11s::IePrep::m_flags
uint8_t m_flags
flags
Definition: ie-dot11s-prep.h:146
ns3::dot11s::IePrep::SetFlags
void SetFlags(uint8_t flags)
Set flags function.
Definition: ie-dot11s-prep.cc:45
ns3::dot11s::IePrep::m_lifetime
uint32_t m_lifetime
lifetime
Definition: ie-dot11s-prep.h:151
ns3::dot11s::IePrep::SetHopcount
void SetHopcount(uint8_t hopcount)
Set hop count function.
Definition: ie-dot11s-prep.cc:50
ns3::dot11s::IePrep::GetOriginatorSeqNumber
uint32_t GetOriginatorSeqNumber() const
Get originator sequence number.
Definition: ie-dot11s-prep.cc:125
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition: address-utils.cc:28
IE_PREP
#define IE_PREP
Definition: wifi-information-element.h:165
ns3::dot11s::IePrep::m_originatorAddress
Mac48Address m_originatorAddress
originator address
Definition: ie-dot11s-prep.h:153
ns3::dot11s::IePrep::SetLifetime
void SetLifetime(uint32_t lifetime)
Set lifetime function.
Definition: ie-dot11s-prep.cc:85
ns3::dot11s::IePrep::GetOriginatorAddress
Mac48Address GetOriginatorAddress() const
Get originator address function.
Definition: ie-dot11s-prep.cc:120
ns3::dot11s::IePrep
See 7.3.2.97 of 802.11s draft 2.07.
Definition: ie-dot11s-prep.h:34
ns3::dot11s::IePrep::SerializeInformationField
virtual void SerializeInformationField(Buffer::Iterator i) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition: ie-dot11s-prep.cc:148
ns3::dot11s::IePrep::GetLifetime
uint32_t GetLifetime() const
Get lifetime function.
Definition: ie-dot11s-prep.cc:130
ns3::dot11s::IePrep::SetMetric
void SetMetric(uint32_t metric)
Set metric function.
Definition: ie-dot11s-prep.cc:70
ns3::dot11s::IePrep::m_destSeqNumber
uint32_t m_destSeqNumber
destination sequence number
Definition: ie-dot11s-prep.h:150
ns3::dot11s::IePrep::SetTtl
void SetTtl(uint8_t ttl)
Set TTL function.
Definition: ie-dot11s-prep.cc:55
ns3::dot11s::operator<<
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Definition: ie-dot11s-beacon-timing.cc:215
ns3::dot11s::IePrep::GetDestinationAddress
Mac48Address GetDestinationAddress() const
Get destination address function.
Definition: ie-dot11s-prep.cc:110
ns3::dot11s::IePrep::m_hopcount
uint8_t m_hopcount
hop count
Definition: ie-dot11s-prep.h:147
ie-dot11s-prep.h
ns3::dot11s::IePrep::GetHopcount
uint8_t GetHopcount() const
Get hop count function.
Definition: ie-dot11s-prep.cc:95
ns3::dot11s::IePrep::IePrep
IePrep()
Definition: ie-dot11s-prep.cc:33
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition: address-utils.cc:70