A Discrete-Event Network Simulator
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 
28 
29 // Class HwmpTag:
31  : m_address(Mac48Address::GetBroadcast()),
32  m_ttl(0),
33  m_metric(0),
34  m_seqno(0)
35 {
36 }
37 
39 {
40 }
41 
42 void
44 {
45  m_address = retransmitter;
46 }
47 
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
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
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
86 {
87  return m_seqno;
88 }
89 
94 TypeId
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
106 {
107  return GetTypeId();
108 }
109 
110 uint32_t
112 {
113  return 6 // address
114  + 1 // ttl
115  + 4 // metric
116  + 4; // seqno
117 }
118 
119 void
121 {
122  uint8_t address[6];
123  int j;
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
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  }
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
160 {
161  m_ttl--;
162 }
163 } // namespace dot11s
164 } // namespace ns3
an EUI-48 address
Definition: mac48-address.h:46
void CopyFrom(const uint8_t buffer[6])
void CopyTo(uint8_t buffer[6]) const
read and write tag data
Definition: tag-buffer.h:52
TAG_BUFFER_INLINE uint32_t ReadU32()
Definition: tag-buffer.h:217
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition: tag-buffer.h:196
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition: tag-buffer.h:187
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
Definition: hwmp-tag.h:51
void SetTtl(uint8_t ttl)
Set the TTL value.
Definition: hwmp-tag.cc:55
uint32_t GetSeqno() const
Get the sequence number.
Definition: hwmp-tag.cc:85
void SetMetric(uint32_t metric)
Set the metric value.
Definition: hwmp-tag.cc:67
void SetSeqno(uint32_t seqno)
Set sequence number.
Definition: hwmp-tag.cc:79
uint8_t GetTtl() const
Get the TTL value.
Definition: hwmp-tag.cc:61
Mac48Address GetAddress()
Get address from tag.
Definition: hwmp-tag.cc:49
~HwmpTag() override
Definition: hwmp-tag.cc:38
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: hwmp-tag.cc:105
static TypeId GetTypeId()
Get the type ID.
Definition: hwmp-tag.cc:95
void Serialize(TagBuffer i) const override
Definition: hwmp-tag.cc:120
Mac48Address m_address
address
Definition: hwmp-tag.h:110
uint8_t m_ttl
TTL.
Definition: hwmp-tag.h:111
void Deserialize(TagBuffer i) override
Definition: hwmp-tag.cc:135
uint32_t m_metric
metric
Definition: hwmp-tag.h:112
uint32_t GetSerializedSize() const override
Definition: hwmp-tag.cc:111
void Print(std::ostream &os) const override
Definition: hwmp-tag.cc:150
void SetAddress(Mac48Address retransmitter)
Set address.
Definition: hwmp-tag.cc:43
uint32_t m_seqno
sequence no
Definition: hwmp-tag.h:113
uint32_t GetMetric() const
Get the metric value.
Definition: hwmp-tag.cc:73
void DecrementTtl()
Decrement TTL.
Definition: hwmp-tag.cc:159
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.