A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
hwmp-tag.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008,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
* Authors: Kirill Andreev <andreev@iitp.ru>
18
*/
19
20
#include "
hwmp-tag.h
"
21
22
namespace
ns3
23
{
24
namespace
dot11s
25
{
26
27
NS_OBJECT_ENSURE_REGISTERED
(HwmpTag);
28
29
// Class HwmpTag:
30
HwmpTag::HwmpTag
()
31
: m_address(
Mac48Address
::GetBroadcast()),
32
m_ttl(0),
33
m_metric(0),
34
m_seqno(0)
35
{
36
}
37
38
HwmpTag::~HwmpTag
()
39
{
40
}
41
42
void
43
HwmpTag::SetAddress
(
Mac48Address
retransmitter)
44
{
45
m_address
= retransmitter;
46
}
47
48
Mac48Address
49
HwmpTag::GetAddress
()
50
{
51
return
m_address
;
52
}
53
54
void
55
HwmpTag::SetTtl
(uint8_t ttl)
56
{
57
m_ttl
= ttl;
58
}
59
60
uint8_t
61
HwmpTag::GetTtl
()
const
62
{
63
return
m_ttl
;
64
}
65
66
void
67
HwmpTag::SetMetric
(uint32_t metric)
68
{
69
m_metric
= metric;
70
}
71
72
uint32_t
73
HwmpTag::GetMetric
()
const
74
{
75
return
m_metric
;
76
}
77
78
void
79
HwmpTag::SetSeqno
(uint32_t seqno)
80
{
81
m_seqno
= seqno;
82
}
83
84
uint32_t
85
HwmpTag::GetSeqno
()
const
86
{
87
return
m_seqno
;
88
}
89
94
TypeId
95
HwmpTag::GetTypeId
()
96
{
97
static
TypeId
tid =
TypeId
(
"ns3::dot11s::HwmpTag"
)
98
.
SetParent
<
Tag
>()
99
.SetGroupName(
"Mesh"
)
100
.AddConstructor<
HwmpTag
>();
101
return
tid;
102
}
103
104
TypeId
105
HwmpTag::GetInstanceTypeId
()
const
106
{
107
return
GetTypeId
();
108
}
109
110
uint32_t
111
HwmpTag::GetSerializedSize
()
const
112
{
113
return
6
// address
114
+ 1
// ttl
115
+ 4
// metric
116
+ 4;
// seqno
117
}
118
119
void
120
HwmpTag::Serialize
(
TagBuffer
i)
const
121
{
122
uint8_t
address
[6];
123
int
j;
124
m_address
.
CopyTo
(
address
);
125
i.
WriteU8
(
m_ttl
);
126
i.
WriteU32
(
m_metric
);
127
i.
WriteU32
(
m_seqno
);
128
for
(j = 0; j < 6; j++)
129
{
130
i.
WriteU8
(
address
[j]);
131
}
132
}
133
134
void
135
HwmpTag::Deserialize
(
TagBuffer
i)
136
{
137
uint8_t
address
[6];
138
int
j;
139
m_ttl
= i.
ReadU8
();
140
m_metric
= i.
ReadU32
();
141
m_seqno
= i.
ReadU32
();
142
for
(j = 0; j < 6; j++)
143
{
144
address
[j] = i.
ReadU8
();
145
}
146
m_address
.
CopyFrom
(
address
);
147
}
148
149
void
150
HwmpTag::Print
(std::ostream& os)
const
151
{
152
os <<
"address="
<<
m_address
;
153
os <<
"ttl="
<<
m_ttl
;
154
os <<
"metrc="
<<
m_metric
;
155
os <<
"seqno="
<<
m_seqno
;
156
}
157
158
void
159
HwmpTag::DecrementTtl
()
160
{
161
m_ttl
--;
162
}
163
}
// namespace dot11s
164
}
// namespace ns3
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:46
ns3::Mac48Address::CopyFrom
void CopyFrom(const uint8_t buffer[6])
Definition:
mac48-address.cc:62
ns3::Mac48Address::CopyTo
void CopyTo(uint8_t buffer[6]) const
Definition:
mac48-address.cc:69
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::TagBuffer::ReadU32
TAG_BUFFER_INLINE uint32_t ReadU32()
Definition:
tag-buffer.h:217
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:172
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition:
tag-buffer.h:196
ns3::TagBuffer::WriteU32
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition:
tag-buffer.h:187
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:39
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::HwmpTag
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
Definition:
hwmp-tag.h:51
ns3::dot11s::HwmpTag::SetTtl
void SetTtl(uint8_t ttl)
Set the TTL value.
Definition:
hwmp-tag.cc:55
ns3::dot11s::HwmpTag::GetSeqno
uint32_t GetSeqno() const
Get the sequence number.
Definition:
hwmp-tag.cc:85
ns3::dot11s::HwmpTag::SetMetric
void SetMetric(uint32_t metric)
Set the metric value.
Definition:
hwmp-tag.cc:67
ns3::dot11s::HwmpTag::SetSeqno
void SetSeqno(uint32_t seqno)
Set sequence number.
Definition:
hwmp-tag.cc:79
ns3::dot11s::HwmpTag::GetTtl
uint8_t GetTtl() const
Get the TTL value.
Definition:
hwmp-tag.cc:61
ns3::dot11s::HwmpTag::GetAddress
Mac48Address GetAddress()
Get address from tag.
Definition:
hwmp-tag.cc:49
ns3::dot11s::HwmpTag::~HwmpTag
~HwmpTag() override
Definition:
hwmp-tag.cc:38
ns3::dot11s::HwmpTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
hwmp-tag.cc:105
ns3::dot11s::HwmpTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
hwmp-tag.cc:95
ns3::dot11s::HwmpTag::Serialize
void Serialize(TagBuffer i) const override
Definition:
hwmp-tag.cc:120
ns3::dot11s::HwmpTag::m_address
Mac48Address m_address
address
Definition:
hwmp-tag.h:110
ns3::dot11s::HwmpTag::m_ttl
uint8_t m_ttl
TTL.
Definition:
hwmp-tag.h:111
ns3::dot11s::HwmpTag::Deserialize
void Deserialize(TagBuffer i) override
Definition:
hwmp-tag.cc:135
ns3::dot11s::HwmpTag::m_metric
uint32_t m_metric
metric
Definition:
hwmp-tag.h:112
ns3::dot11s::HwmpTag::HwmpTag
HwmpTag()
Definition:
hwmp-tag.cc:30
ns3::dot11s::HwmpTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
hwmp-tag.cc:111
ns3::dot11s::HwmpTag::Print
void Print(std::ostream &os) const override
Definition:
hwmp-tag.cc:150
ns3::dot11s::HwmpTag::SetAddress
void SetAddress(Mac48Address retransmitter)
Set address.
Definition:
hwmp-tag.cc:43
ns3::dot11s::HwmpTag::m_seqno
uint32_t m_seqno
sequence no
Definition:
hwmp-tag.h:113
ns3::dot11s::HwmpTag::GetMetric
uint32_t GetMetric() const
Get the metric value.
Definition:
hwmp-tag.cc:73
ns3::dot11s::HwmpTag::DecrementTtl
void DecrementTtl()
Decrement TTL.
Definition:
hwmp-tag.cc:159
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
hwmp-tag.h
first.address
address
Definition:
first.py:47
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mesh
model
dot11s
hwmp-tag.cc
Generated on Sun Mar 3 2024 17:11:04 for ns-3 by
1.9.1