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"
25namespace ns3 {
26namespace 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}
44void
45IePrep::SetFlags (uint8_t flags)
46{
47 m_flags = flags;
48}
49void
50IePrep::SetHopcount (uint8_t hopcount)
51{
52 m_hopcount = hopcount;
53}
54void
55IePrep::SetTtl (uint8_t ttl)
56{
57 m_ttl = ttl;
58}
59void
61{
62 m_destSeqNumber = destSeqNumber;
63}
64void
66{
67 m_destinationAddress = destAddress;
68}
69void
71{
72 m_metric = metric;
73}
74void
76{
77 m_originatorAddress = originatorAddress;
78}
79void
81{
82 m_originatorSeqNumber = originatorSeqNumber;
83}
84void
86{
87 m_lifetime = lifetime;
88}
89uint8_t
91{
92 return m_flags;
93}
94uint8_t
96{
97 return m_hopcount;
98}
101{
102 return m_ttl;
103}
106{
107 return m_destSeqNumber;
108}
111{
113}
116{
117 return m_metric;
118}
121{
122 return m_originatorAddress;
123}
126{
128}
131{
132 return m_lifetime;
133}
134void
136{
137 m_ttl--;
138 m_hopcount++;
139}
140
141void
143{
144 m_metric += metric;
145}
146
147void
149{
150 i.WriteU8 (m_flags);
152 i.WriteU8 (m_ttl);
159}
160uint16_t
162{
164 m_flags = i.ReadU8 ();
165 m_hopcount = i.ReadU8 ();
166 m_ttl = i.ReadU8 ();
170 m_metric = i.ReadLsbtohU32 ();
173 return i.GetDistanceFrom (start);
174}
175uint16_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}
189void
190IePrep::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}
197bool
198operator== (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}
205std::ostream &
206operator << (std::ostream &os, const IePrep &a)
207{
208 a.Print (os);
209 return os;
210}
211} // namespace dot11s
212} // namespace ns3
213
iterator in a Buffer instance
Definition: buffer.h:99
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1077
void WriteU8(uint8_t data)
Definition: buffer.h:869
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:918
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
an EUI-48 address
Definition: mac48-address.h:44
See 7.3.2.97 of 802.11s draft 2.07.
uint32_t GetMetric() const
Get metric function.
uint8_t m_flags
flags
void SetTtl(uint8_t ttl)
Set TTL function.
uint32_t m_lifetime
lifetime
void SetDestinationSeqNumber(uint32_t dest_seq_number)
Set destination sequence number function.
virtual uint16_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
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 m_destSeqNumber
destination sequence number
uint8_t GetFlags() const
Get flags function.
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
virtual WifiInformationElementId ElementId() const
Get the wifi information element ID.
Mac48Address GetDestinationAddress() const
Get destination address function.
void SetFlags(uint8_t flags)
Set flags function.
virtual uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
void SetHopcount(uint8_t hopcount)
Set hop count function.
uint8_t m_hopcount
hop count
uint32_t m_originatorSeqNumber
originator sequence number
void IncrementMetric(uint32_t metric)
Increment metric function.
uint32_t GetLifetime() const
Get lifetime function.
uint32_t GetOriginatorSeqNumber() const
Get originator sequence number.
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address function.
void SetMetric(uint32_t metric)
Set metric function.
void SetDestinationAddress(Mac48Address dest_address)
Set destination address function.
uint32_t m_metric
metric
void SetLifetime(uint32_t lifetime)
Set lifetime function.
Mac48Address GetOriginatorAddress() const
Get originator address function.
uint32_t GetTtl() const
Get TTL function.
void DecrementTtl()
Decrement TTL function.
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number function.
Mac48Address m_originatorAddress
originator address
uint32_t GetDestinationSeqNumber() const
Get destination sequence number function.
Mac48Address m_destinationAddress
destination address
uint8_t GetHopcount() const
Get hop count function.
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.
def start()
Definition: core.py:1852
#define IE_PREP