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-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
29
IeRann::~IeRann
()
30
{
31
}
32
IeRann::IeRann
() :
33
m_flags (0), m_hopcount (0), m_ttl (0), m_originatorAddress (
Mac48Address
::GetBroadcast ()),
34
m_destSeqNumber (0), m_metric (0)
35
{
36
}
37
WifiInformationElementId
38
IeRann::ElementId
()
const
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
69
IeRann::SetOriginatorAddress
(
Mac48Address
originator_address)
70
{
71
m_originatorAddress
= originator_address;
72
}
73
74
uint8_t
75
IeRann::GetFlags
()
76
{
77
return
m_flags
;
78
}
79
uint8_t
80
IeRann::GetHopcount
()
81
{
82
return
m_hopcount
;
83
}
84
uint8_t
85
IeRann::GetTtl
()
86
{
87
return
m_ttl
;
88
}
89
uint32_t
90
IeRann::GetDestSeqNumber
()
91
{
92
return
m_destSeqNumber
;
93
}
94
uint32_t
95
IeRann::GetMetric
()
96
{
97
return
m_metric
;
98
}
99
void
100
IeRann::DecrementTtl
()
101
{
102
m_ttl
--;
103
m_hopcount
++;
104
}
105
106
void
107
IeRann::IncrementMetric
(uint32_t m)
108
{
109
m_metric
+= m;
110
}
111
112
Mac48Address
113
IeRann::GetOriginatorAddress
()
114
{
115
return
m_originatorAddress
;
116
}
117
void
118
IeRann::SerializeInformationField
(
Buffer::Iterator
i)
const
119
{
120
i.
WriteU8
(
m_flags
);
121
i.
WriteU8
(
m_hopcount
);
122
i.
WriteU8
(
m_ttl
);
123
WriteTo
(i,
m_originatorAddress
);
124
i.
WriteHtolsbU32
(
m_destSeqNumber
);
125
i.
WriteHtolsbU32
(
m_metric
);
126
}
127
uint8_t
128
IeRann::DeserializeInformationField
(
Buffer::Iterator
start
, uint8_t length)
129
{
130
Buffer::Iterator
i =
start
;
131
m_flags
= i.
ReadU8
();
132
m_hopcount
= i.
ReadU8
();
133
m_ttl
= i.
ReadU8
();
134
ReadFrom
(i,
m_originatorAddress
);
135
m_destSeqNumber
= i.
ReadLsbtohU32
();
136
m_metric
= i.
ReadLsbtohU32
();
137
return
i.
GetDistanceFrom
(start);
138
}
139
uint8_t
140
IeRann::GetInformationFieldSize
()
const
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
168
&& a.
m_originatorAddress
== b.
m_originatorAddress
&& a.
m_destSeqNumber
== b.
m_destSeqNumber
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
src
mesh
model
dot11s
ie-dot11s-rann.cc
Generated on Tue May 14 2013 11:08:28 for ns-3 by
1.8.1.2