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
src
mesh
model
dot11s
ie-dot11s-perr.cc
Generated on Fri Dec 21 2012 19:00:41 for ns-3 by
1.8.1.2