A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19
*/
20
21
#include "
seq-ts-echo-header.h
"
22
23
#include "ns3/assert.h"
24
#include "ns3/header.h"
25
#include "ns3/log.h"
26
#include "ns3/simulator.h"
27
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"SeqTsEchoHeader"
);
32
33
NS_OBJECT_ENSURE_REGISTERED
(SeqTsEchoHeader);
34
35
SeqTsEchoHeader::SeqTsEchoHeader
()
36
: m_seq(0),
37
m_tsValue(
Simulator
::
Now
()),
38
m_tsEchoReply(
Seconds
(0))
39
{
40
NS_LOG_FUNCTION
(
this
);
41
}
42
43
void
44
SeqTsEchoHeader::SetSeq
(uint32_t seq)
45
{
46
NS_LOG_FUNCTION
(
this
<< seq);
47
m_seq
= seq;
48
}
49
50
uint32_t
51
SeqTsEchoHeader::GetSeq
()
const
52
{
53
NS_LOG_FUNCTION
(
this
);
54
return
m_seq
;
55
}
56
57
void
58
SeqTsEchoHeader::SetTsValue
(
Time
ts)
59
{
60
NS_LOG_FUNCTION
(
this
<< ts);
61
m_tsValue
= ts;
62
}
63
64
Time
65
SeqTsEchoHeader::GetTsValue
()
const
66
{
67
NS_LOG_FUNCTION
(
this
);
68
return
m_tsValue
;
69
}
70
71
void
72
SeqTsEchoHeader::SetTsEchoReply
(
Time
ts)
73
{
74
NS_LOG_FUNCTION
(
this
<< ts);
75
m_tsEchoReply
= ts;
76
}
77
78
Time
79
SeqTsEchoHeader::GetTsEchoReply
()
const
80
{
81
NS_LOG_FUNCTION
(
this
);
82
return
m_tsEchoReply
;
83
}
84
85
TypeId
86
SeqTsEchoHeader::GetTypeId
()
87
{
88
static
TypeId
tid =
TypeId
(
"ns3::SeqTsEchoHeader"
)
89
.
SetParent
<
Header
>()
90
.SetGroupName(
"Applications"
)
91
.AddConstructor<
SeqTsEchoHeader
>();
92
return
tid;
93
}
94
95
TypeId
96
SeqTsEchoHeader::GetInstanceTypeId
()
const
97
{
98
return
GetTypeId
();
99
}
100
101
void
102
SeqTsEchoHeader::Print
(std::ostream& os)
const
103
{
104
NS_LOG_FUNCTION
(
this
<< &os);
105
os <<
"(seq="
<<
m_seq
<<
" Tx time="
<<
m_tsValue
.
As
(
Time::S
)
106
<<
" Rx time="
<<
m_tsEchoReply
.
As
(
Time::S
) <<
")"
;
107
}
108
109
uint32_t
110
SeqTsEchoHeader::GetSerializedSize
()
const
111
{
112
NS_LOG_FUNCTION
(
this
);
113
return
4 + 8 + 8;
114
}
115
116
void
117
SeqTsEchoHeader::Serialize
(
Buffer::Iterator
start
)
const
118
{
119
NS_LOG_FUNCTION
(
this
<< &
start
);
120
Buffer::Iterator
i =
start
;
121
i.
WriteHtonU32
(
m_seq
);
122
i.
WriteHtonU64
(
m_tsValue
.
GetTimeStep
());
123
i.
WriteHtonU64
(
m_tsEchoReply
.
GetTimeStep
());
124
}
125
126
uint32_t
127
SeqTsEchoHeader::Deserialize
(
Buffer::Iterator
start
)
128
{
129
NS_LOG_FUNCTION
(
this
<< &
start
);
130
Buffer::Iterator
i =
start
;
131
m_seq
= i.
ReadNtohU32
();
132
m_tsValue
= TimeStep(i.
ReadNtohU64
());
133
m_tsEchoReply
= TimeStep(i.
ReadNtohU64
());
134
return
GetSerializedSize
();
135
}
136
137
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition:
buffer.cc:934
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64()
Definition:
buffer.cc:1041
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition:
buffer.h:978
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition:
buffer.h:933
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::SeqTsEchoHeader
Packet header to carry sequence number and two timestamps.
Definition:
seq-ts-echo-header.h:38
ns3::SeqTsEchoHeader::GetTsEchoReply
Time GetTsEchoReply() const
Definition:
seq-ts-echo-header.cc:79
ns3::SeqTsEchoHeader::m_tsEchoReply
Time m_tsEchoReply
Receiver's timestamp.
Definition:
seq-ts-echo-header.h:94
ns3::SeqTsEchoHeader::m_tsValue
Time m_tsValue
Sender's timestamp.
Definition:
seq-ts-echo-header.h:93
ns3::SeqTsEchoHeader::SetTsValue
void SetTsValue(Time ts)
Set the sender's time value.
Definition:
seq-ts-echo-header.cc:58
ns3::SeqTsEchoHeader::GetTsValue
Time GetTsValue() const
Definition:
seq-ts-echo-header.cc:65
ns3::SeqTsEchoHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
seq-ts-echo-header.cc:110
ns3::SeqTsEchoHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
seq-ts-echo-header.cc:96
ns3::SeqTsEchoHeader::GetSeq
uint32_t GetSeq() const
Definition:
seq-ts-echo-header.cc:51
ns3::SeqTsEchoHeader::m_seq
uint32_t m_seq
Sequence number.
Definition:
seq-ts-echo-header.h:92
ns3::SeqTsEchoHeader::SetSeq
void SetSeq(uint32_t seq)
Definition:
seq-ts-echo-header.cc:44
ns3::SeqTsEchoHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
seq-ts-echo-header.cc:117
ns3::SeqTsEchoHeader::SeqTsEchoHeader
SeqTsEchoHeader()
constructor
Definition:
seq-ts-echo-header.cc:35
ns3::SeqTsEchoHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
seq-ts-echo-header.cc:86
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:72
ns3::SeqTsEchoHeader::Print
void Print(std::ostream &os) const override
Definition:
seq-ts-echo-header.cc:102
ns3::Simulator
Control the scheduling of simulation events.
Definition:
simulator.h:68
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::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_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:305
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1326
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
seq-ts-echo-header.h
src
applications
model
seq-ts-echo-header.cc
Generated on Sun Mar 3 2024 17:10:54 for ns-3 by
1.9.1