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 namespace ns3
24 {
25 
26 /*
27  * There are 4 classes defined here: SatTimeTag, SatPhyTimeTag, SatMacTimeTag,
28  * SatDevTimeTag, and SatAppTimeTag. Except of the name difference, they share
29  * exactly the same definitions.
30  */
31 
32 // LLC ////////////////////////////////////////////////////////////////////////
33 
34 NS_OBJECT_ENSURE_REGISTERED(SatTimeTag);
35 
37  : m_senderTimestamp(Seconds(0))
38 {
39  // Nothing to do here
40 }
41 
42 SatTimeTag::SatTimeTag(Time senderTimestamp)
43  : m_senderTimestamp(senderTimestamp)
44 {
45  // Nothing to do here
46 }
47 
48 TypeId
50 {
51  static TypeId tid = TypeId("ns3::SatTimeTag").SetParent<Tag>().AddConstructor<SatTimeTag>();
52  return tid;
53 }
54 
55 TypeId
57 {
58  return GetTypeId();
59 }
60 
61 uint32_t
63 {
64  return sizeof(Time);
65 }
66 
67 void
68 SatTimeTag::Serialize(TagBuffer i) const
69 {
70  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
71  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
72 }
73 
74 void
76 {
77  int64_t senderTimestamp;
78  i.Read((uint8_t*)&senderTimestamp, 8);
79  m_senderTimestamp = NanoSeconds(senderTimestamp);
80 }
81 
82 void
83 SatTimeTag::Print(std::ostream& os) const
84 {
85  os << m_senderTimestamp;
86 }
87 
88 Time
90 {
91  return m_senderTimestamp;
92 }
93 
94 void
95 SatTimeTag::SetSenderTimestamp(Time senderTimestamp)
96 {
97  this->m_senderTimestamp = senderTimestamp;
98 }
99 
100 // PHY ////////////////////////////////////////////////////////////////////////
101 
102 NS_OBJECT_ENSURE_REGISTERED(SatPhyTimeTag);
103 
105  : m_senderTimestamp(Seconds(0))
106 {
107  // Nothing to do here
108 }
109 
110 SatPhyTimeTag::SatPhyTimeTag(Time senderTimestamp)
111  : m_senderTimestamp(senderTimestamp)
112 {
113  // Nothing to do here
114 }
115 
116 TypeId
118 {
119  static TypeId tid =
120  TypeId("ns3::SatPhyTimeTag").SetParent<Tag>().AddConstructor<SatPhyTimeTag>();
121  return tid;
122 }
123 
124 TypeId
126 {
127  return GetTypeId();
128 }
129 
130 uint32_t
132 {
133  return sizeof(Time);
134 }
135 
136 void
137 SatPhyTimeTag::Serialize(TagBuffer i) const
138 {
139  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
140  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
141 }
142 
143 void
145 {
146  int64_t senderTimestamp;
147  i.Read((uint8_t*)&senderTimestamp, 8);
148  m_senderTimestamp = NanoSeconds(senderTimestamp);
149 }
150 
151 void
152 SatPhyTimeTag::Print(std::ostream& os) const
153 {
154  os << m_senderTimestamp;
155 }
156 
157 Time
159 {
160  return m_senderTimestamp;
161 }
162 
163 void
165 {
166  this->m_senderTimestamp = senderTimestamp;
167 }
168 
169 // PHY LINK ////////////////////////////////////////////////////////////////////////
170 
171 NS_OBJECT_ENSURE_REGISTERED(SatPhyLinkTimeTag);
172 
174  : m_senderLinkTimestamp(Seconds(0))
175 {
176  // Nothing to do here
177 }
178 
179 SatPhyLinkTimeTag::SatPhyLinkTimeTag(Time senderLinkTimestamp)
180  : m_senderLinkTimestamp(senderLinkTimestamp)
181 {
182  // Nothing to do here
183 }
184 
185 TypeId
187 {
188  static TypeId tid =
189  TypeId("ns3::SatPhyLinkTimeTag").SetParent<Tag>().AddConstructor<SatPhyLinkTimeTag>();
190  return tid;
191 }
192 
193 TypeId
195 {
196  return GetTypeId();
197 }
198 
199 uint32_t
201 {
202  return sizeof(Time);
203 }
204 
205 void
207 {
208  int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
209  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
210 }
211 
212 void
214 {
215  int64_t senderTimestamp;
216  i.Read((uint8_t*)&senderTimestamp, 8);
217  m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
218 }
219 
220 void
221 SatPhyLinkTimeTag::Print(std::ostream& os) const
222 {
223  os << m_senderLinkTimestamp;
224 }
225 
226 Time
228 {
229  return m_senderLinkTimestamp;
230 }
231 
232 void
234 {
235  this->m_senderLinkTimestamp = senderLinkTimestamp;
236 }
237 
238 // MAC ////////////////////////////////////////////////////////////////////////
239 
240 NS_OBJECT_ENSURE_REGISTERED(SatMacTimeTag);
241 
243  : m_senderTimestamp(Seconds(0))
244 {
245  // Nothing to do here
246 }
247 
248 SatMacTimeTag::SatMacTimeTag(Time senderTimestamp)
249  : m_senderTimestamp(senderTimestamp)
250 {
251  // Nothing to do here
252 }
253 
254 TypeId
256 {
257  static TypeId tid =
258  TypeId("ns3::SatMacTimeTag").SetParent<Tag>().AddConstructor<SatMacTimeTag>();
259  return tid;
260 }
261 
262 TypeId
264 {
265  return GetTypeId();
266 }
267 
268 uint32_t
270 {
271  return sizeof(Time);
272 }
273 
274 void
275 SatMacTimeTag::Serialize(TagBuffer i) const
276 {
277  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
278  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
279 }
280 
281 void
283 {
284  int64_t senderTimestamp;
285  i.Read((uint8_t*)&senderTimestamp, 8);
286  m_senderTimestamp = NanoSeconds(senderTimestamp);
287 }
288 
289 void
290 SatMacTimeTag::Print(std::ostream& os) const
291 {
292  os << m_senderTimestamp;
293 }
294 
295 Time
297 {
298  return m_senderTimestamp;
299 }
300 
301 void
303 {
304  this->m_senderTimestamp = senderTimestamp;
305 }
306 
307 // MAC LINK ////////////////////////////////////////////////////////////////////////
308 
309 NS_OBJECT_ENSURE_REGISTERED(SatMacLinkTimeTag);
310 
312  : m_senderLinkTimestamp(Seconds(0))
313 {
314  // Nothing to do here
315 }
316 
317 SatMacLinkTimeTag::SatMacLinkTimeTag(Time senderLinkTimestamp)
318  : m_senderLinkTimestamp(senderLinkTimestamp)
319 {
320  // Nothing to do here
321 }
322 
323 TypeId
325 {
326  static TypeId tid =
327  TypeId("ns3::SatMacLinkTimeTag").SetParent<Tag>().AddConstructor<SatMacLinkTimeTag>();
328  return tid;
329 }
330 
331 TypeId
333 {
334  return GetTypeId();
335 }
336 
337 uint32_t
339 {
340  return sizeof(Time);
341 }
342 
343 void
345 {
346  int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
347  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
348 }
349 
350 void
352 {
353  int64_t senderTimestamp;
354  i.Read((uint8_t*)&senderTimestamp, 8);
355  m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
356 }
357 
358 void
359 SatMacLinkTimeTag::Print(std::ostream& os) const
360 {
361  os << m_senderLinkTimestamp;
362 }
363 
364 Time
366 {
367  return m_senderLinkTimestamp;
368 }
369 
370 void
372 {
373  this->m_senderLinkTimestamp = senderLinkTimestamp;
374 }
375 
376 // DEV ////////////////////////////////////////////////////////////////////////
377 
378 NS_OBJECT_ENSURE_REGISTERED(SatDevTimeTag);
379 
381  : m_senderTimestamp(Seconds(0))
382 {
383  // Nothing to do here
384 }
385 
386 SatDevTimeTag::SatDevTimeTag(Time senderTimestamp)
387  : m_senderTimestamp(senderTimestamp)
388 {
389  // Nothing to do here
390 }
391 
392 TypeId
394 {
395  static TypeId tid =
396  TypeId("ns3::SatDevTimeTag").SetParent<Tag>().AddConstructor<SatDevTimeTag>();
397  return tid;
398 }
399 
400 TypeId
402 {
403  return GetTypeId();
404 }
405 
406 uint32_t
408 {
409  return sizeof(Time);
410 }
411 
412 void
413 SatDevTimeTag::Serialize(TagBuffer i) const
414 {
415  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
416  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
417 }
418 
419 void
421 {
422  int64_t senderTimestamp;
423  i.Read((uint8_t*)&senderTimestamp, 8);
424  m_senderTimestamp = NanoSeconds(senderTimestamp);
425 }
426 
427 void
428 SatDevTimeTag::Print(std::ostream& os) const
429 {
430  os << m_senderTimestamp;
431 }
432 
433 Time
435 {
436  return m_senderTimestamp;
437 }
438 
439 void
441 {
442  this->m_senderTimestamp = senderTimestamp;
443 }
444 
445 // DEV LINK ////////////////////////////////////////////////////////////////////////
446 
447 NS_OBJECT_ENSURE_REGISTERED(SatDevLinkTimeTag);
448 
450  : m_senderTimestamp(Seconds(0))
451 {
452  // Nothing to do here
453 }
454 
456  : m_senderTimestamp(senderTimestamp)
457 {
458  // Nothing to do here
459 }
460 
461 TypeId
463 {
464  static TypeId tid =
465  TypeId("ns3::SatDevLinkTimeTag").SetParent<Tag>().AddConstructor<SatDevLinkTimeTag>();
466  return tid;
467 }
468 
469 TypeId
471 {
472  return GetTypeId();
473 }
474 
475 uint32_t
477 {
478  return sizeof(Time);
479 }
480 
481 void
483 {
484  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
485  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
486 }
487 
488 void
490 {
491  int64_t senderTimestamp;
492  i.Read((uint8_t*)&senderTimestamp, 8);
493  m_senderTimestamp = NanoSeconds(senderTimestamp);
494 }
495 
496 void
497 SatDevLinkTimeTag::Print(std::ostream& os) const
498 {
499  os << m_senderTimestamp;
500 }
501 
502 Time
504 {
505  return m_senderTimestamp;
506 }
507 
508 void
510 {
511  this->m_senderTimestamp = senderTimestamp;
512 }
513 
514 } // 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.
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.