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
seq-ts-echo-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA
3
* Copyright (c) 2016 Universita' di Firenze (added echo fields)
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8
*/
9
10
#include "
seq-ts-echo-header.h
"
11
12
#include "ns3/assert.h"
13
#include "ns3/header.h"
14
#include "ns3/log.h"
15
#include "ns3/simulator.h"
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"SeqTsEchoHeader"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(
SeqTsEchoHeader
);
23
24
SeqTsEchoHeader::SeqTsEchoHeader
()
25
:
m_tsValue
(
Simulator
::
Now
())
26
{
27
NS_LOG_FUNCTION
(
this
);
28
}
29
30
void
31
SeqTsEchoHeader::SetSeq
(
uint32_t
seq)
32
{
33
NS_LOG_FUNCTION
(
this
<< seq);
34
m_seq
= seq;
35
}
36
37
uint32_t
38
SeqTsEchoHeader::GetSeq
()
const
39
{
40
NS_LOG_FUNCTION
(
this
);
41
return
m_seq
;
42
}
43
44
void
45
SeqTsEchoHeader::SetTsValue
(
Time
ts)
46
{
47
NS_LOG_FUNCTION
(
this
<< ts);
48
m_tsValue
= ts;
49
}
50
51
Time
52
SeqTsEchoHeader::GetTsValue
()
const
53
{
54
NS_LOG_FUNCTION
(
this
);
55
return
m_tsValue
;
56
}
57
58
void
59
SeqTsEchoHeader::SetTsEchoReply
(
Time
ts)
60
{
61
NS_LOG_FUNCTION
(
this
<< ts);
62
m_tsEchoReply
= ts;
63
}
64
65
Time
66
SeqTsEchoHeader::GetTsEchoReply
()
const
67
{
68
NS_LOG_FUNCTION
(
this
);
69
return
m_tsEchoReply
;
70
}
71
72
TypeId
73
SeqTsEchoHeader::GetTypeId
()
74
{
75
static
TypeId
tid =
TypeId
(
"ns3::SeqTsEchoHeader"
)
76
.
SetParent
<
Header
>()
77
.SetGroupName(
"Applications"
)
78
.AddConstructor<
SeqTsEchoHeader
>();
79
return
tid;
80
}
81
82
TypeId
83
SeqTsEchoHeader::GetInstanceTypeId
()
const
84
{
85
return
GetTypeId
();
86
}
87
88
void
89
SeqTsEchoHeader::Print
(std::ostream& os)
const
90
{
91
NS_LOG_FUNCTION
(
this
<< &os);
92
os <<
"(seq="
<<
m_seq
<<
" Tx time="
<<
m_tsValue
.As(
Time::S
)
93
<<
" Rx time="
<<
m_tsEchoReply
.As(
Time::S
) <<
")"
;
94
}
95
96
uint32_t
97
SeqTsEchoHeader::GetSerializedSize
()
const
98
{
99
NS_LOG_FUNCTION
(
this
);
100
return
4 + 8 + 8;
101
}
102
103
void
104
SeqTsEchoHeader::Serialize
(
Buffer::Iterator
start)
const
105
{
106
NS_LOG_FUNCTION
(
this
<< &start);
107
Buffer::Iterator
i = start;
108
i.
WriteHtonU32
(
m_seq
);
109
i.
WriteHtonU64
(
m_tsValue
.GetTimeStep());
110
i.
WriteHtonU64
(
m_tsEchoReply
.GetTimeStep());
111
}
112
113
uint32_t
114
SeqTsEchoHeader::Deserialize
(
Buffer::Iterator
start)
115
{
116
NS_LOG_FUNCTION
(
this
<< &start);
117
Buffer::Iterator
i = start;
118
m_seq
= i.
ReadNtohU32
();
119
m_tsValue
=
TimeStep
(i.
ReadNtohU64
());
120
m_tsEchoReply
=
TimeStep
(i.
ReadNtohU64
());
121
return
GetSerializedSize
();
122
}
123
124
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition
buffer.cc:923
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64()
Definition
buffer.cc:1030
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition
buffer.h:967
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition
buffer.h:922
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::SeqTsEchoHeader
Packet header to carry sequence number and two timestamps.
Definition
seq-ts-echo-header.h:27
ns3::SeqTsEchoHeader::GetTsEchoReply
Time GetTsEchoReply() const
Definition
seq-ts-echo-header.cc:66
ns3::SeqTsEchoHeader::m_tsEchoReply
Time m_tsEchoReply
Receiver's timestamp.
Definition
seq-ts-echo-header.h:83
ns3::SeqTsEchoHeader::m_tsValue
Time m_tsValue
Sender's timestamp.
Definition
seq-ts-echo-header.h:82
ns3::SeqTsEchoHeader::SetTsValue
void SetTsValue(Time ts)
Set the sender's time value.
Definition
seq-ts-echo-header.cc:45
ns3::SeqTsEchoHeader::GetTsValue
Time GetTsValue() const
Definition
seq-ts-echo-header.cc:52
ns3::SeqTsEchoHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
seq-ts-echo-header.cc:97
ns3::SeqTsEchoHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
seq-ts-echo-header.cc:83
ns3::SeqTsEchoHeader::GetSeq
uint32_t GetSeq() const
Definition
seq-ts-echo-header.cc:38
ns3::SeqTsEchoHeader::m_seq
uint32_t m_seq
Sequence number.
Definition
seq-ts-echo-header.h:81
ns3::SeqTsEchoHeader::SetSeq
void SetSeq(uint32_t seq)
Definition
seq-ts-echo-header.cc:31
ns3::SeqTsEchoHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
seq-ts-echo-header.cc:104
ns3::SeqTsEchoHeader::SeqTsEchoHeader
SeqTsEchoHeader()
constructor
Definition
seq-ts-echo-header.cc:24
ns3::SeqTsEchoHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
seq-ts-echo-header.cc:73
ns3::SeqTsEchoHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
seq-ts-echo-header.cc:114
ns3::SeqTsEchoHeader::SetTsEchoReply
void SetTsEchoReply(Time ts)
Upon SeqTsEchoHeader reception, the host answers via echoing back the received timestamp.
Definition
seq-ts-echo-header.cc:59
ns3::SeqTsEchoHeader::Print
void Print(std::ostream &os) const override
Definition
seq-ts-echo-header.cc:89
ns3::Simulator
Control the scheduling of simulation events.
Definition
simulator.h:57
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:96
ns3::Time::TimeStep
Time TimeStep(uint64_t ts)
Scheduler interface.
Definition
nstime.h:1451
ns3::Time::S
@ S
second
Definition
nstime.h:107
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:231
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition
simulator.cc:294
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
seq-ts-echo-header.h
src
applications
model
seq-ts-echo-header.cc
Generated on
for ns-3 by
1.15.0