A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 IE11S_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 << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
155  os << " flags = " << (int) m_flags << std::endl;
156  os << " hop count = " << (int) m_hopcount << std::endl;
157  os << " TTL = " << (int) m_ttl << std::endl;
158  os << " originator address = " << m_originatorAddress << std::endl;
159  os << " dst seq. number = " << m_destSeqNumber << std::endl;
160  os << " metric = " << m_metric << std::endl;
161  os << "</information_element>" << std::endl;
162 }
163 
164 bool
165 operator== (const IeRann & a, const IeRann & b)
166 {
167  return (a.m_flags == b.m_flags && a.m_hopcount == b.m_hopcount && a.m_ttl == b.m_ttl
169  && a.m_metric == b.m_metric);
170 }
171 std::ostream &
172 operator << (std::ostream &os, const IeRann &a)
173 {
174  a.Print (os);
175  return os;
176 }
177 }
178 } // namespace ns3::dot11s
179 
180 
Mac48Address m_originatorAddress
void IncrementMetric(uint32_t metric)
virtual uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SetOriginatorAddress(Mac48Address originator_address)
void SetDestSeqNumber(uint32_t dest_seq_number)
void SetFlags(uint8_t flags)
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
bool operator==(const MeshHeader &a, const MeshHeader &b)
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:811
iterator in a Buffer instance
Definition: buffer.h:98
See 7.3.2.95 of 802.11s draft 2.07.
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
Mac48Address GetOriginatorAddress()
void SetTTL(uint8_t ttl)
void SetHopcount(uint8_t hopcount)
an EUI-48 address
Definition: mac48-address.h:41
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)
#define IE11S_RANN
void WriteU8(uint8_t data)
Definition: buffer.h:876
uint32_t GetDestSeqNumber()
uint8_t ReadU8(void)
Definition: buffer.h:1028
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
virtual void SerializeInformationField(Buffer::Iterator i) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1105
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:946