satellite-mac-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
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  * Author: Sami Rantanen <sami.rantanen@magister.fi>
19  * Bastien Tauran <bastien.tauran@viveris.fr>
20  */
21 
22 #include "satellite-mac-tag.h"
23 
24 #include <ns3/log.h>
25 
26 #include <ostream>
27 
28 NS_LOG_COMPONENT_DEFINE("SatMacTag");
29 
30 namespace ns3
31 {
32 
33 NS_OBJECT_ENSURE_REGISTERED(SatMacTag);
34 
36 {
37  NS_LOG_FUNCTION(this);
38 }
39 
41 {
42  NS_LOG_FUNCTION(this);
43 }
44 
45 TypeId
47 {
48  static TypeId tid = TypeId("ns3::SatMacTag").SetParent<Tag>().AddConstructor<SatMacTag>();
49  return tid;
50 }
51 
52 TypeId
54 {
55  NS_LOG_FUNCTION(this);
56 
57  return GetTypeId();
58 }
59 
60 void
61 SatMacTag::SetDestAddress(Mac48Address dest)
62 {
63  NS_LOG_FUNCTION(this << dest);
64  m_destAddress = dest;
65 }
66 
67 Mac48Address
69 {
70  NS_LOG_FUNCTION(this);
71  return m_destAddress;
72 }
73 
74 void
75 SatMacTag::SetSourceAddress(Mac48Address source)
76 {
77  NS_LOG_FUNCTION(this << source);
78  m_sourceAddress = source;
79 }
80 
81 Mac48Address
83 {
84  NS_LOG_FUNCTION(this);
85  return m_sourceAddress;
86 }
87 
88 uint32_t
90 {
91  NS_LOG_FUNCTION(this);
92 
93  return (2 * ADDRESS_LENGHT);
94 }
95 
96 void
97 SatMacTag::Serialize(TagBuffer i) const
98 {
99  NS_LOG_FUNCTION(this << &i);
100 
101  uint8_t buff[ADDRESS_LENGHT];
102 
103  m_destAddress.CopyTo(buff);
104  i.Write(buff, ADDRESS_LENGHT);
105 
106  m_sourceAddress.CopyTo(buff);
107  i.Write(buff, ADDRESS_LENGHT);
108 }
109 
110 void
112 {
113  NS_LOG_FUNCTION(this << &i);
114 
115  uint8_t buff[ADDRESS_LENGHT];
116 
117  i.Read(buff, ADDRESS_LENGHT);
118  m_destAddress.CopyFrom(buff);
119 
120  i.Read(buff, ADDRESS_LENGHT);
121  m_sourceAddress.CopyFrom(buff);
122 }
123 
124 void
125 SatMacTag::Print(std::ostream& os) const
126 {
127  NS_LOG_FUNCTION(this << &os);
128  os << "DestAddress=" << m_destAddress << "SourceAddress" << m_sourceAddress;
129 }
130 
131 NS_OBJECT_ENSURE_REGISTERED(SatAddressE2ETag);
132 
134 {
135  NS_LOG_FUNCTION(this);
136 }
137 
139 {
140  NS_LOG_FUNCTION(this);
141 }
142 
143 TypeId
145 {
146  static TypeId tid =
147  TypeId("ns3::SatAddressE2ETag").SetParent<Tag>().AddConstructor<SatAddressE2ETag>();
148  return tid;
149 }
150 
151 TypeId
153 {
154  NS_LOG_FUNCTION(this);
155 
156  return GetTypeId();
157 }
158 
159 void
160 SatAddressE2ETag::SetE2EDestAddress(Mac48Address e2eDestAddress)
161 {
162  NS_LOG_FUNCTION(this << e2eDestAddress);
163  m_e2eDestAddress = e2eDestAddress;
164 }
165 
166 Mac48Address
168 {
169  NS_LOG_FUNCTION(this);
170  return m_e2eDestAddress;
171 }
172 
173 void
174 SatAddressE2ETag::SetE2ESourceAddress(Mac48Address e2eSourceAddress)
175 {
176  NS_LOG_FUNCTION(this << e2eSourceAddress);
177  m_e2eSourceAddress = e2eSourceAddress;
178 }
179 
180 Mac48Address
182 {
183  NS_LOG_FUNCTION(this);
184  return m_e2eSourceAddress;
185 }
186 
187 uint32_t
189 {
190  NS_LOG_FUNCTION(this);
191 
192  return (2 * ADDRESS_LENGHT);
193 }
194 
195 void
196 SatAddressE2ETag::Serialize(TagBuffer i) const
197 {
198  NS_LOG_FUNCTION(this << &i);
199 
200  uint8_t buff[ADDRESS_LENGHT];
201 
202  m_e2eDestAddress.CopyTo(buff);
203  i.Write(buff, ADDRESS_LENGHT);
204 
205  m_e2eSourceAddress.CopyTo(buff);
206  i.Write(buff, ADDRESS_LENGHT);
207 }
208 
209 void
211 {
212  NS_LOG_FUNCTION(this << &i);
213 
214  uint8_t buff[ADDRESS_LENGHT];
215 
216  i.Read(buff, ADDRESS_LENGHT);
217  m_e2eDestAddress.CopyFrom(buff);
218 
219  i.Read(buff, ADDRESS_LENGHT);
220  m_e2eSourceAddress.CopyFrom(buff);
221 }
222 
223 void
224 SatAddressE2ETag::Print(std::ostream& os) const
225 {
226  NS_LOG_FUNCTION(this << &os);
227  os << "E2EDestAddress=" << m_e2eDestAddress << "E2ESourceAddress" << m_e2eSourceAddress;
228 }
229 
230 NS_OBJECT_ENSURE_REGISTERED(SatFlowIdTag);
231 
233  : m_flowId(0)
234 {
235  NS_LOG_FUNCTION(this);
236 }
237 
239 {
240  NS_LOG_FUNCTION(this);
241 }
242 
243 TypeId
245 {
246  static TypeId tid = TypeId("ns3::SatFlowIdTag").SetParent<Tag>().AddConstructor<SatFlowIdTag>();
247  return tid;
248 }
249 
250 TypeId
252 {
253  NS_LOG_FUNCTION(this);
254 
255  return GetTypeId();
256 }
257 
258 void
259 SatFlowIdTag::SetFlowId(uint8_t flowId)
260 {
261  NS_LOG_FUNCTION(this << (uint32_t)flowId);
262  m_flowId = flowId;
263 }
264 
265 uint8_t
267 {
268  NS_LOG_FUNCTION(this);
269  return m_flowId;
270 }
271 
272 uint32_t
274 {
275  NS_LOG_FUNCTION(this);
276 
277  return sizeof(uint8_t);
278 }
279 
280 void
281 SatFlowIdTag::Serialize(TagBuffer i) const
282 {
283  NS_LOG_FUNCTION(this << &i);
284 
285  i.WriteU8(m_flowId);
286 }
287 
288 void
290 {
291  NS_LOG_FUNCTION(this << &i);
292 
293  m_flowId = i.ReadU8();
294 }
295 
296 void
297 SatFlowIdTag::Print(std::ostream& os) const
298 {
299  NS_LOG_FUNCTION(this << &os);
300  os << "FlowId=" << m_flowId;
301 }
302 
303 } // namespace ns3
This class implements a tag that carries the satellite MAC of GW and UT.
static const uint32_t ADDRESS_LENGHT
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatMacTag.
~SatAddressE2ETag()
Destructor for SatMacTag.
void SetE2ESourceAddress(Mac48Address e2eSourceAddress)
Set E2E source MAC address.
virtual uint32_t GetSerializedSize(void) const
Get serialized size of SatMacTag.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatMacTag.
SatAddressE2ETag()
Default constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
Mac48Address GetE2ESourceAddress(void) const
Get E2E source MAC address.
void SetE2EDestAddress(Mac48Address e2eDestAddress)
Set E2E destination MAC address.
Mac48Address GetE2EDestAddress(void) const
Get E2E destination MAC address.
Mac48Address m_e2eSourceAddress
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatMacTag.
SatFlowIdTag implements a tag which carries the flow identifier of a packet.
void SetFlowId(uint8_t flowId)
Set flow id.
virtual uint32_t GetSerializedSize(void) const
Get serialized size of SatFlowIdTag.
SatFlowIdTag()
Default constructor.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatFlowIdTag.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
uint8_t GetFlowId() const
Get flow identifier.
static TypeId GetTypeId(void)
Get the type ID.
~SatFlowIdTag()
Destructor for SatFlowIdTag.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatFlowIdTag.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatFlowIdTag.
SatMacTag()
Default constructor.
static const uint32_t ADDRESS_LENGHT
static TypeId GetTypeId(void)
Get the type ID.
Mac48Address m_sourceAddress
virtual uint32_t GetSerializedSize(void) const
Get serialized size of SatMacTag.
~SatMacTag()
Destructor for SatMacTag.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatMacTag.
void SetDestAddress(Mac48Address dest)
Set destination MAC address.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatMacTag.
Mac48Address m_destAddress
Mac48Address GetSourceAddress(void) const
Get source MAC address.
Mac48Address GetDestAddress(void) const
Get destination MAC address.
void SetSourceAddress(Mac48Address source)
Set source MAC address.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatMacTag.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.