A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
timestamp-tag.cc
Go to the documentation of this file.
1
/*
2
* SPDX-License-Identifier: GPL-2.0-only
3
*
4
* Authors: Joe Kopena <tjkopena@cs.drexel.edu>
5
*/
6
7
#include "
timestamp-tag.h
"
8
9
#include "ns3/nstime.h"
10
#include "ns3/tag-buffer.h"
11
#include "ns3/tag.h"
12
#include "ns3/type-id.h"
13
#include "ns3/uinteger.h"
14
15
namespace
ns3
16
{
17
18
NS_OBJECT_ENSURE_REGISTERED
(TimestampTag);
19
20
TimestampTag::TimestampTag
() =
default
;
21
22
TimestampTag::TimestampTag
(
Time
timestamp)
23
: m_timestamp(timestamp)
24
{
25
}
26
27
TypeId
28
TimestampTag::GetTypeId
()
29
{
30
static
TypeId
tid =
TypeId
(
"ns3::TimestampTag"
)
31
.
SetParent
<
Tag
>()
32
.SetGroupName(
"Network"
)
33
.AddConstructor<
TimestampTag
>();
34
return
tid;
35
}
36
37
TypeId
38
TimestampTag::GetInstanceTypeId
()
const
39
{
40
return
GetTypeId
();
41
}
42
43
uint32_t
44
TimestampTag::GetSerializedSize
()
const
45
{
46
return
8;
47
}
48
49
void
50
TimestampTag::Serialize
(
TagBuffer
i)
const
51
{
52
i.
WriteU64
(
m_timestamp
.
GetTimeStep
());
53
}
54
55
void
56
TimestampTag::Deserialize
(
TagBuffer
i)
57
{
58
m_timestamp
= TimeStep(i.
ReadU64
());
59
}
60
61
void
62
TimestampTag::Print
(std::ostream& os)
const
63
{
64
os <<
"timestamp="
<<
m_timestamp
.
As
(
Time::S
);
65
}
66
67
Time
68
TimestampTag::GetTimestamp
()
const
69
{
70
return
m_timestamp
;
71
}
72
73
void
74
TimestampTag::SetTimestamp
(
Time
timestamp)
75
{
76
m_timestamp
= timestamp;
77
}
78
79
}
// namespace ns3
ns3::TagBuffer
read and write tag data
Definition
tag-buffer.h:41
ns3::TagBuffer::WriteU64
void WriteU64(uint64_t v)
Definition
tag-buffer.cc:93
ns3::TagBuffer::ReadU64
uint64_t ReadU64()
Definition
tag-buffer.cc:128
ns3::Tag
tag a set of bytes in a packet
Definition
tag.h:28
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::Time::As
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition
time.cc:404
ns3::Time::S
@ S
second
Definition
nstime.h:105
ns3::Time::GetTimeStep
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
Definition
nstime.h:434
ns3::TimestampTag
Timestamp tag for associating a timestamp with a packet.
Definition
timestamp-tag.h:28
ns3::TimestampTag::Deserialize
void Deserialize(TagBuffer i) override
Definition
timestamp-tag.cc:56
ns3::TimestampTag::m_timestamp
Time m_timestamp
Timestamp.
Definition
timestamp-tag.h:66
ns3::TimestampTag::SetTimestamp
void SetTimestamp(Time timestamp)
Set the Timestamp object.
Definition
timestamp-tag.cc:74
ns3::TimestampTag::Print
void Print(std::ostream &os) const override
Definition
timestamp-tag.cc:62
ns3::TimestampTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
timestamp-tag.cc:44
ns3::TimestampTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
timestamp-tag.cc:28
ns3::TimestampTag::Serialize
void Serialize(TagBuffer i) const override
Definition
timestamp-tag.cc:50
ns3::TimestampTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
timestamp-tag.cc:38
ns3::TimestampTag::TimestampTag
TimestampTag()
Construct a new TimestampTag object.
ns3::TimestampTag::GetTimestamp
Time GetTimestamp() const
Get the Timestamp object.
Definition
timestamp-tag.cc:68
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
timestamp-tag.h
src
network
utils
timestamp-tag.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0