A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
timestamp-tag.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Authors: Joe Kopena <tjkopena@cs.drexel.edu>
16
*/
17
18
#include "
timestamp-tag.h
"
19
20
#include "ns3/nstime.h"
21
#include "ns3/tag-buffer.h"
22
#include "ns3/tag.h"
23
#include "ns3/type-id.h"
24
#include "ns3/uinteger.h"
25
26
namespace
ns3
27
{
28
29
NS_OBJECT_ENSURE_REGISTERED
(TimestampTag);
30
31
TimestampTag::TimestampTag
() =
default
;
32
33
TimestampTag::TimestampTag
(
Time
timestamp)
34
: m_timestamp(timestamp)
35
{
36
}
37
38
TypeId
39
TimestampTag::GetTypeId
()
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::TimestampTag"
)
42
.
SetParent
<
Tag
>()
43
.SetGroupName(
"Network"
)
44
.AddConstructor<
TimestampTag
>();
45
return
tid;
46
}
47
48
TypeId
49
TimestampTag::GetInstanceTypeId
()
const
50
{
51
return
GetTypeId
();
52
}
53
54
uint32_t
55
TimestampTag::GetSerializedSize
()
const
56
{
57
return
8;
58
}
59
60
void
61
TimestampTag::Serialize
(
TagBuffer
i)
const
62
{
63
i.
WriteU64
(
m_timestamp
.
GetTimeStep
());
64
}
65
66
void
67
TimestampTag::Deserialize
(
TagBuffer
i)
68
{
69
m_timestamp
= TimeStep(i.
ReadU64
());
70
}
71
72
void
73
TimestampTag::Print
(std::ostream& os)
const
74
{
75
os <<
"timestamp="
<<
m_timestamp
.
As
(
Time::S
);
76
}
77
78
Time
79
TimestampTag::GetTimestamp
()
const
80
{
81
return
m_timestamp
;
82
}
83
84
void
85
TimestampTag::SetTimestamp
(
Time
timestamp)
86
{
87
m_timestamp
= timestamp;
88
}
89
90
}
// namespace ns3
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::TagBuffer::WriteU64
void WriteU64(uint64_t v)
Definition:
tag-buffer.cc:104
ns3::TagBuffer::ReadU64
uint64_t ReadU64()
Definition:
tag-buffer.cc:139
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:39
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
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:415
ns3::Time::S
@ S
second
Definition:
nstime.h:116
ns3::Time::GetTimeStep
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
Definition:
nstime.h:445
ns3::TimestampTag
Timestamp tag for associating a timestamp with a packet.
Definition:
timestamp-tag.h:39
ns3::TimestampTag::Deserialize
void Deserialize(TagBuffer i) override
Definition:
timestamp-tag.cc:67
ns3::TimestampTag::m_timestamp
Time m_timestamp
Timestamp.
Definition:
timestamp-tag.h:77
ns3::TimestampTag::SetTimestamp
void SetTimestamp(Time timestamp)
Set the Timestamp object.
Definition:
timestamp-tag.cc:85
ns3::TimestampTag::Print
void Print(std::ostream &os) const override
Definition:
timestamp-tag.cc:73
ns3::TimestampTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
timestamp-tag.cc:55
ns3::TimestampTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
timestamp-tag.cc:39
ns3::TimestampTag::Serialize
void Serialize(TagBuffer i) const override
Definition:
timestamp-tag.cc:61
ns3::TimestampTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
timestamp-tag.cc:49
ns3::TimestampTag::TimestampTag
TimestampTag()
Construct a new TimestampTag object.
ns3::TimestampTag::GetTimestamp
Time GetTimestamp() const
Get the Timestamp object.
Definition:
timestamp-tag.cc:79
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
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 Sun Mar 3 2024 17:11:06 for ns-3 by
1.9.1