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 
25 namespace 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 
36 NS_OBJECT_ENSURE_REGISTERED(SatTimeTag);
37 
39  : m_senderTimestamp(Seconds(0))
40 {
41  // Nothing to do here
42 }
43 
44 SatTimeTag::SatTimeTag(Time senderTimestamp)
45  : m_senderTimestamp(senderTimestamp)
46 {
47  // Nothing to do here
48 }
49 
50 TypeId
52 {
53  static TypeId tid = TypeId("ns3::SatTimeTag").SetParent<Tag>().AddConstructor<SatTimeTag>();
54  return tid;
55 }
56 
57 TypeId
59 {
60  return GetTypeId();
61 }
62 
63 uint32_t
65 {
66  return sizeof(Time);
67 }
68 
69 void
70 SatTimeTag::Serialize(TagBuffer i) const
71 {
72  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
73  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
74 }
75 
76 void
78 {
79  int64_t senderTimestamp;
80  i.Read((uint8_t*)&senderTimestamp, 8);
81  m_senderTimestamp = NanoSeconds(senderTimestamp);
82 }
83 
84 void
85 SatTimeTag::Print(std::ostream& os) const
86 {
87  os << m_senderTimestamp;
88 }
89 
90 Time
92 {
93  return m_senderTimestamp;
94 }
95 
96 void
97 SatTimeTag::SetSenderTimestamp(Time senderTimestamp)
98 {
99  this->m_senderTimestamp = senderTimestamp;
100 }
101 
102 // PHY ////////////////////////////////////////////////////////////////////////
103 
104 NS_OBJECT_ENSURE_REGISTERED(SatPhyTimeTag);
105 
107  : m_senderTimestamp(Seconds(0))
108 {
109  // Nothing to do here
110 }
111 
112 SatPhyTimeTag::SatPhyTimeTag(Time senderTimestamp)
113  : m_senderTimestamp(senderTimestamp)
114 {
115  // Nothing to do here
116 }
117 
118 TypeId
120 {
121  static TypeId tid =
122  TypeId("ns3::SatPhyTimeTag").SetParent<Tag>().AddConstructor<SatPhyTimeTag>();
123  return tid;
124 }
125 
126 TypeId
128 {
129  return GetTypeId();
130 }
131 
132 uint32_t
134 {
135  return sizeof(Time);
136 }
137 
138 void
139 SatPhyTimeTag::Serialize(TagBuffer i) const
140 {
141  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
142  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
143 }
144 
145 void
147 {
148  int64_t senderTimestamp;
149  i.Read((uint8_t*)&senderTimestamp, 8);
150  m_senderTimestamp = NanoSeconds(senderTimestamp);
151 }
152 
153 void
154 SatPhyTimeTag::Print(std::ostream& os) const
155 {
156  os << m_senderTimestamp;
157 }
158 
159 Time
161 {
162  return m_senderTimestamp;
163 }
164 
165 void
167 {
168  this->m_senderTimestamp = senderTimestamp;
169 }
170 
171 // PHY LINK ////////////////////////////////////////////////////////////////////////
172 
173 NS_OBJECT_ENSURE_REGISTERED(SatPhyLinkTimeTag);
174 
176  : m_senderLinkTimestamp(Seconds(0))
177 {
178  // Nothing to do here
179 }
180 
181 SatPhyLinkTimeTag::SatPhyLinkTimeTag(Time senderLinkTimestamp)
182  : m_senderLinkTimestamp(senderLinkTimestamp)
183 {
184  // Nothing to do here
185 }
186 
187 TypeId
189 {
190  static TypeId tid =
191  TypeId("ns3::SatPhyLinkTimeTag").SetParent<Tag>().AddConstructor<SatPhyLinkTimeTag>();
192  return tid;
193 }
194 
195 TypeId
197 {
198  return GetTypeId();
199 }
200 
201 uint32_t
203 {
204  return sizeof(Time);
205 }
206 
207 void
209 {
210  int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
211  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
212 }
213 
214 void
216 {
217  int64_t senderTimestamp;
218  i.Read((uint8_t*)&senderTimestamp, 8);
219  m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
220 }
221 
222 void
223 SatPhyLinkTimeTag::Print(std::ostream& os) const
224 {
225  os << m_senderLinkTimestamp;
226 }
227 
228 Time
230 {
231  return m_senderLinkTimestamp;
232 }
233 
234 void
236 {
237  this->m_senderLinkTimestamp = senderLinkTimestamp;
238 }
239 
240 // MAC ////////////////////////////////////////////////////////////////////////
241 
242 NS_OBJECT_ENSURE_REGISTERED(SatMacTimeTag);
243 
245  : m_senderTimestamp(Seconds(0))
246 {
247  // Nothing to do here
248 }
249 
250 SatMacTimeTag::SatMacTimeTag(Time senderTimestamp)
251  : m_senderTimestamp(senderTimestamp)
252 {
253  // Nothing to do here
254 }
255 
256 TypeId
258 {
259  static TypeId tid =
260  TypeId("ns3::SatMacTimeTag").SetParent<Tag>().AddConstructor<SatMacTimeTag>();
261  return tid;
262 }
263 
264 TypeId
266 {
267  return GetTypeId();
268 }
269 
270 uint32_t
272 {
273  return sizeof(Time);
274 }
275 
276 void
277 SatMacTimeTag::Serialize(TagBuffer i) const
278 {
279  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
280  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
281 }
282 
283 void
285 {
286  int64_t senderTimestamp;
287  i.Read((uint8_t*)&senderTimestamp, 8);
288  m_senderTimestamp = NanoSeconds(senderTimestamp);
289 }
290 
291 void
292 SatMacTimeTag::Print(std::ostream& os) const
293 {
294  os << m_senderTimestamp;
295 }
296 
297 Time
299 {
300  return m_senderTimestamp;
301 }
302 
303 void
305 {
306  this->m_senderTimestamp = senderTimestamp;
307 }
308 
309 // MAC LINK ////////////////////////////////////////////////////////////////////////
310 
311 NS_OBJECT_ENSURE_REGISTERED(SatMacLinkTimeTag);
312 
314  : m_senderLinkTimestamp(Seconds(0))
315 {
316  // Nothing to do here
317 }
318 
319 SatMacLinkTimeTag::SatMacLinkTimeTag(Time senderLinkTimestamp)
320  : m_senderLinkTimestamp(senderLinkTimestamp)
321 {
322  // Nothing to do here
323 }
324 
325 TypeId
327 {
328  static TypeId tid =
329  TypeId("ns3::SatMacLinkTimeTag").SetParent<Tag>().AddConstructor<SatMacLinkTimeTag>();
330  return tid;
331 }
332 
333 TypeId
335 {
336  return GetTypeId();
337 }
338 
339 uint32_t
341 {
342  return sizeof(Time);
343 }
344 
345 void
347 {
348  int64_t senderTimestamp = m_senderLinkTimestamp.GetNanoSeconds();
349  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
350 }
351 
352 void
354 {
355  int64_t senderTimestamp;
356  i.Read((uint8_t*)&senderTimestamp, 8);
357  m_senderLinkTimestamp = NanoSeconds(senderTimestamp);
358 }
359 
360 void
361 SatMacLinkTimeTag::Print(std::ostream& os) const
362 {
363  os << m_senderLinkTimestamp;
364 }
365 
366 Time
368 {
369  return m_senderLinkTimestamp;
370 }
371 
372 void
374 {
375  this->m_senderLinkTimestamp = senderLinkTimestamp;
376 }
377 
378 // DEV ////////////////////////////////////////////////////////////////////////
379 
380 NS_OBJECT_ENSURE_REGISTERED(SatDevTimeTag);
381 
383  : m_senderTimestamp(Seconds(0))
384 {
385  // Nothing to do here
386 }
387 
388 SatDevTimeTag::SatDevTimeTag(Time senderTimestamp)
389  : m_senderTimestamp(senderTimestamp)
390 {
391  // Nothing to do here
392 }
393 
394 TypeId
396 {
397  static TypeId tid =
398  TypeId("ns3::SatDevTimeTag").SetParent<Tag>().AddConstructor<SatDevTimeTag>();
399  return tid;
400 }
401 
402 TypeId
404 {
405  return GetTypeId();
406 }
407 
408 uint32_t
410 {
411  return sizeof(Time);
412 }
413 
414 void
415 SatDevTimeTag::Serialize(TagBuffer i) const
416 {
417  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
418  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
419 }
420 
421 void
423 {
424  int64_t senderTimestamp;
425  i.Read((uint8_t*)&senderTimestamp, 8);
426  m_senderTimestamp = NanoSeconds(senderTimestamp);
427 }
428 
429 void
430 SatDevTimeTag::Print(std::ostream& os) const
431 {
432  os << m_senderTimestamp;
433 }
434 
435 Time
437 {
438  return m_senderTimestamp;
439 }
440 
441 void
443 {
444  this->m_senderTimestamp = senderTimestamp;
445 }
446 
447 // DEV LINK ////////////////////////////////////////////////////////////////////////
448 
449 NS_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 
463 TypeId
465 {
466  static TypeId tid =
467  TypeId("ns3::SatDevLinkTimeTag").SetParent<Tag>().AddConstructor<SatDevLinkTimeTag>();
468  return tid;
469 }
470 
471 TypeId
473 {
474  return GetTypeId();
475 }
476 
477 uint32_t
479 {
480  return sizeof(Time);
481 }
482 
483 void
485 {
486  int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds();
487  i.Write((const uint8_t*)&senderTimestamp, sizeof(int64_t));
488 }
489 
490 void
492 {
493  int64_t senderTimestamp;
494  i.Read((uint8_t*)&senderTimestamp, 8);
495  m_senderTimestamp = NanoSeconds(senderTimestamp);
496 }
497 
498 void
499 SatDevLinkTimeTag::Print(std::ostream& os) const
500 {
501  os << m_senderTimestamp;
502 }
503 
504 Time
506 {
507  return m_senderTimestamp;
508 }
509 
510 void
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.
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.