A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
dot11s-mac-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Kirill Andreev <andreev@iitp.ru>
18
*/
19
20
#include "
dot11s-mac-header.h
"
21
22
#include "ns3/address-utils.h"
23
#include "ns3/assert.h"
24
#include "ns3/packet.h"
25
26
namespace
ns3
27
{
28
namespace
dot11s
29
{
30
/***********************************************************
31
* Here Mesh Mac Header functionality is defined.
32
***********************************************************/
33
TypeId
34
MeshHeader::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::dot11s::MeshHeader"
)
37
.
SetParent
<
Header
>()
38
.SetGroupName(
"Mesh"
)
39
.AddConstructor<
MeshHeader
>();
40
return
tid;
41
}
42
43
MeshHeader::MeshHeader
()
44
: m_meshFlags(0),
45
m_meshTtl(0),
46
m_meshSeqno(0),
47
m_addr4(
Mac48Address
()),
48
m_addr5(
Mac48Address
()),
49
m_addr6(
Mac48Address
())
50
{
51
}
52
53
MeshHeader::~MeshHeader
()
54
{
55
}
56
57
TypeId
58
MeshHeader::GetInstanceTypeId
()
const
59
{
60
return
GetTypeId
();
61
}
62
63
void
64
MeshHeader::SetAddr4
(
Mac48Address
address
)
65
{
66
m_addr4
=
address
;
67
}
68
69
void
70
MeshHeader::SetAddr5
(
Mac48Address
address
)
71
{
72
m_addr5
=
address
;
73
}
74
75
void
76
MeshHeader::SetAddr6
(
Mac48Address
address
)
77
{
78
m_addr6
=
address
;
79
}
80
81
Mac48Address
82
MeshHeader::GetAddr4
()
const
83
{
84
return
m_addr4
;
85
}
86
87
Mac48Address
88
MeshHeader::GetAddr5
()
const
89
{
90
return
m_addr5
;
91
}
92
93
Mac48Address
94
MeshHeader::GetAddr6
()
const
95
{
96
return
m_addr6
;
97
}
98
99
void
100
MeshHeader::SetMeshSeqno
(uint32_t seqno)
101
{
102
m_meshSeqno
= seqno;
103
}
104
105
uint32_t
106
MeshHeader::GetMeshSeqno
()
const
107
{
108
return
m_meshSeqno
;
109
}
110
111
void
112
MeshHeader::SetMeshTtl
(uint8_t TTL)
113
{
114
m_meshTtl
= TTL;
115
}
116
117
uint8_t
118
MeshHeader::GetMeshTtl
()
const
119
{
120
return
m_meshTtl
;
121
}
122
123
void
124
MeshHeader::SetAddressExt
(uint8_t value)
125
{
126
NS_ASSERT
(value <= 3);
127
m_meshFlags
|= 0x03 & value;
128
}
129
130
uint8_t
131
MeshHeader::GetAddressExt
()
const
132
{
133
return
(0x03 &
m_meshFlags
);
134
}
135
136
uint32_t
137
MeshHeader::GetSerializedSize
()
const
138
{
139
return
6 +
GetAddressExt
() * 6;
140
}
141
142
void
143
MeshHeader::Serialize
(
Buffer::Iterator
start
)
const
144
{
145
Buffer::Iterator
i =
start
;
146
i.
WriteU8
(
m_meshFlags
);
147
i.
WriteU8
(
m_meshTtl
);
148
i.
WriteHtolsbU32
(
m_meshSeqno
);
149
uint8_t addresses_to_add =
GetAddressExt
();
150
// Writing Address extensions:
151
if
((addresses_to_add == 1) || (addresses_to_add == 3))
152
{
153
WriteTo
(i,
m_addr4
);
154
}
155
if
(addresses_to_add > 1)
156
{
157
WriteTo
(i,
m_addr5
);
158
}
159
if
(addresses_to_add > 1)
160
{
161
WriteTo
(i,
m_addr6
);
162
}
163
}
164
165
uint32_t
166
MeshHeader::Deserialize
(
Buffer::Iterator
start
)
167
{
168
Buffer::Iterator
i =
start
;
169
uint8_t addresses_to_read = 0;
170
m_meshFlags
= i.
ReadU8
();
171
m_meshTtl
= i.
ReadU8
();
172
m_meshSeqno
= i.
ReadLsbtohU32
();
173
addresses_to_read =
m_meshFlags
& 0x03;
174
if
((addresses_to_read == 1) || (addresses_to_read == 3))
175
{
176
ReadFrom
(i,
m_addr4
);
177
}
178
if
(addresses_to_read > 1)
179
{
180
ReadFrom
(i,
m_addr5
);
181
}
182
if
(addresses_to_read > 1)
183
{
184
ReadFrom
(i,
m_addr6
);
185
}
186
return
i.
GetDistanceFrom
(
start
);
187
}
188
189
void
190
MeshHeader::Print
(std::ostream& os)
const
191
{
192
os <<
"flags="
<< (uint16_t)
m_meshFlags
<<
", ttl="
<< (uint16_t)
m_meshTtl
193
<<
", seqno="
<<
m_meshSeqno
<<
", addr4="
<<
m_addr4
<<
", addr5="
<<
m_addr5
194
<<
", addr6="
<<
m_addr6
;
195
}
196
197
bool
198
operator==
(
const
MeshHeader
& a,
const
MeshHeader
& b)
199
{
200
return
((a.
m_meshFlags
== b.
m_meshFlags
) && (a.
m_meshTtl
== b.
m_meshTtl
) &&
201
(a.
m_meshSeqno
== b.
m_meshSeqno
) && (a.
m_addr4
== b.
m_addr4
) &&
202
(a.
m_addr5
== b.
m_addr5
) && (a.
m_addr6
== b.
m_addr6
));
203
}
204
}
// namespace dot11s
205
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition:
buffer.h:1027
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:881
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition:
buffer.cc:910
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(const Iterator &o) const
Definition:
buffer.cc:780
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32()
Definition:
buffer.cc:1076
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:46
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
ns3::dot11s::MeshHeader
Mesh Control field, see Section 8.2.4.7.3 IEEE 802.11-2012.
Definition:
dot11s-mac-header.h:38
ns3::dot11s::MeshHeader::MeshHeader
MeshHeader()
Definition:
dot11s-mac-header.cc:43
ns3::dot11s::MeshHeader::SetAddr6
void SetAddr6(Mac48Address address)
Set extended address 6.
Definition:
dot11s-mac-header.cc:76
ns3::dot11s::MeshHeader::SetMeshSeqno
void SetMeshSeqno(uint32_t seqno)
Set four-byte mesh sequence number.
Definition:
dot11s-mac-header.cc:100
ns3::dot11s::MeshHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
dot11s-mac-header.cc:143
ns3::dot11s::MeshHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
dot11s-mac-header.cc:58
ns3::dot11s::MeshHeader::m_addr6
Mac48Address m_addr6
MAC address 6.
Definition:
dot11s-mac-header.h:126
ns3::dot11s::MeshHeader::GetMeshSeqno
uint32_t GetMeshSeqno() const
Get the four-byte mesh sequence number.
Definition:
dot11s-mac-header.cc:106
ns3::dot11s::MeshHeader::~MeshHeader
~MeshHeader() override
Definition:
dot11s-mac-header.cc:53
ns3::dot11s::MeshHeader::SetMeshTtl
void SetMeshTtl(uint8_t TTL)
Set mesh TTL subfield corresponding to the remaining number of hops the MSDU/MMPDU is forwarded.
Definition:
dot11s-mac-header.cc:112
ns3::dot11s::MeshHeader::m_addr4
Mac48Address m_addr4
MAC address 4.
Definition:
dot11s-mac-header.h:124
ns3::dot11s::MeshHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
dot11s-mac-header.cc:34
ns3::dot11s::MeshHeader::Print
void Print(std::ostream &os) const override
Definition:
dot11s-mac-header.cc:190
ns3::dot11s::MeshHeader::GetAddr5
Mac48Address GetAddr5() const
Get extended address 5.
Definition:
dot11s-mac-header.cc:88
ns3::dot11s::MeshHeader::GetAddr4
Mac48Address GetAddr4() const
Get extended address 4.
Definition:
dot11s-mac-header.cc:82
ns3::dot11s::MeshHeader::m_meshFlags
uint8_t m_meshFlags
mesh flags
Definition:
dot11s-mac-header.h:121
ns3::dot11s::MeshHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
dot11s-mac-header.cc:137
ns3::dot11s::MeshHeader::GetAddr6
Mac48Address GetAddr6() const
Get extended address 6.
Definition:
dot11s-mac-header.cc:94
ns3::dot11s::MeshHeader::GetAddressExt
uint8_t GetAddressExt() const
Get Address Extension Mode.
Definition:
dot11s-mac-header.cc:131
ns3::dot11s::MeshHeader::SetAddressExt
void SetAddressExt(uint8_t num_of_addresses)
Set Address Extension Mode.
Definition:
dot11s-mac-header.cc:124
ns3::dot11s::MeshHeader::SetAddr5
void SetAddr5(Mac48Address address)
Set extended address 5.
Definition:
dot11s-mac-header.cc:70
ns3::dot11s::MeshHeader::SetAddr4
void SetAddr4(Mac48Address address)
Set extended address 4.
Definition:
dot11s-mac-header.cc:64
ns3::dot11s::MeshHeader::m_meshTtl
uint8_t m_meshTtl
mesh TTL
Definition:
dot11s-mac-header.h:122
ns3::dot11s::MeshHeader::GetMeshTtl
uint8_t GetMeshTtl() const
Get mesh TTL function subfield value.
Definition:
dot11s-mac-header.cc:118
ns3::dot11s::MeshHeader::m_addr5
Mac48Address m_addr5
MAC address 5.
Definition:
dot11s-mac-header.h:125
ns3::dot11s::MeshHeader::m_meshSeqno
uint32_t m_meshSeqno
mesh sequence no
Definition:
dot11s-mac-header.h:123
dot11s-mac-header.h
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
first.address
address
Definition:
first.py:47
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition:
dot11s-mac-header.cc:198
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition:
address-utils.cc:31
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition:
address-utils.cc:84
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
src
mesh
model
dot11s
dot11s-mac-header.cc
Generated on Sun Mar 3 2024 17:11:04 for ns-3 by
1.9.1