A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
mesh
model
dot11s
dot11s-mac-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 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 "ns3/assert.h"
22
#include "ns3/address-utils.h"
23
#include "
dot11s-mac-header.h
"
24
#include "ns3/packet.h"
25
26
namespace
ns3
{
27
namespace
dot11s {
28
/***********************************************************
29
* Here Mesh Mac Header functionality is defined.
30
***********************************************************/
31
TypeId
32
MeshHeader::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::dot11s::MeshHeader"
)
35
.
SetParent
<
Header
> ()
36
.SetGroupName (
"Mesh"
)
37
.AddConstructor<
MeshHeader
> ();
38
return
tid;
39
}
40
MeshHeader::MeshHeader
() :
41
m_meshFlags (0), m_meshTtl (0), m_meshSeqno (0), m_addr4 (
Mac48Address
()), m_addr5 (
Mac48Address
()),
42
m_addr6 (
Mac48Address
())
43
{
44
}
45
MeshHeader::~MeshHeader
()
46
{
47
}
48
TypeId
49
MeshHeader::GetInstanceTypeId
()
const
50
{
51
return
GetTypeId
();
52
}
53
void
54
MeshHeader::SetAddr4
(
Mac48Address
address
)
55
{
56
m_addr4
=
address
;
57
}
58
void
59
MeshHeader::SetAddr5
(
Mac48Address
address
)
60
{
61
m_addr5
=
address
;
62
}
63
void
64
MeshHeader::SetAddr6
(
Mac48Address
address
)
65
{
66
m_addr6
=
address
;
67
}
68
Mac48Address
69
MeshHeader::GetAddr4
()
const
70
{
71
return
m_addr4
;
72
}
73
Mac48Address
74
MeshHeader::GetAddr5
()
const
75
{
76
return
m_addr5
;
77
}
78
Mac48Address
79
MeshHeader::GetAddr6
()
const
80
{
81
return
m_addr6
;
82
}
83
void
84
MeshHeader::SetMeshSeqno
(uint32_t seqno)
85
{
86
m_meshSeqno
= seqno;
87
}
88
uint32_t
89
MeshHeader::GetMeshSeqno
()
const
90
{
91
return
m_meshSeqno
;
92
}
93
void
94
MeshHeader::SetMeshTtl
(uint8_t TTL)
95
{
96
m_meshTtl
= TTL;
97
}
98
uint8_t
99
MeshHeader::GetMeshTtl
()
const
100
{
101
return
m_meshTtl
;
102
}
103
void
104
MeshHeader::SetAddressExt
(uint8_t value)
105
{
106
NS_ASSERT
(value <= 3);
107
m_meshFlags
|= 0x03 & value;
108
}
109
uint8_t
110
MeshHeader::GetAddressExt
()
const
111
{
112
return
(0x03 &
m_meshFlags
);
113
}
114
uint32_t
115
MeshHeader::GetSerializedSize
()
const
116
{
117
return
6 +
GetAddressExt
() * 6;
118
}
119
void
120
MeshHeader::Serialize
(
Buffer::Iterator
start
)
const
121
{
122
Buffer::Iterator
i =
start
;
123
i.
WriteU8
(
m_meshFlags
);
124
i.
WriteU8
(
m_meshTtl
);
125
i.
WriteHtolsbU32
(
m_meshSeqno
);
126
uint8_t addresses_to_add =
GetAddressExt
();
127
//Writing Address extensions:
128
if
((addresses_to_add == 1) || (addresses_to_add == 3))
129
{
130
WriteTo
(i,
m_addr4
);
131
}
132
if
(addresses_to_add > 1)
133
{
134
WriteTo
(i,
m_addr5
);
135
}
136
if
(addresses_to_add > 1)
137
{
138
WriteTo
(i,
m_addr6
);
139
}
140
}
141
uint32_t
142
MeshHeader::Deserialize
(
Buffer::Iterator
start
)
143
{
144
Buffer::Iterator
i =
start
;
145
uint8_t addresses_to_read = 0;
146
m_meshFlags
= i.
ReadU8
();
147
m_meshTtl
= i.
ReadU8
();
148
m_meshSeqno
= i.
ReadLsbtohU32
();
149
addresses_to_read =
m_meshFlags
& 0x03;
150
if
((addresses_to_read == 1) || (addresses_to_read == 3))
151
{
152
ReadFrom
(i,
m_addr4
);
153
}
154
if
(addresses_to_read > 1)
155
{
156
ReadFrom
(i,
m_addr5
);
157
}
158
if
(addresses_to_read > 1)
159
{
160
ReadFrom
(i,
m_addr6
);
161
}
162
return
i.
GetDistanceFrom
(
start
);
163
}
164
void
165
MeshHeader::Print
(std::ostream &os)
const
166
{
167
os <<
"flags="
<< (uint16_t)
m_meshFlags
<<
", ttl="
<< (uint16_t)
m_meshTtl
168
<<
", seqno="
<<
m_meshSeqno
<<
", addr4="
<<
m_addr4
169
<<
", addr5="
<<
m_addr5
<<
", addr6="
<<
m_addr6
;
170
}
171
bool
172
operator==
(
const
MeshHeader
& a,
const
MeshHeader
& b)
173
{
174
return
((a.
m_meshFlags
== b.
m_meshFlags
) && (a.
m_meshTtl
== b.
m_meshTtl
)
175
&& (a.
m_meshSeqno
== b.
m_meshSeqno
) && (a.
m_addr4
== b.
m_addr4
) && (a.
m_addr5
== b.
m_addr5
)
176
&& (a.
m_addr6
== b.
m_addr6
));
177
}
178
}
// namespace dot11s
179
}
// namespace ns3
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::dot11s::MeshHeader::GetAddr6
Mac48Address GetAddr6() const
Get extended address 6.
Definition:
dot11s-mac-header.cc:79
ns3::dot11s::MeshHeader::m_addr4
Mac48Address m_addr4
MAC address 4.
Definition:
dot11s-mac-header.h:123
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition:
address-utils.cc:70
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::dot11s::MeshHeader::MeshHeader
MeshHeader()
Definition:
dot11s-mac-header.cc:40
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:67
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition:
address-utils.cc:28
ns3::dot11s::MeshHeader::GetMeshSeqno
uint32_t GetMeshSeqno() const
Get the four-byte mesh sequence number.
Definition:
dot11s-mac-header.cc:89
ns3::dot11s::MeshHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
dot11s-mac-header.cc:142
ns3::dot11s::MeshHeader::m_addr5
Mac48Address m_addr5
MAC address 5.
Definition:
dot11s-mac-header.h:124
ns3::dot11s::MeshHeader::SetMeshSeqno
void SetMeshSeqno(uint32_t seqno)
Set four-byte mesh sequence number.
Definition:
dot11s-mac-header.cc:84
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition:
dot11s-mac-header.cc:172
ns3::dot11s::MeshHeader::SetAddressExt
void SetAddressExt(uint8_t num_of_addresses)
Set Address Extension Mode.
Definition:
dot11s-mac-header.cc:104
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::dot11s::MeshHeader::GetAddressExt
uint8_t GetAddressExt() const
Get Address Extension Mode.
Definition:
dot11s-mac-header.cc:110
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:783
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:94
ns3::dot11s::MeshHeader::GetSerializedSize
virtual uint32_t GetSerializedSize() const
Definition:
dot11s-mac-header.cc:115
ns3::dot11s::MeshHeader::SetAddr6
void SetAddr6(Mac48Address address)
Set extended address 6.
Definition:
dot11s-mac-header.cc:64
ns3::dot11s::MeshHeader::SetAddr4
void SetAddr4(Mac48Address address)
Set extended address 4.
Definition:
dot11s-mac-header.cc:54
ns3::dot11s::MeshHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
dot11s-mac-header.cc:32
ns3::dot11s::MeshHeader::Print
virtual void Print(std::ostream &os) const
Definition:
dot11s-mac-header.cc:165
ns3::dot11s::MeshHeader::GetAddr5
Mac48Address GetAddr5() const
Get extended address 5.
Definition:
dot11s-mac-header.cc:74
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
first.address
address
Definition:
first.py:37
ns3::dot11s::MeshHeader::m_meshTtl
uint8_t m_meshTtl
mesh TTL
Definition:
dot11s-mac-header.h:121
ns3::dot11s::MeshHeader::SetAddr5
void SetAddr5(Mac48Address address)
Set extended address 5.
Definition:
dot11s-mac-header.cc:59
ns3::dot11s::MeshHeader::m_addr6
Mac48Address m_addr6
MAC address 6.
Definition:
dot11s-mac-header.h:125
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:43
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:869
ns3::dot11s::MeshHeader::GetAddr4
Mac48Address GetAddr4() const
Get extended address 4.
Definition:
dot11s-mac-header.cc:69
ns3::dot11s::MeshHeader::~MeshHeader
~MeshHeader()
Definition:
dot11s-mac-header.cc:45
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1021
ns3::dot11s::MeshHeader
Mesh Control field, see Section 8.2.4.7.3 IEEE 802.11-2012.
Definition:
dot11s-mac-header.h:37
ns3::dot11s::MeshHeader::GetMeshTtl
uint8_t GetMeshTtl() const
Get mesh TTL function subfield value.
Definition:
dot11s-mac-header.cc:99
ns3::dot11s::MeshHeader::m_meshSeqno
uint32_t m_meshSeqno
mesh sequence no
Definition:
dot11s-mac-header.h:122
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:915
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32(void)
Definition:
buffer.cc:1076
ns3::dot11s::MeshHeader::m_meshFlags
uint8_t m_meshFlags
mesh flags
Definition:
dot11s-mac-header.h:120
ns3::dot11s::MeshHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
dot11s-mac-header.cc:120
ns3::dot11s::MeshHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Definition:
dot11s-mac-header.cc:49
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition:
buffer.cc:917
dot11s-mac-header.h
Generated on Wed Nov 7 2018 10:02:04 for ns-3 by
1.8.14