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 NS_LOG_COMPONENT_DEFINE("SatMacTag");
27 
28 namespace ns3
29 {
30 
31 NS_OBJECT_ENSURE_REGISTERED(SatMacTag);
32 
34 {
35  NS_LOG_FUNCTION(this);
36 }
37 
39 {
40  NS_LOG_FUNCTION(this);
41 }
42 
43 TypeId
45 {
46  static TypeId tid = TypeId("ns3::SatMacTag").SetParent<Tag>().AddConstructor<SatMacTag>();
47  return tid;
48 }
49 
50 TypeId
52 {
53  NS_LOG_FUNCTION(this);
54 
55  return GetTypeId();
56 }
57 
58 void
59 SatMacTag::SetDestAddress(Mac48Address dest)
60 {
61  NS_LOG_FUNCTION(this << dest);
62  m_destAddress = dest;
63 }
64 
65 Mac48Address
67 {
68  NS_LOG_FUNCTION(this);
69  return m_destAddress;
70 }
71 
72 void
73 SatMacTag::SetSourceAddress(Mac48Address source)
74 {
75  NS_LOG_FUNCTION(this << source);
76  m_sourceAddress = source;
77 }
78 
79 Mac48Address
81 {
82  NS_LOG_FUNCTION(this);
83  return m_sourceAddress;
84 }
85 
86 uint32_t
88 {
89  NS_LOG_FUNCTION(this);
90 
91  return (2 * ADDRESS_LENGHT);
92 }
93 
94 void
95 SatMacTag::Serialize(TagBuffer i) const
96 {
97  NS_LOG_FUNCTION(this << &i);
98 
99  uint8_t buff[ADDRESS_LENGHT];
100 
101  m_destAddress.CopyTo(buff);
102  i.Write(buff, ADDRESS_LENGHT);
103 
104  m_sourceAddress.CopyTo(buff);
105  i.Write(buff, ADDRESS_LENGHT);
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION(this << &i);
112 
113  uint8_t buff[ADDRESS_LENGHT];
114 
115  i.Read(buff, ADDRESS_LENGHT);
116  m_destAddress.CopyFrom(buff);
117 
118  i.Read(buff, ADDRESS_LENGHT);
119  m_sourceAddress.CopyFrom(buff);
120 }
121 
122 void
123 SatMacTag::Print(std::ostream& os) const
124 {
125  NS_LOG_FUNCTION(this << &os);
126  os << "DestAddress=" << m_destAddress << "SourceAddress" << m_sourceAddress;
127 }
128 
129 NS_OBJECT_ENSURE_REGISTERED(SatAddressE2ETag);
130 
132 {
133  NS_LOG_FUNCTION(this);
134 }
135 
137 {
138  NS_LOG_FUNCTION(this);
139 }
140 
141 TypeId
143 {
144  static TypeId tid =
145  TypeId("ns3::SatAddressE2ETag").SetParent<Tag>().AddConstructor<SatAddressE2ETag>();
146  return tid;
147 }
148 
149 TypeId
151 {
152  NS_LOG_FUNCTION(this);
153 
154  return GetTypeId();
155 }
156 
157 void
158 SatAddressE2ETag::SetE2EDestAddress(Mac48Address e2eDestAddress)
159 {
160  NS_LOG_FUNCTION(this << e2eDestAddress);
161  m_e2eDestAddress = e2eDestAddress;
162 }
163 
164 Mac48Address
166 {
167  NS_LOG_FUNCTION(this);
168  return m_e2eDestAddress;
169 }
170 
171 void
172 SatAddressE2ETag::SetE2ESourceAddress(Mac48Address e2eSourceAddress)
173 {
174  NS_LOG_FUNCTION(this << e2eSourceAddress);
175  m_e2eSourceAddress = e2eSourceAddress;
176 }
177 
178 Mac48Address
180 {
181  NS_LOG_FUNCTION(this);
182  return m_e2eSourceAddress;
183 }
184 
185 uint32_t
187 {
188  NS_LOG_FUNCTION(this);
189 
190  return (2 * ADDRESS_LENGHT);
191 }
192 
193 void
194 SatAddressE2ETag::Serialize(TagBuffer i) const
195 {
196  NS_LOG_FUNCTION(this << &i);
197 
198  uint8_t buff[ADDRESS_LENGHT];
199 
200  m_e2eDestAddress.CopyTo(buff);
201  i.Write(buff, ADDRESS_LENGHT);
202 
203  m_e2eSourceAddress.CopyTo(buff);
204  i.Write(buff, ADDRESS_LENGHT);
205 }
206 
207 void
209 {
210  NS_LOG_FUNCTION(this << &i);
211 
212  uint8_t buff[ADDRESS_LENGHT];
213 
214  i.Read(buff, ADDRESS_LENGHT);
215  m_e2eDestAddress.CopyFrom(buff);
216 
217  i.Read(buff, ADDRESS_LENGHT);
218  m_e2eSourceAddress.CopyFrom(buff);
219 }
220 
221 void
222 SatAddressE2ETag::Print(std::ostream& os) const
223 {
224  NS_LOG_FUNCTION(this << &os);
225  os << "E2EDestAddress=" << m_e2eDestAddress << "E2ESourceAddress" << m_e2eSourceAddress;
226 }
227 
228 NS_OBJECT_ENSURE_REGISTERED(SatFlowIdTag);
229 
231  : m_flowId(0)
232 {
233  NS_LOG_FUNCTION(this);
234 }
235 
237 {
238  NS_LOG_FUNCTION(this);
239 }
240 
241 TypeId
243 {
244  static TypeId tid = TypeId("ns3::SatFlowIdTag").SetParent<Tag>().AddConstructor<SatFlowIdTag>();
245  return tid;
246 }
247 
248 TypeId
250 {
251  NS_LOG_FUNCTION(this);
252 
253  return GetTypeId();
254 }
255 
256 void
257 SatFlowIdTag::SetFlowId(uint8_t flowId)
258 {
259  NS_LOG_FUNCTION(this << (uint32_t)flowId);
260  m_flowId = flowId;
261 }
262 
263 uint8_t
265 {
266  NS_LOG_FUNCTION(this);
267  return m_flowId;
268 }
269 
270 uint32_t
272 {
273  NS_LOG_FUNCTION(this);
274 
275  return sizeof(uint8_t);
276 }
277 
278 void
279 SatFlowIdTag::Serialize(TagBuffer i) const
280 {
281  NS_LOG_FUNCTION(this << &i);
282 
283  i.WriteU8(m_flowId);
284 }
285 
286 void
288 {
289  NS_LOG_FUNCTION(this << &i);
290 
291  m_flowId = i.ReadU8();
292 }
293 
294 void
295 SatFlowIdTag::Print(std::ostream& os) const
296 {
297  NS_LOG_FUNCTION(this << &os);
298  os << "FlowId=" << m_flowId;
299 }
300 
301 } // 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.