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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#include "ie-dot11s-rann.h"
10
11#include "ns3/address-utils.h"
12#include "ns3/assert.h"
13#include "ns3/packet.h"
14
15namespace ns3
16{
17namespace dot11s
18{
19
23
25 : m_flags(0),
26 m_hopcount(0),
27 m_ttl(0),
28 m_originatorAddress(Mac48Address::GetBroadcast()),
29 m_destSeqNumber(0),
30 m_metric(0)
31{
32}
33
36{
37 return IE_RANN;
38}
39
40void
41IeRann::SetFlags(uint8_t flags)
42{
43 m_flags = flags;
44}
45
46void
47IeRann::SetHopcount(uint8_t hopcount)
48{
49 m_hopcount = hopcount;
50}
51
52void
53IeRann::SetTTL(uint8_t ttl)
54{
55 m_ttl = ttl;
56}
57
58void
60{
61 m_destSeqNumber = dest_seq_number;
62}
63
64void
66{
67 m_metric = metric;
68}
69
70void
72{
73 m_originatorAddress = originator_address;
74}
75
76uint8_t
78{
79 return m_flags;
80}
81
82uint8_t
84{
85 return m_hopcount;
86}
87
88uint8_t
90{
91 return m_ttl;
92}
93
96{
97 return m_destSeqNumber;
98}
99
102{
103 return m_metric;
104}
105
106void
108{
109 m_ttl--;
110 m_hopcount++;
111}
112
113void
118
124
125void
135
136uint16_t
138{
139 Buffer::Iterator i = start;
140 m_flags = i.ReadU8();
141 m_hopcount = i.ReadU8();
142 m_ttl = i.ReadU8();
146 return i.GetDistanceFrom(start);
147}
148
149uint16_t
151{
152 uint16_t retval = 1 // Flags
153 + 1 // Hopcount
154 + 1 // TTL
155 + 6 // OriginatorAddress
156 + 4 // DestSeqNumber
157 + 4; // Metric
158 return retval;
159}
160
161void
162IeRann::Print(std::ostream& os) const
163{
164 os << "RANN=(flags=" << (int)m_flags << ", hop count=" << (int)m_hopcount
165 << ", TTL=" << (int)m_ttl << ", originator address=" << m_originatorAddress
166 << ", dst seq. number=" << m_destSeqNumber << ", metric=" << m_metric << ")";
167}
168
169bool
170operator==(const IeRann& a, const IeRann& b)
171{
172 return (a.m_flags == b.m_flags && a.m_hopcount == b.m_hopcount && a.m_ttl == b.m_ttl &&
175}
176
177std::ostream&
178operator<<(std::ostream& os, const IeRann& a)
179{
180 a.Print(os);
181 return os;
182}
183} // namespace dot11s
184} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
void WriteHtolsbU32(uint32_t data)
Definition buffer.cc:899
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
uint32_t ReadLsbtohU32()
Definition buffer.cc:1065
an EUI-48 address
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)
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