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
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::Dot11sMacHeader"
)
35
.
SetParent
<
Header
> ()
36
.AddConstructor<MeshHeader> ();
37
return
tid;
38
}
39
MeshHeader::MeshHeader
() :
40
m_meshFlags (0), m_meshTtl (0), m_meshSeqno (0), m_addr4 (
Mac48Address
()), m_addr5 (
Mac48Address
()),
41
m_addr6 (
Mac48Address
())
42
{
43
}
44
MeshHeader::~MeshHeader
()
45
{
46
}
47
TypeId
48
MeshHeader::GetInstanceTypeId
()
const
49
{
50
return
GetTypeId
();
51
}
52
void
53
MeshHeader::SetAddr4
(
Mac48Address
address
)
54
{
55
m_addr4
=
address
;
56
}
57
void
58
MeshHeader::SetAddr5
(
Mac48Address
address
)
59
{
60
m_addr5
=
address
;
61
}
62
void
63
MeshHeader::SetAddr6
(
Mac48Address
address
)
64
{
65
m_addr6
=
address
;
66
}
67
Mac48Address
68
MeshHeader::GetAddr4
()
const
69
{
70
return
m_addr4
;
71
}
72
Mac48Address
73
MeshHeader::GetAddr5
()
const
74
{
75
return
m_addr5
;
76
}
77
Mac48Address
78
MeshHeader::GetAddr6
()
const
79
{
80
return
m_addr6
;
81
}
82
void
83
MeshHeader::SetMeshSeqno
(uint32_t seqno)
84
{
85
m_meshSeqno
= seqno;
86
}
87
uint32_t
88
MeshHeader::GetMeshSeqno
()
const
89
{
90
return
m_meshSeqno
;
91
}
92
void
93
MeshHeader::SetMeshTtl
(uint8_t TTL)
94
{
95
m_meshTtl
= TTL;
96
}
97
uint8_t
98
MeshHeader::GetMeshTtl
()
const
99
{
100
return
m_meshTtl
;
101
}
102
void
103
MeshHeader::SetAddressExt
(uint8_t num_of_addresses)
104
{
105
NS_ASSERT
(num_of_addresses <= 3);
106
m_meshFlags
|= 0x03 & num_of_addresses;
107
}
108
uint8_t
109
MeshHeader::GetAddressExt
()
const
110
{
111
return
(0x03 &
m_meshFlags
);
112
}
113
uint32_t
114
MeshHeader::GetSerializedSize
()
const
115
{
116
return
6 +
GetAddressExt
() * 6;
117
}
118
void
119
MeshHeader::Serialize
(
Buffer::Iterator
start
)
const
120
{
121
Buffer::Iterator
i =
start
;
122
i.
WriteU8
(
m_meshFlags
);
123
i.
WriteU8
(
m_meshTtl
);
124
i.
WriteHtolsbU32
(
m_meshSeqno
);
125
uint8_t addresses_to_add =
GetAddressExt
();
126
//Writing Address extensions:
127
if
((addresses_to_add == 1) || (addresses_to_add == 3))
128
{
129
WriteTo
(i,
m_addr4
);
130
}
131
if
(addresses_to_add > 1)
132
{
133
WriteTo
(i,
m_addr5
);
134
}
135
if
(addresses_to_add > 1)
136
{
137
WriteTo
(i,
m_addr6
);
138
}
139
}
140
uint32_t
141
MeshHeader::Deserialize
(
Buffer::Iterator
start
)
142
{
143
Buffer::Iterator
i =
start
;
144
uint8_t addresses_to_read = 0;
145
m_meshFlags
= i.
ReadU8
();
146
m_meshTtl
= i.
ReadU8
();
147
m_meshSeqno
= i.
ReadLsbtohU32
();
148
addresses_to_read =
m_meshFlags
& 0x03;
149
if
((addresses_to_read == 1) || (addresses_to_read == 3))
150
{
151
ReadFrom
(i,
m_addr4
);
152
}
153
if
(addresses_to_read > 1)
154
{
155
ReadFrom
(i,
m_addr5
);
156
}
157
if
(addresses_to_read > 1)
158
{
159
ReadFrom
(i,
m_addr6
);
160
}
161
return
i.
GetDistanceFrom
(start);
162
}
163
void
164
MeshHeader::Print
(std::ostream &os)
const
165
{
166
os <<
"flags = "
<< (uint16_t)
m_meshFlags
<< std::endl <<
"ttl = "
<< (uint16_t)
m_meshTtl
167
<< std::endl <<
"seqno = "
<<
m_meshSeqno
<< std::endl<<
"addr4 = "
<<
m_addr4
<< std::endl
168
<<
"addr5 = "
<<
m_addr5
<< std::endl <<
"addr6 = "
<<
m_addr6
<< std::endl;
169
}
170
bool
171
operator==
(
const
MeshHeader
& a,
const
MeshHeader
& b)
172
{
173
return
((a.
m_meshFlags
== b.
m_meshFlags
) && (a.
m_meshTtl
== b.
m_meshTtl
)
174
&& (a.
m_meshSeqno
== b.
m_meshSeqno
) && (a.
m_addr4
== b.
m_addr4
) && (a.
m_addr5
== b.
m_addr5
)
175
&& (a.
m_addr6
== b.
m_addr6
));
176
}
177
}
// namespace dot11s
178
}
// namespace ns3
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::dot11s::MeshHeader::GetMeshTtl
uint8_t GetMeshTtl() const
Definition:
dot11s-mac-header.cc:98
ns3::dot11s::MeshHeader::m_addr4
Mac48Address m_addr4
Definition:
dot11s-mac-header.h:69
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition:
address-utils.cc:70
ns3::dot11s::MeshHeader::MeshHeader
MeshHeader()
Definition:
dot11s-mac-header.cc:39
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition:
address-utils.cc:28
ns3::dot11s::MeshHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
dot11s-mac-header.cc:141
ns3::dot11s::MeshHeader::m_addr5
Mac48Address m_addr5
Definition:
dot11s-mac-header.h:70
visualizer.core.start
def start
Definition:
core.py:1482
ns3::dot11s::MeshHeader::SetMeshSeqno
void SetMeshSeqno(uint32_t seqno)
Definition:
dot11s-mac-header.cc:83
ns3::dot11s::MeshHeader::Print
virtual void Print(std::ostream &os) const
Definition:
dot11s-mac-header.cc:164
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition:
dot11s-mac-header.cc:171
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:807
ns3::dot11s::MeshHeader::SetAddressExt
void SetAddressExt(uint8_t num_of_addresses)
Definition:
dot11s-mac-header.cc:103
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::dot11s::MeshHeader::SetMeshTtl
void SetMeshTtl(uint8_t TTL)
Definition:
dot11s-mac-header.cc:93
ns3::dot11s::MeshHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
dot11s-mac-header.cc:119
ns3::dot11s::MeshHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId() const
Definition:
dot11s-mac-header.cc:48
ns3::dot11s::MeshHeader::GetAddr5
Mac48Address GetAddr5() const
Definition:
dot11s-mac-header.cc:73
ns3::dot11s::MeshHeader::GetAddr4
Mac48Address GetAddr4() const
Definition:
dot11s-mac-header.cc:68
ns3::dot11s::MeshHeader::SetAddr6
void SetAddr6(Mac48Address address)
Definition:
dot11s-mac-header.cc:63
ns3::dot11s::MeshHeader::GetAddressExt
uint8_t GetAddressExt() const
Definition:
dot11s-mac-header.cc:109
ns3::dot11s::MeshHeader::SetAddr4
void SetAddr4(Mac48Address address)
Definition:
dot11s-mac-header.cc:53
ns3::dot11s::MeshHeader::GetTypeId
static TypeId GetTypeId()
Definition:
dot11s-mac-header.cc:32
ns3::dot11s::MeshHeader::m_meshTtl
uint8_t m_meshTtl
Definition:
dot11s-mac-header.h:67
ns3::dot11s::MeshHeader::SetAddr5
void SetAddr5(Mac48Address address)
Definition:
dot11s-mac-header.cc:58
ns3::dot11s::MeshHeader::m_addr6
Mac48Address m_addr6
Definition:
dot11s-mac-header.h:71
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:41
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:690
ns3::dot11s::MeshHeader::GetSerializedSize
virtual uint32_t GetSerializedSize() const
Definition:
dot11s-mac-header.cc:114
ns3::dot11s::MeshHeader::~MeshHeader
~MeshHeader()
Definition:
dot11s-mac-header.cc:44
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:819
ns3::dot11s::MeshHeader
Mesh Control field, see IEEE 802.11s draft 3.0 section 7.1.3.5b.
Definition:
dot11s-mac-header.h:37
ns3::dot11s::MeshHeader::GetMeshSeqno
uint32_t GetMeshSeqno() const
Definition:
dot11s-mac-header.cc:88
first.address
tuple address
Definition:
first.py:37
ns3::dot11s::MeshHeader::m_meshSeqno
uint32_t m_meshSeqno
Definition:
dot11s-mac-header.h:68
ns3::dot11s::MeshHeader::GetAddr6
Mac48Address GetAddr6() const
Definition:
dot11s-mac-header.cc:78
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32(void)
Definition:
buffer.cc:1101
ns3::dot11s::MeshHeader::m_meshFlags
uint8_t m_meshFlags
Definition:
dot11s-mac-header.h:66
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition:
buffer.cc:942
dot11s-mac-header.h
src
mesh
model
dot11s
dot11s-mac-header.cc
Generated on Sat Apr 19 2014 14:07:03 for ns-3 by
1.8.6