A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
hwmp-tag.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#include "hwmp-tag.h"
10
11namespace ns3
12{
13namespace dot11s
14{
15
17
18// Class HwmpTag:
20 : m_address(Mac48Address::GetBroadcast()),
21 m_ttl(0),
22 m_metric(0),
23 m_seqno(0)
24{
25}
26
30
31void
33{
34 m_address = retransmitter;
35}
36
39{
40 return m_address;
41}
42
43void
44HwmpTag::SetTtl(uint8_t ttl)
45{
46 m_ttl = ttl;
47}
48
49uint8_t
51{
52 return m_ttl;
53}
54
55void
57{
58 m_metric = metric;
59}
60
63{
64 return m_metric;
65}
66
67void
69{
70 m_seqno = seqno;
71}
72
75{
76 return m_seqno;
77}
78
79/**
80 * @brief Get the type ID.
81 * @return the object TypeId
82 */
85{
86 static TypeId tid = TypeId("ns3::dot11s::HwmpTag")
87 .SetParent<Tag>()
88 .SetGroupName("Mesh")
89 .AddConstructor<HwmpTag>();
90 return tid;
91}
92
95{
96 return GetTypeId();
97}
98
101{
102 return 6 // address
103 + 1 // ttl
104 + 4 // metric
105 + 4; // seqno
106}
107
108void
110{
111 uint8_t address[6];
112 int j;
113 m_address.CopyTo(address);
114 i.WriteU8(m_ttl);
116 i.WriteU32(m_seqno);
117 for (j = 0; j < 6; j++)
118 {
119 i.WriteU8(address[j]);
120 }
121}
122
123void
125{
126 uint8_t address[6];
127 int j;
128 m_ttl = i.ReadU8();
129 m_metric = i.ReadU32();
130 m_seqno = i.ReadU32();
131 for (j = 0; j < 6; j++)
132 {
133 address[j] = i.ReadU8();
134 }
135 m_address.CopyFrom(address);
136}
137
138void
139HwmpTag::Print(std::ostream& os) const
140{
141 os << "address=" << m_address;
142 os << "ttl=" << m_ttl;
143 os << "metrc=" << m_metric;
144 os << "seqno=" << m_seqno;
145}
146
147void
149{
150 m_ttl--;
151}
152} // namespace dot11s
153} // namespace ns3
an EUI-48 address
void CopyFrom(const uint8_t buffer[6])
void CopyTo(uint8_t buffer[6]) const
read and write tag data
Definition tag-buffer.h:41
TAG_BUFFER_INLINE uint32_t ReadU32()
Definition tag-buffer.h:206
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition tag-buffer.h:161
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition tag-buffer.h:185
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition tag-buffer.h:176
tag a set of bytes in a packet
Definition tag.h:28
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
Definition hwmp-tag.h:40
void SetTtl(uint8_t ttl)
Set the TTL value.
Definition hwmp-tag.cc:44
uint32_t GetSeqno() const
Get the sequence number.
Definition hwmp-tag.cc:74
void SetMetric(uint32_t metric)
Set the metric value.
Definition hwmp-tag.cc:56
void SetSeqno(uint32_t seqno)
Set sequence number.
Definition hwmp-tag.cc:68
uint8_t GetTtl() const
Get the TTL value.
Definition hwmp-tag.cc:50
Mac48Address GetAddress()
Get address from tag.
Definition hwmp-tag.cc:38
~HwmpTag() override
Definition hwmp-tag.cc:27
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition hwmp-tag.cc:94
static TypeId GetTypeId()
Get the type ID.
Definition hwmp-tag.cc:84
void Serialize(TagBuffer i) const override
Definition hwmp-tag.cc:109
Mac48Address m_address
address
Definition hwmp-tag.h:99
uint8_t m_ttl
TTL.
Definition hwmp-tag.h:100
void Deserialize(TagBuffer i) override
Definition hwmp-tag.cc:124
uint32_t m_metric
metric
Definition hwmp-tag.h:101
uint32_t GetSerializedSize() const override
Definition hwmp-tag.cc:100
void Print(std::ostream &os) const override
Definition hwmp-tag.cc:139
void SetAddress(Mac48Address retransmitter)
Set address.
Definition hwmp-tag.cc:32
uint32_t m_seqno
sequence no
Definition hwmp-tag.h:102
uint32_t GetMetric() const
Get the metric value.
Definition hwmp-tag.cc:62
void DecrementTtl()
Decrement TTL.
Definition hwmp-tag.cc:148
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.