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