A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
dot11s-mac-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Kirill Andreev <andreev@iitp.ru>
7
*/
8
9
#include "
dot11s-mac-header.h
"
10
11
#include "ns3/address-utils.h"
12
#include "ns3/assert.h"
13
#include "ns3/packet.h"
14
15
namespace
ns3
16
{
17
namespace
dot11s
18
{
19
/***********************************************************
20
* Here Mesh Mac Header functionality is defined.
21
***********************************************************/
22
TypeId
23
MeshHeader::GetTypeId
()
24
{
25
static
TypeId
tid =
TypeId
(
"ns3::dot11s::MeshHeader"
)
26
.
SetParent
<
Header
>()
27
.SetGroupName(
"Mesh"
)
28
.AddConstructor<
MeshHeader
>();
29
return
tid;
30
}
31
32
MeshHeader::MeshHeader
()
33
: m_meshFlags(0),
34
m_meshTtl(0),
35
m_meshSeqno(0),
36
m_addr4(
Mac48Address
()),
37
m_addr5(
Mac48Address
()),
38
m_addr6(
Mac48Address
())
39
{
40
}
41
42
MeshHeader::~MeshHeader
()
43
{
44
}
45
46
TypeId
47
MeshHeader::GetInstanceTypeId
()
const
48
{
49
return
GetTypeId
();
50
}
51
52
void
53
MeshHeader::SetAddr4
(
Mac48Address
address)
54
{
55
m_addr4
= address;
56
}
57
58
void
59
MeshHeader::SetAddr5
(
Mac48Address
address)
60
{
61
m_addr5
= address;
62
}
63
64
void
65
MeshHeader::SetAddr6
(
Mac48Address
address)
66
{
67
m_addr6
= address;
68
}
69
70
Mac48Address
71
MeshHeader::GetAddr4
()
const
72
{
73
return
m_addr4
;
74
}
75
76
Mac48Address
77
MeshHeader::GetAddr5
()
const
78
{
79
return
m_addr5
;
80
}
81
82
Mac48Address
83
MeshHeader::GetAddr6
()
const
84
{
85
return
m_addr6
;
86
}
87
88
void
89
MeshHeader::SetMeshSeqno
(
uint32_t
seqno)
90
{
91
m_meshSeqno
= seqno;
92
}
93
94
uint32_t
95
MeshHeader::GetMeshSeqno
()
const
96
{
97
return
m_meshSeqno
;
98
}
99
100
void
101
MeshHeader::SetMeshTtl
(uint8_t TTL)
102
{
103
m_meshTtl
= TTL;
104
}
105
106
uint8_t
107
MeshHeader::GetMeshTtl
()
const
108
{
109
return
m_meshTtl
;
110
}
111
112
void
113
MeshHeader::SetAddressExt
(uint8_t value)
114
{
115
NS_ASSERT
(value <= 3);
116
m_meshFlags
|= 0x03 & value;
117
}
118
119
uint8_t
120
MeshHeader::GetAddressExt
()
const
121
{
122
return
(0x03 &
m_meshFlags
);
123
}
124
125
uint32_t
126
MeshHeader::GetSerializedSize
()
const
127
{
128
return
6 +
GetAddressExt
() * 6;
129
}
130
131
void
132
MeshHeader::Serialize
(
Buffer::Iterator
start)
const
133
{
134
Buffer::Iterator
i = start;
135
i.
WriteU8
(
m_meshFlags
);
136
i.
WriteU8
(
m_meshTtl
);
137
i.
WriteHtolsbU32
(
m_meshSeqno
);
138
uint8_t addresses_to_add =
GetAddressExt
();
139
// Writing Address extensions:
140
if
((addresses_to_add == 1) || (addresses_to_add == 3))
141
{
142
WriteTo
(i,
m_addr4
);
143
}
144
if
(addresses_to_add > 1)
145
{
146
WriteTo
(i,
m_addr5
);
147
}
148
if
(addresses_to_add > 1)
149
{
150
WriteTo
(i,
m_addr6
);
151
}
152
}
153
154
uint32_t
155
MeshHeader::Deserialize
(
Buffer::Iterator
start)
156
{
157
Buffer::Iterator
i = start;
158
uint8_t addresses_to_read = 0;
159
m_meshFlags
= i.
ReadU8
();
160
m_meshTtl
= i.
ReadU8
();
161
m_meshSeqno
= i.
ReadLsbtohU32
();
162
addresses_to_read =
m_meshFlags
& 0x03;
163
if
((addresses_to_read == 1) || (addresses_to_read == 3))
164
{
165
ReadFrom
(i,
m_addr4
);
166
}
167
if
(addresses_to_read > 1)
168
{
169
ReadFrom
(i,
m_addr5
);
170
}
171
if
(addresses_to_read > 1)
172
{
173
ReadFrom
(i,
m_addr6
);
174
}
175
return
i.
GetDistanceFrom
(start);
176
}
177
178
void
179
MeshHeader::Print
(std::ostream& os)
const
180
{
181
os <<
"flags="
<< (uint16_t)
m_meshFlags
<<
", ttl="
<< (uint16_t)
m_meshTtl
182
<<
", seqno="
<<
m_meshSeqno
<<
", addr4="
<<
m_addr4
<<
", addr5="
<<
m_addr5
183
<<
", addr6="
<<
m_addr6
;
184
}
185
186
bool
187
operator==
(
const
MeshHeader
& a,
const
MeshHeader
& b)
188
{
189
return
((a.
m_meshFlags
== b.
m_meshFlags
) && (a.
m_meshTtl
== b.
m_meshTtl
) &&
190
(a.
m_meshSeqno
== b.
m_meshSeqno
) && (a.
m_addr4
== b.
m_addr4
) &&
191
(a.
m_addr5
== b.
m_addr5
) && (a.
m_addr6
== b.
m_addr6
));
192
}
193
}
// namespace dot11s
194
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition
buffer.cc:899
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(const Iterator &o) const
Definition
buffer.cc:769
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32()
Definition
buffer.cc:1065
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::dot11s::MeshHeader
Mesh Control field, see Section 8.2.4.7.3 IEEE 802.11-2012.
Definition
dot11s-mac-header.h:27
ns3::dot11s::MeshHeader::MeshHeader
MeshHeader()
Definition
dot11s-mac-header.cc:32
ns3::dot11s::MeshHeader::SetAddr6
void SetAddr6(Mac48Address address)
Set extended address 6.
Definition
dot11s-mac-header.cc:65
ns3::dot11s::MeshHeader::SetMeshSeqno
void SetMeshSeqno(uint32_t seqno)
Set four-byte mesh sequence number.
Definition
dot11s-mac-header.cc:89
ns3::dot11s::MeshHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
dot11s-mac-header.cc:132
ns3::dot11s::MeshHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
dot11s-mac-header.cc:47
ns3::dot11s::MeshHeader::m_addr6
Mac48Address m_addr6
MAC address 6.
Definition
dot11s-mac-header.h:115
ns3::dot11s::MeshHeader::GetMeshSeqno
uint32_t GetMeshSeqno() const
Get the four-byte mesh sequence number.
Definition
dot11s-mac-header.cc:95
ns3::dot11s::MeshHeader::~MeshHeader
~MeshHeader() override
Definition
dot11s-mac-header.cc:42
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:101
ns3::dot11s::MeshHeader::m_addr4
Mac48Address m_addr4
MAC address 4.
Definition
dot11s-mac-header.h:113
ns3::dot11s::MeshHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
dot11s-mac-header.cc:155
ns3::dot11s::MeshHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
dot11s-mac-header.cc:23
ns3::dot11s::MeshHeader::Print
void Print(std::ostream &os) const override
Definition
dot11s-mac-header.cc:179
ns3::dot11s::MeshHeader::GetAddr5
Mac48Address GetAddr5() const
Get extended address 5.
Definition
dot11s-mac-header.cc:77
ns3::dot11s::MeshHeader::GetAddr4
Mac48Address GetAddr4() const
Get extended address 4.
Definition
dot11s-mac-header.cc:71
ns3::dot11s::MeshHeader::m_meshFlags
uint8_t m_meshFlags
mesh flags
Definition
dot11s-mac-header.h:110
ns3::dot11s::MeshHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
dot11s-mac-header.cc:126
ns3::dot11s::MeshHeader::GetAddr6
Mac48Address GetAddr6() const
Get extended address 6.
Definition
dot11s-mac-header.cc:83
ns3::dot11s::MeshHeader::GetAddressExt
uint8_t GetAddressExt() const
Get Address Extension Mode.
Definition
dot11s-mac-header.cc:120
ns3::dot11s::MeshHeader::SetAddressExt
void SetAddressExt(uint8_t num_of_addresses)
Set Address Extension Mode.
Definition
dot11s-mac-header.cc:113
ns3::dot11s::MeshHeader::SetAddr5
void SetAddr5(Mac48Address address)
Set extended address 5.
Definition
dot11s-mac-header.cc:59
ns3::dot11s::MeshHeader::SetAddr4
void SetAddr4(Mac48Address address)
Set extended address 4.
Definition
dot11s-mac-header.cc:53
ns3::dot11s::MeshHeader::m_meshTtl
uint8_t m_meshTtl
mesh TTL
Definition
dot11s-mac-header.h:111
ns3::dot11s::MeshHeader::GetMeshTtl
uint8_t GetMeshTtl() const
Get mesh TTL function subfield value.
Definition
dot11s-mac-header.cc:107
ns3::dot11s::MeshHeader::m_addr5
Mac48Address m_addr5
MAC address 5.
Definition
dot11s-mac-header.h:114
ns3::dot11s::MeshHeader::m_meshSeqno
uint32_t m_meshSeqno
mesh sequence no
Definition
dot11s-mac-header.h:112
uint32_t
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:55
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition
dot11s-mac-header.cc:187
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:21
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition
address-utils.cc:74
src
mesh
model
dot11s
dot11s-mac-header.cc
Generated on Tue Dec 3 2024 18:20:49 for ns-3 by
1.11.0