Loading...
Searching...
No Matches
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
28NS_LOG_COMPONENT_DEFINE("SatMacTag");
29
30namespace ns3
31{
32
33NS_OBJECT_ENSURE_REGISTERED(SatMacTag);
34
36{
37 NS_LOG_FUNCTION(this);
38}
39
41{
42 NS_LOG_FUNCTION(this);
43}
44
45TypeId
47{
48 static TypeId tid = TypeId("ns3::SatMacTag").SetParent<Tag>().AddConstructor<SatMacTag>();
49 return tid;
50}
51
52TypeId
54{
55 NS_LOG_FUNCTION(this);
56
57 return GetTypeId();
58}
59
60void
61SatMacTag::SetDestAddress(Mac48Address dest)
62{
63 NS_LOG_FUNCTION(this << dest);
64 m_destAddress = dest;
65}
66
67Mac48Address
69{
70 NS_LOG_FUNCTION(this);
71 return m_destAddress;
72}
73
74void
75SatMacTag::SetSourceAddress(Mac48Address source)
76{
77 NS_LOG_FUNCTION(this << source);
78 m_sourceAddress = source;
79}
80
81Mac48Address
83{
84 NS_LOG_FUNCTION(this);
85 return m_sourceAddress;
86}
87
88uint32_t
90{
91 NS_LOG_FUNCTION(this);
92
93 return (2 * ADDRESS_LENGHT);
94}
95
96void
97SatMacTag::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
110void
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
124void
125SatMacTag::Print(std::ostream& os) const
126{
127 NS_LOG_FUNCTION(this << &os);
128 os << "DestAddress=" << m_destAddress << "SourceAddress" << m_sourceAddress;
129}
130
131NS_OBJECT_ENSURE_REGISTERED(SatAddressE2ETag);
132
134{
135 NS_LOG_FUNCTION(this);
136}
137
139{
140 NS_LOG_FUNCTION(this);
141}
142
143TypeId
145{
146 static TypeId tid =
147 TypeId("ns3::SatAddressE2ETag").SetParent<Tag>().AddConstructor<SatAddressE2ETag>();
148 return tid;
149}
150
151TypeId
153{
154 NS_LOG_FUNCTION(this);
155
156 return GetTypeId();
157}
158
159void
160SatAddressE2ETag::SetE2EDestAddress(Mac48Address e2eDestAddress)
161{
162 NS_LOG_FUNCTION(this << e2eDestAddress);
163 m_e2eDestAddress = e2eDestAddress;
164}
165
166Mac48Address
168{
169 NS_LOG_FUNCTION(this);
170 return m_e2eDestAddress;
171}
172
173void
174SatAddressE2ETag::SetE2ESourceAddress(Mac48Address e2eSourceAddress)
175{
176 NS_LOG_FUNCTION(this << e2eSourceAddress);
177 m_e2eSourceAddress = e2eSourceAddress;
178}
179
180Mac48Address
182{
183 NS_LOG_FUNCTION(this);
184 return m_e2eSourceAddress;
185}
186
187uint32_t
189{
190 NS_LOG_FUNCTION(this);
191
192 return (2 * ADDRESS_LENGHT);
193}
194
195void
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
209void
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
223void
224SatAddressE2ETag::Print(std::ostream& os) const
225{
226 NS_LOG_FUNCTION(this << &os);
227 os << "E2EDestAddress=" << m_e2eDestAddress << "E2ESourceAddress" << m_e2eSourceAddress;
228}
229
230NS_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
243TypeId
245{
246 static TypeId tid = TypeId("ns3::SatFlowIdTag").SetParent<Tag>().AddConstructor<SatFlowIdTag>();
247 return tid;
248}
249
250TypeId
252{
253 NS_LOG_FUNCTION(this);
254
255 return GetTypeId();
256}
257
258void
260{
261 NS_LOG_FUNCTION(this << (uint32_t)flowId);
262 m_flowId = flowId;
263}
264
265uint8_t
267{
268 NS_LOG_FUNCTION(this);
269 return m_flowId;
270}
271
272uint32_t
274{
275 NS_LOG_FUNCTION(this);
276
277 return sizeof(uint8_t);
278}
279
280void
281SatFlowIdTag::Serialize(TagBuffer i) const
282{
283 NS_LOG_FUNCTION(this << &i);
284
285 i.WriteU8(m_flowId);
286}
287
288void
290{
291 NS_LOG_FUNCTION(this << &i);
292
293 m_flowId = i.ReadU8();
294}
295
296void
297SatFlowIdTag::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.
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.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
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.