A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
26namespace ns3
27{
28
29NS_OBJECT_ENSURE_REGISTERED(TimestampTag);
30
32
34 : m_timestamp(timestamp)
35{
36}
37
40{
41 static TypeId tid = TypeId("ns3::TimestampTag")
42 .SetParent<Tag>()
43 .SetGroupName("Network")
44 .AddConstructor<TimestampTag>();
45 return tid;
46}
47
50{
51 return GetTypeId();
52}
53
56{
57 return 8;
58}
59
60void
62{
64}
65
66void
68{
69 m_timestamp = TimeStep(i.ReadU64());
70}
71
72void
73TimestampTag::Print(std::ostream& os) const
74{
75 os << "timestamp=" << m_timestamp.As(Time::S);
76}
77
78Time
80{
81 return m_timestamp;
82}
83
84void
86{
87 m_timestamp = timestamp;
88}
89
90} // namespace ns3
read and write tag data
Definition: tag-buffer.h:52
void WriteU64(uint64_t v)
Definition: tag-buffer.cc:104
uint64_t ReadU64()
Definition: tag-buffer.cc:139
tag a set of bytes in a packet
Definition: tag.h:39
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
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
@ S
second
Definition: nstime.h:116
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:445
Timestamp tag for associating a timestamp with a packet.
Definition: timestamp-tag.h:39
void Deserialize(TagBuffer i) override
Time m_timestamp
Timestamp.
Definition: timestamp-tag.h:77
void SetTimestamp(Time timestamp)
Set the Timestamp object.
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
static TypeId GetTypeId()
Get the type ID.
void Serialize(TagBuffer i) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
TimestampTag()
Construct a new TimestampTag object.
Time GetTimestamp() const
Get the Timestamp object.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.