A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ie-dot11s-perr.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-perr.h
"
22
#include "ns3/address-utils.h"
23
#include "ns3/packet.h"
24
namespace
ns3 {
25
namespace
dot11s {
26
IePerr::IePerr
()
27
{
28
}
29
IePerr::~IePerr
()
30
{
31
}
32
WifiInformationElementId
33
IePerr::ElementId
()
const
34
{
35
return
IE11S_PERR
;
36
}
37
void
38
IePerr::Print
(std::ostream &os)
const
39
{
40
os << std::endl <<
"<information_element id="
<<
ElementId
() <<
">"
<< std::endl;
41
os <<
"Number of failed destinations: = "
<<
m_addressUnits
.size ();
42
for
(
unsigned
int
j = 0; j <
m_addressUnits
.size (); j++)
43
{
44
os <<
"Failed destination address: = "
<<
m_addressUnits
[j].destination <<
", sequence number = "
45
<<
m_addressUnits
[j].seqnum;
46
}
47
os << std::endl <<
"</information_element>"
<< std::endl;
48
}
49
uint8_t
50
IePerr::GetNumOfDest
()
const
51
{
52
return
m_addressUnits
.size ();
53
}
54
void
55
IePerr::SerializeInformationField
(
Buffer::Iterator
i)
const
56
{
57
i.
WriteU8
(0);
58
i.
WriteU8
(
m_addressUnits
.size ());
59
for
(
unsigned
int
j = 0; j <
m_addressUnits
.size (); j++)
60
{
61
WriteTo
(i,
m_addressUnits
[j].destination);
62
i.
WriteHtolsbU32
(
m_addressUnits
[j].seqnum);
63
}
64
}
65
uint8_t
66
IePerr::DeserializeInformationField
(
Buffer::Iterator
start
, uint8_t length)
67
{
68
Buffer::Iterator
i =
start
;
69
i.
Next
(1);
//Mode flags is not used now
70
uint8_t numOfDest = i.
ReadU8
();
71
NS_ASSERT
((2 + 10 * numOfDest ) == length);
72
length = 0;
//to avoid compiler warning in optimized builds
73
for
(
unsigned
int
j = 0; j < numOfDest; j++)
74
{
75
HwmpProtocol::FailedDestination
unit;
76
ReadFrom
(i, unit.
destination
);
77
unit.
seqnum
= i.
ReadLsbtohU32
();
78
m_addressUnits
.push_back (unit);
79
}
80
return
i.
GetDistanceFrom
(start);
81
}
82
83
uint8_t
84
IePerr::GetInformationFieldSize
()
const
85
{
86
uint8_t retval = 1
//ModeFlags
87
+ 1
//NumOfDests
88
+ (6 + 4) *
m_addressUnits
.size ();
89
return
retval;
90
}
91
92
void
93
IePerr::AddAddressUnit
(
HwmpProtocol::FailedDestination
unit)
94
{
95
for
(
unsigned
int
i = 0; i <
m_addressUnits
.size (); i++)
96
{
97
if
(
m_addressUnits
[i].destination == unit.
destination
)
98
{
99
return
;
100
}
101
}
102
if
((
m_addressUnits
.size () + 1) * 10 + 2 > 255)
103
{
104
return
;
105
}
106
m_addressUnits
.push_back (unit);
107
}
108
bool
109
IePerr::IsFull
()
const
110
{
111
return
(
GetInformationFieldSize
() + 2
/* ID + LENGTH*/
+ 10
/* Size of Mac48Address + uint32_t (one unit)*/
> 255);
112
}
113
std::vector<HwmpProtocol::FailedDestination>
114
IePerr::GetAddressUnitVector
()
const
115
{
116
return
m_addressUnits
;
117
}
118
void
119
IePerr::DeleteAddressUnit
(
Mac48Address
address
)
120
{
121
for
(std::vector<HwmpProtocol::FailedDestination>::iterator i =
m_addressUnits
.begin (); i
122
!=
m_addressUnits
.end (); i++)
123
{
124
if
(i->destination == address)
125
{
126
m_addressUnits
.erase (i);
127
break
;
128
}
129
}
130
}
131
void
132
IePerr::ResetPerr
()
133
{
134
m_addressUnits
.clear ();
135
}
136
bool
137
operator==
(
const
IePerr
& a,
const
IePerr
& b)
138
{
139
if
(a.
m_addressUnits
.size () != b.
m_addressUnits
.size ())
140
{
141
return
false
;
142
}
143
for
(
unsigned
int
i = 0; i < a.
m_addressUnits
.size (); i++)
144
{
145
if
(a.
m_addressUnits
[i].destination != b.
m_addressUnits
[i].destination)
146
{
147
return
false
;
148
}
149
if
(a.
m_addressUnits
[i].seqnum != b.
m_addressUnits
[i].seqnum)
150
{
151
return
false
;
152
}
153
}
154
return
true
;
155
}
156
std::ostream &
157
operator <<
(std::ostream & os,
const
IePerr
& a)
158
{
159
a.
Print
(os);
160
return
os;
161
}
162
}
// namespace dot11s
163
}
// namespace ns3
164
165
ns3::dot11s::IePerr::m_addressUnits
std::vector< HwmpProtocol::FailedDestination > m_addressUnits
Definition:
ie-dot11s-perr.h:56
ns3::dot11s::IePerr::SerializeInformationField
virtual void SerializeInformationField(Buffer::Iterator i) const
Definition:
ie-dot11s-perr.cc:55
ns3::dot11s::HwmpProtocol::FailedDestination
structure of unreachable destination - address and sequence number
Definition:
hwmp-protocol.h:57
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Definition:
address-utils.cc:70
ns3::dot11s::IePerr::AddAddressUnit
void AddAddressUnit(HwmpProtocol::FailedDestination unit)
Definition:
ie-dot11s-perr.cc:93
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Definition:
address-utils.cc:28
visualizer.core.start
def start
Definition:
core.py:1482
ns3::dot11s::IePerr::DeserializeInformationField
virtual uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Definition:
ie-dot11s-perr.cc:66
ns3::dot11s::IePerr::GetInformationFieldSize
virtual uint8_t GetInformationFieldSize() const
Definition:
ie-dot11s-perr.cc:84
ns3::dot11s::IePerr
See 7.3.2.98 of 802.11s draft 2.07.
Definition:
ie-dot11s-perr.h:34
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition:
dot11s-mac-header.cc:171
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:807
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::dot11s::IePerr::Print
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
Definition:
ie-dot11s-perr.cc:38
ie-dot11s-perr.h
ns3::dot11s::IePerr::GetNumOfDest
uint8_t GetNumOfDest() const
Definition:
ie-dot11s-perr.cc:50
IE11S_PERR
#define IE11S_PERR
Definition:
mesh-information-element.h:52
ns3::Buffer::Iterator::Next
void Next(void)
Definition:
buffer.h:666
ns3::dot11s::IePerr::GetAddressUnitVector
std::vector< HwmpProtocol::FailedDestination > GetAddressUnitVector() const
Definition:
ie-dot11s-perr.cc:114
ns3::dot11s::HwmpProtocol::FailedDestination::seqnum
uint32_t seqnum
Definition:
hwmp-protocol.h:60
ns3::dot11s::IePerr::IePerr
IePerr()
Definition:
ie-dot11s-perr.cc:26
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:41
ns3::dot11s::HwmpProtocol::FailedDestination::destination
Mac48Address destination
Definition:
hwmp-protocol.h:59
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:690
ns3::dot11s::IePerr::~IePerr
~IePerr()
Definition:
ie-dot11s-perr.cc:29
ns3::dot11s::IePerr::ElementId
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
Definition:
ie-dot11s-perr.cc:33
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:819
ns3::dot11s::IePerr::IsFull
bool IsFull() const
Definition:
ie-dot11s-perr.cc:109
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
Definition:
wifi-information-element.h:41
first.address
tuple address
Definition:
first.py:37
ns3::dot11s::IePerr::DeleteAddressUnit
void DeleteAddressUnit(Mac48Address address)
Definition:
ie-dot11s-perr.cc:119
ns3::dot11s::IePerr::ResetPerr
void ResetPerr()
Definition:
ie-dot11s-perr.cc:132
ns3::dot11s::operator<<
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Definition:
ie-dot11s-beacon-timing.cc:216
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32(void)
Definition:
buffer.cc:1101
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition:
buffer.cc:942
src
mesh
model
dot11s
ie-dot11s-perr.cc
Generated on Sun Apr 20 2014 11:14:57 for ns-3 by
1.8.6