A Discrete-Event Network Simulator
API
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 
27 
28 //Class HwmpTag:
30  m_address (Mac48Address::GetBroadcast ()), m_ttl (0), m_metric (0), m_seqno (0)
31 {
32 }
33 
35 {
36 }
37 
38 void
40 {
41  m_address = retransmitter;
42 }
43 
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
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
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
82 {
83  return m_seqno;
84 }
85 
86 TypeId
88 {
89  static TypeId tid = TypeId ("ns3::dot11s::HwmpTag")
90  .SetParent<Tag> ()
91  .SetGroupName ("Mesh")
92  .AddConstructor<HwmpTag> ()
93  ;
94  return tid;
95 }
96 
97 TypeId
99 {
100  return GetTypeId ();
101 }
102 
103 uint32_t
105 {
106  return 6 //address
107  + 1 //ttl
108  + 4 //metric
109  + 4; //seqno
110 }
111 
112 void
114 {
115  uint8_t address[6];
116  int j;
117  m_address.CopyTo (address);
118  i.WriteU8 (m_ttl);
119  i.WriteU32 (m_metric);
120  i.WriteU32 (m_seqno);
121  for (j = 0; j < 6; j++)
122  {
123  i.WriteU8 (address[j]);
124  }
125 }
126 
127 void
129 {
130  uint8_t address[6];
131  int j;
132  m_ttl = i.ReadU8 ();
133  m_metric = i.ReadU32 ();
134  m_seqno = i.ReadU32 ();
135  for (j = 0; j < 6; j++)
136  {
137  address[j] = i.ReadU8 ();
138  }
139  m_address.CopyFrom (address);
140 }
141 
142 void
143 HwmpTag::Print (std::ostream &os) const
144 {
145  os << "address=" << m_address;
146  os << "ttl=" << m_ttl;
147  os << "metrc=" << m_metric;
148  os << "seqno=" << m_seqno;
149 }
150 void
152 {
153  m_ttl--;
154 }
155 } // namespace dot11s
156 } // namespace ns3
virtual uint32_t GetSerializedSize() const
Definition: hwmp-tag.cc:104
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
Definition: hwmp-tag.h:48
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Definition: hwmp-tag.cc:98
TAG_BUFFER_INLINE uint32_t ReadU32(void)
Definition: tag-buffer.h:215
static TypeId GetTypeId()
Definition: hwmp-tag.cc:87
uint32_t GetSeqno()
Definition: hwmp-tag.cc:81
void SetTtl(uint8_t ttl)
Definition: hwmp-tag.cc:51
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
void SetAddress(Mac48Address retransmitter)
Definition: hwmp-tag.cc:39
Mac48Address GetAddress()
Definition: hwmp-tag.cc:45
void CopyTo(uint8_t buffer[6]) const
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition: tag-buffer.h:186
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
void SetMetric(uint32_t metric)
Definition: hwmp-tag.cc:63
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
void CopyFrom(const uint8_t buffer[6])
virtual void Print(std::ostream &os) const
Definition: hwmp-tag.cc:143
uint8_t GetTtl()
Definition: hwmp-tag.cc:57
read and write tag data
Definition: tag-buffer.h:51
Mac48Address m_address
Definition: hwmp-tag.h:70
uint32_t GetMetric()
Definition: hwmp-tag.cc:69
virtual void Serialize(TagBuffer i) const
Definition: hwmp-tag.cc:113
uint32_t m_metric
Definition: hwmp-tag.h:72
tuple address
Definition: first.py:37
uint32_t m_seqno
Definition: hwmp-tag.h:73
void SetSeqno(uint32_t seqno)
Definition: hwmp-tag.cc:75
virtual void Deserialize(TagBuffer i)
Definition: hwmp-tag.cc:128
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904