A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-rann.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#include "ie-dot11s-rann.h"
21
22#include "ns3/address-utils.h"
23#include "ns3/assert.h"
24#include "ns3/packet.h"
25
26namespace ns3
27{
28namespace dot11s
29{
30
32{
33}
34
36 : m_flags(0),
37 m_hopcount(0),
38 m_ttl(0),
39 m_originatorAddress(Mac48Address::GetBroadcast()),
40 m_destSeqNumber(0),
41 m_metric(0)
42{
43}
44
47{
48 return IE_RANN;
49}
50
51void
52IeRann::SetFlags(uint8_t flags)
53{
54 m_flags = flags;
55}
56
57void
58IeRann::SetHopcount(uint8_t hopcount)
59{
60 m_hopcount = hopcount;
61}
62
63void
64IeRann::SetTTL(uint8_t ttl)
65{
66 m_ttl = ttl;
67}
68
69void
71{
72 m_destSeqNumber = dest_seq_number;
73}
74
75void
77{
78 m_metric = metric;
79}
80
81void
83{
84 m_originatorAddress = originator_address;
85}
86
87uint8_t
89{
90 return m_flags;
91}
92
93uint8_t
95{
96 return m_hopcount;
97}
98
99uint8_t
101{
102 return m_ttl;
103}
104
107{
108 return m_destSeqNumber;
109}
110
113{
114 return m_metric;
115}
116
117void
119{
120 m_ttl--;
121 m_hopcount++;
122}
123
124void
126{
127 m_metric += m;
128}
129
132{
133 return m_originatorAddress;
134}
135
136void
138{
139 i.WriteU8(m_flags);
141 i.WriteU8(m_ttl);
145}
146
147uint16_t
149{
150 Buffer::Iterator i = start;
151 m_flags = i.ReadU8();
152 m_hopcount = i.ReadU8();
153 m_ttl = i.ReadU8();
157 return i.GetDistanceFrom(start);
158}
159
160uint16_t
162{
163 uint16_t retval = 1 // Flags
164 + 1 // Hopcount
165 + 1 // TTL
166 + 6 // OriginatorAddress
167 + 4 // DestSeqNumber
168 + 4; // Metric
169 return retval;
170}
171
172void
173IeRann::Print(std::ostream& os) const
174{
175 os << "RANN=(flags=" << (int)m_flags << ", hop count=" << (int)m_hopcount
176 << ", TTL=" << (int)m_ttl << ", originator address=" << m_originatorAddress
177 << ", dst seq. number=" << m_destSeqNumber << ", metric=" << m_metric << ")";
178}
179
180bool
181operator==(const IeRann& a, const IeRann& b)
182{
183 return (a.m_flags == b.m_flags && a.m_hopcount == b.m_hopcount && a.m_ttl == b.m_ttl &&
186}
187
188std::ostream&
189operator<<(std::ostream& os, const IeRann& a)
190{
191 a.Print(os);
192 return os;
193}
194} // namespace dot11s
195} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:910
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1076
an EUI-48 address
Definition: mac48-address.h:46
Root announcement (RANN) element.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
void SetMetric(uint32_t metric)
Set metric value to cumulative metric from originating root mesh STA to the mesh STA transmitting the...
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint8_t m_flags
flags
Mac48Address m_originatorAddress
originator address
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
uint8_t GetFlags() const
Get flags value.
void SetTTL(uint8_t ttl)
Set TTL value to the remaining number of hops allowed.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint8_t GetTtl() const
Get TTL value.
void IncrementMetric(uint32_t metric)
Increment metric.
uint8_t m_hopcount
hop count
uint32_t GetDestSeqNumber() const
Get destination sequence number value.
uint32_t m_destSeqNumber
destination sequence number
uint32_t GetMetric() const
Get metric value.
void DecrementTtl()
Decrement TTL function.
void SetHopcount(uint8_t hopcount)
Set hop count value to number of hops from the originating root mesh STA to the mesh STA transmitting...
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address value.
uint8_t GetHopcount() const
Get hop count value.
void SetDestSeqNumber(uint32_t dest_seq_number)
Set destination sequence number value.
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint32_t m_metric
metric
void SetFlags(uint8_t flags)
Set flags field.
Mac48Address GetOriginatorAddress()
Get originator address value.
bool operator==(const MeshHeader &a, const MeshHeader &b)
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
#define IE_RANN