A Discrete-Event Network Simulator
API
ie-dot11s-rann.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-rann.h"
22 #include "ns3/assert.h"
23 #include "ns3/address-utils.h"
24 #include "ns3/packet.h"
25 
26 namespace ns3 {
27 namespace dot11s {
28 
30 {
31 }
33  m_flags (0), m_hopcount (0), m_ttl (0), m_originatorAddress (Mac48Address::GetBroadcast ()),
34  m_destSeqNumber (0), m_metric (0)
35 {
36 }
39 {
40  return IE_RANN;
41 }
42 
43 void
44 IeRann::SetFlags (uint8_t flags)
45 {
46  m_flags = flags;
47 }
48 void
49 IeRann::SetHopcount (uint8_t hopcount)
50 {
51  m_hopcount = hopcount;
52 }
53 void
54 IeRann::SetTTL (uint8_t ttl)
55 {
56  m_ttl = ttl;
57 }
58 void
59 IeRann::SetDestSeqNumber (uint32_t dest_seq_number)
60 {
61  m_destSeqNumber = dest_seq_number;
62 }
63 void
64 IeRann::SetMetric (uint32_t metric)
65 {
66  m_metric = metric;
67 }
68 void
70 {
71  m_originatorAddress = originator_address;
72 }
73 
74 uint8_t
76 {
77  return m_flags;
78 }
79 uint8_t
81 {
82  return m_hopcount;
83 }
84 uint8_t
86 {
87  return m_ttl;
88 }
89 uint32_t
91 {
92  return m_destSeqNumber;
93 }
94 uint32_t
96 {
97  return m_metric;
98 }
99 void
101 {
102  m_ttl--;
103  m_hopcount++;
104 }
105 
106 void
108 {
109  m_metric += m;
110 }
111 
114 {
115  return m_originatorAddress;
116 }
117 void
119 {
120  i.WriteU8 (m_flags);
121  i.WriteU8 (m_hopcount);
122  i.WriteU8 (m_ttl);
126 }
127 uint8_t
129 {
131  m_flags = i.ReadU8 ();
132  m_hopcount = i.ReadU8 ();
133  m_ttl = i.ReadU8 ();
136  m_metric = i.ReadLsbtohU32 ();
137  return i.GetDistanceFrom (start);
138 }
139 uint8_t
141 {
142  uint8_t retval = 1 //Flags
143  + 1 //Hopcount
144  + 1 //TTL
145  + 6 //OriginatorAddress
146  + 4 //DestSeqNumber
147  + 4; //Metric
148  return retval;
149 }
150 
151 void
152 IeRann::Print (std::ostream &os) const
153 {
154  os << "RANN=(flags=" << (int) m_flags
155  << ", hop count=" << (int) m_hopcount
156  << ", TTL=" << (int) m_ttl
157  << ", originator address=" << m_originatorAddress
158  << ", dst seq. number=" << m_destSeqNumber
159  << ", metric=" << m_metric
160  << ")";
161 }
162 
163 bool
164 operator== (const IeRann & a, const IeRann & b)
165 {
166  return (a.m_flags == b.m_flags && a.m_hopcount == b.m_hopcount && a.m_ttl == b.m_ttl
168  && a.m_metric == b.m_metric);
169 }
170 std::ostream &
171 operator << (std::ostream &os, const IeRann &a)
172 {
173  a.Print (os);
174  return os;
175 }
176 }
177 } // namespace ns3::dot11s
178 
179 
Mac48Address m_originatorAddress
originator address
void IncrementMetric(uint32_t metric)
Increment metric.
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address value.
uint8_t GetTtl()
Get TTL value.
uint8_t GetFlags()
Get flags value.
void SetDestSeqNumber(uint32_t dest_seq_number)
Set destination sequence number value.
void SetFlags(uint8_t flags)
Set flags field.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1844
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t m_flags
flags
bool operator==(const MeshHeader &a, const MeshHeader &b)
iterator in a Buffer instance
Definition: buffer.h:98
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:783
uint8_t GetHopcount()
Get hop count value.
Root announcement (RANN) element.
uint32_t m_metric
metric
uint32_t GetMetric()
Get metric value.
#define IE_RANN
void DecrementTtl()
Decrement TTL function.
Mac48Address GetOriginatorAddress()
Get originator address value.
void SetTTL(uint8_t ttl)
Set TTL value to the remaining number of hops allowed.
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
void SetHopcount(uint8_t hopcount)
Set hop count value to number of hops from the originating root mesh STA to the mesh STA transmitting...
uint32_t m_destSeqNumber
destination sequence number
uint8_t m_hopcount
hop count
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
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) ...
void SetMetric(uint32_t metric)
Set metric value to cumulative metric from originating root mesh STA to the mesh STA transmitting the...
virtual WifiInformationElementId ElementId() const
void WriteU8(uint8_t data)
Definition: buffer.h:869
virtual void SerializeInformationField(Buffer::Iterator i) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
uint32_t GetDestSeqNumber()
Get destination sequence number value.
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1076
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:917
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...