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_seq(0),
26
m_tsValue(
Simulator
::
Now
()),
27
m_tsEchoReply(
Seconds
(0))
28
{
29
NS_LOG_FUNCTION
(
this
);
30
}
31
32
void
33
SeqTsEchoHeader::SetSeq
(
uint32_t
seq)
34
{
35
NS_LOG_FUNCTION
(
this
<< seq);
36
m_seq
= seq;
37
}
38
39
uint32_t
40
SeqTsEchoHeader::GetSeq
()
const
41
{
42
NS_LOG_FUNCTION
(
this
);
43
return
m_seq
;
44
}
45
46
void
47
SeqTsEchoHeader::SetTsValue
(
Time
ts)
48
{
49
NS_LOG_FUNCTION
(
this
<< ts);
50
m_tsValue
= ts;
51
}
52
53
Time
54
SeqTsEchoHeader::GetTsValue
()
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
return
m_tsValue
;
58
}
59
60
void
61
SeqTsEchoHeader::SetTsEchoReply
(
Time
ts)
62
{
63
NS_LOG_FUNCTION
(
this
<< ts);
64
m_tsEchoReply
= ts;
65
}
66
67
Time
68
SeqTsEchoHeader::GetTsEchoReply
()
const
69
{
70
NS_LOG_FUNCTION
(
this
);
71
return
m_tsEchoReply
;
72
}
73
74
TypeId
75
SeqTsEchoHeader::GetTypeId
()
76
{
77
static
TypeId
tid =
TypeId
(
"ns3::SeqTsEchoHeader"
)
78
.
SetParent
<
Header
>()
79
.SetGroupName(
"Applications"
)
80
.AddConstructor<
SeqTsEchoHeader
>();
81
return
tid;
82
}
83
84
TypeId
85
SeqTsEchoHeader::GetInstanceTypeId
()
const
86
{
87
return
GetTypeId
();
88
}
89
90
void
91
SeqTsEchoHeader::Print
(std::ostream& os)
const
92
{
93
NS_LOG_FUNCTION
(
this
<< &os);
94
os <<
"(seq="
<<
m_seq
<<
" Tx time="
<<
m_tsValue
.
As
(
Time::S
)
95
<<
" Rx time="
<<
m_tsEchoReply
.
As
(
Time::S
) <<
")"
;
96
}
97
98
uint32_t
99
SeqTsEchoHeader::GetSerializedSize
()
const
100
{
101
NS_LOG_FUNCTION
(
this
);
102
return
4 + 8 + 8;
103
}
104
105
void
106
SeqTsEchoHeader::Serialize
(
Buffer::Iterator
start)
const
107
{
108
NS_LOG_FUNCTION
(
this
<< &start);
109
Buffer::Iterator
i = start;
110
i.
WriteHtonU32
(
m_seq
);
111
i.
WriteHtonU64
(
m_tsValue
.
GetTimeStep
());
112
i.
WriteHtonU64
(
m_tsEchoReply
.
GetTimeStep
());
113
}
114
115
uint32_t
116
SeqTsEchoHeader::Deserialize
(
Buffer::Iterator
start)
117
{
118
NS_LOG_FUNCTION
(
this
<< &start);
119
Buffer::Iterator
i = start;
120
m_seq
= i.
ReadNtohU32
();
121
m_tsValue
= TimeStep(i.
ReadNtohU64
());
122
m_tsEchoReply
= TimeStep(i.
ReadNtohU64
());
123
return
GetSerializedSize
();
124
}
125
126
}
// 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:68
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:47
ns3::SeqTsEchoHeader::GetTsValue
Time GetTsValue() const
Definition
seq-ts-echo-header.cc:54
ns3::SeqTsEchoHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
seq-ts-echo-header.cc:99
ns3::SeqTsEchoHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
seq-ts-echo-header.cc:85
ns3::SeqTsEchoHeader::GetSeq
uint32_t GetSeq() const
Definition
seq-ts-echo-header.cc:40
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:33
ns3::SeqTsEchoHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
seq-ts-echo-header.cc:106
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:75
ns3::SeqTsEchoHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
seq-ts-echo-header.cc:116
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:61
ns3::SeqTsEchoHeader::Print
void Print(std::ostream &os) const override
Definition
seq-ts-echo-header.cc:91
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: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::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_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:229
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::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
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 Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0