Loading...
Searching...
No Matches
satellite-time-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: Jani Puttonen <jani.puttonen@magister.fi>
19 */
20
21#include "satellite-time-tag.h"
22
23#include <ostream>
24
25namespace ns3
26{
27
28/*
29 * There are 4 classes defined here: SatTimeTag, SatPhyTimeTag, SatMacTimeTag,
30 * SatDevTimeTag, and SatAppTimeTag. Except of the name difference, they share
31 * exactly the same definitions.
32 */
33
34// LLC ////////////////////////////////////////////////////////////////////////
35
36NS_OBJECT_ENSURE_REGISTERED(SatTimeTag);
37
39 : m_senderTimestamp(Seconds(0))
40{
41 // Nothing to do here
42}
43
44SatTimeTag::SatTimeTag(Time senderTimestamp)
45 : m_senderTimestamp(senderTimestamp)
46{
47 // Nothing to do here
48}
49
50TypeId
52{
53 static TypeId tid = TypeId("ns3::SatTimeTag").SetParent<Tag>().AddConstructor<SatTimeTag>();
54 return tid;
55}
56
57TypeId
59{
60 return GetTypeId();
61}
62
63uint32_t
65{
66 return sizeof(Time);
67}
68
69void
70SatTimeTag::Serialize(TagBuffer i) const
71{
72 int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
73 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
74}
75
76void
78{
79 int64_t senderTimestamp;
80 i.Read((uint8_t*)&senderTimestamp, 8);
81 m_senderTimestamp = NanoSeconds(senderTimestamp);
82}
83
84void
85SatTimeTag::Print(std::ostream& os) const
86{
88}
89
90Time
95
96void
97SatTimeTag::SetSenderTimestamp(Time senderTimestamp)
98{
99 this->m_senderTimestamp = senderTimestamp;
100}
101
102// PHY ////////////////////////////////////////////////////////////////////////
103
104NS_OBJECT_ENSURE_REGISTERED(SatPhyTimeTag);
105
107 : m_senderTimestamp(Seconds(0))
108{
109 // Nothing to do here
110}
111
112SatPhyTimeTag::SatPhyTimeTag(Time senderTimestamp)
113 : m_senderTimestamp(senderTimestamp)
114{
115 // Nothing to do here
116}
117
118TypeId
120{
121 static TypeId tid =
122 TypeId("ns3::SatPhyTimeTag").SetParent<Tag>().AddConstructor<SatPhyTimeTag>();
123 return tid;
124}
125
126TypeId
128{
129 return GetTypeId();
130}
131
132uint32_t
134{
135 return sizeof(Time);
136}
137
138void
139SatPhyTimeTag::Serialize(TagBuffer i) const
140{
141 int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
142 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
143}
144
145void
147{
148 int64_t senderTimestamp;
149 i.Read((uint8_t*)&senderTimestamp, 8);
150 m_senderTimestamp = NanoSeconds(senderTimestamp);
151}
152
153void
154SatPhyTimeTag::Print(std::ostream& os) const
155{
156 os << m_senderTimestamp;
157}
158
159Time
161{
162 return m_senderTimestamp;
163}
164
165void
167{
168 this->m_senderTimestamp = senderTimestamp;
169}
170
171// PHY LINK ////////////////////////////////////////////////////////////////////////
172
173NS_OBJECT_ENSURE_REGISTERED(SatPhyLinkTimeTag);
174
176 : m_senderLinkTimestamp(Seconds(0))
177{
178 // Nothing to do here
179}
180
182 : m_senderLinkTimestamp(senderLinkTimestamp)
183{
184 // Nothing to do here
185}
186
187TypeId
189{
190 static TypeId tid =
191 TypeId("ns3::SatPhyLinkTimeTag").SetParent<Tag>().AddConstructor<SatPhyLinkTimeTag>();
192 return tid;
193}
194
195TypeId
197{
198 return GetTypeId();
199}
200
201uint32_t
203{
204 return sizeof(Time);
205}
206
207void
209{
210 int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
211 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
212}
213
214void
216{
217 int64_t senderTimestamp;
218 i.Read((uint8_t*)&senderTimestamp, 8);
219 m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
220}
221
222void
223SatPhyLinkTimeTag::Print(std::ostream& os) const
224{
226}
227
228Time
233
234void
236{
237 this->m_senderLinkTimestamp = senderLinkTimestamp;
238}
239
240// MAC ////////////////////////////////////////////////////////////////////////
241
242NS_OBJECT_ENSURE_REGISTERED(SatMacTimeTag);
243
245 : m_senderTimestamp(Seconds(0))
246{
247 // Nothing to do here
248}
249
250SatMacTimeTag::SatMacTimeTag(Time senderTimestamp)
251 : m_senderTimestamp(senderTimestamp)
252{
253 // Nothing to do here
254}
255
256TypeId
258{
259 static TypeId tid =
260 TypeId("ns3::SatMacTimeTag").SetParent<Tag>().AddConstructor<SatMacTimeTag>();
261 return tid;
262}
263
264TypeId
266{
267 return GetTypeId();
268}
269
270uint32_t
272{
273 return sizeof(Time);
274}
275
276void
277SatMacTimeTag::Serialize(TagBuffer i) const
278{
279 int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
280 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
281}
282
283void
285{
286 int64_t senderTimestamp;
287 i.Read((uint8_t*)&senderTimestamp, 8);
288 m_senderTimestamp = NanoSeconds(senderTimestamp);
289}
290
291void
292SatMacTimeTag::Print(std::ostream& os) const
293{
294 os << m_senderTimestamp;
295}
296
297Time
299{
300 return m_senderTimestamp;
301}
302
303void
305{
306 this->m_senderTimestamp = senderTimestamp;
307}
308
309// MAC LINK ////////////////////////////////////////////////////////////////////////
310
311NS_OBJECT_ENSURE_REGISTERED(SatMacLinkTimeTag);
312
314 : m_senderLinkTimestamp(Seconds(0))
315{
316 // Nothing to do here
317}
318
320 : m_senderLinkTimestamp(senderLinkTimestamp)
321{
322 // Nothing to do here
323}
324
325TypeId
327{
328 static TypeId tid =
329 TypeId("ns3::SatMacLinkTimeTag").SetParent<Tag>().AddConstructor<SatMacLinkTimeTag>();
330 return tid;
331}
332
333TypeId
335{
336 return GetTypeId();
337}
338
339uint32_t
341{
342 return sizeof(Time);
343}
344
345void
347{
348 int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
349 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
350}
351
352void
354{
355 int64_t senderTimestamp;
356 i.Read((uint8_t*)&senderTimestamp, 8);
357 m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
358}
359
360void
361SatMacLinkTimeTag::Print(std::ostream& os) const
362{
364}
365
366Time
371
372void
374{
375 this->m_senderLinkTimestamp = senderLinkTimestamp;
376}
377
378// DEV ////////////////////////////////////////////////////////////////////////
379
380NS_OBJECT_ENSURE_REGISTERED(SatDevTimeTag);
381
383 : m_senderTimestamp(Seconds(0))
384{
385 // Nothing to do here
386}
387
388SatDevTimeTag::SatDevTimeTag(Time senderTimestamp)
389 : m_senderTimestamp(senderTimestamp)
390{
391 // Nothing to do here
392}
393
394TypeId
396{
397 static TypeId tid =
398 TypeId("ns3::SatDevTimeTag").SetParent<Tag>().AddConstructor<SatDevTimeTag>();
399 return tid;
400}
401
402TypeId
404{
405 return GetTypeId();
406}
407
408uint32_t
410{
411 return sizeof(Time);
412}
413
414void
415SatDevTimeTag::Serialize(TagBuffer i) const
416{
417 int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
418 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
419}
420
421void
423{
424 int64_t senderTimestamp;
425 i.Read((uint8_t*)&senderTimestamp, 8);
426 m_senderTimestamp = NanoSeconds(senderTimestamp);
427}
428
429void
430SatDevTimeTag::Print(std::ostream& os) const
431{
432 os << m_senderTimestamp;
433}
434
435Time
437{
438 return m_senderTimestamp;
439}
440
441void
443{
444 this->m_senderTimestamp = senderTimestamp;
445}
446
447// DEV LINK ////////////////////////////////////////////////////////////////////////
448
449NS_OBJECT_ENSURE_REGISTERED(SatDevLinkTimeTag);
450
452 : m_senderTimestamp(Seconds(0))
453{
454 // Nothing to do here
455}
456
458 : m_senderTimestamp(senderTimestamp)
459{
460 // Nothing to do here
461}
462
463TypeId
465{
466 static TypeId tid =
467 TypeId("ns3::SatDevLinkTimeTag").SetParent<Tag>().AddConstructor<SatDevLinkTimeTag>();
468 return tid;
469}
470
471TypeId
473{
474 return GetTypeId();
475}
476
477uint32_t
479{
480 return sizeof(Time);
481}
482
483void
485{
486 int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
487 i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
488}
489
490void
492{
493 int64_t senderTimestamp;
494 i.Read((uint8_t*)&senderTimestamp, 8);
495 m_senderTimestamp = NanoSeconds(senderTimestamp);
496}
497
498void
499SatDevLinkTimeTag::Print(std::ostream& os) const
500{
501 os << m_senderTimestamp;
502}
503
504Time
509
510void
512{
513 this->m_senderTimestamp = senderTimestamp;
514}
515
516} // namespace ns3
Time tag used to identify the time when packet is enqueued at device level.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatDevTimeTag.
SatDevTimeTag()
Default constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSerializedSize() const
Get serialized size of SatDevTimeTag.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
void SetSenderTimestamp(Time senderTimestamp)
Set sender time stamp of this tag.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatDevTimeTag.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatDevTimeTag.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
Time tag used to identify the time when packet is enqueued at MAC level.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatMacTimeTag.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatMacTimeTag.
SatMacTimeTag()
Default constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
virtual uint32_t GetSerializedSize() const
Get serialized size of SatMacTimeTag.
void SetSenderTimestamp(Time senderTimestamp)
Set sender time stamp of this tag.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatMacTimeTag.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
Time tag used to identify the time when packet is enqueued at PHY on first link between GW and UT lev...
void SetSenderTimestamp(Time senderTimestamp)
Set sender time stamp of this tag.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
SatPhyTimeTag()
Default constructor.
virtual uint32_t GetSerializedSize() const
Get serialized size of SatPhyTimeTag.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatPhyTimeTag.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatPhyTimeTag.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatPhyTimeTag.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
Time tag used to identify the time when packet is enqueued at LLC level.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
virtual uint32_t GetSerializedSize() const
Get serialized size of SatTimeTag.
virtual void Deserialize(TagBuffer i)
Deserializes information from buffer to this instance of SatTimeTag.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
virtual void Print(std::ostream &os) const
Print time stamp of this instance of SatTimeTag.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Serialize(TagBuffer i) const
Serializes information to buffer from this instance of SatTimeTag.
void SetSenderTimestamp(Time senderTimestamp)
Set sender time stamp of this tag.
SatTimeTag()
Default constructor.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.