A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 INRIA
4
* Copyright (c) 2016 Universita' di Firenze (added echo fields)
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
20
*/
21
22
#include "ns3/assert.h"
23
#include "ns3/log.h"
24
#include "ns3/header.h"
25
#include "ns3/simulator.h"
26
#include "
seq-ts-echo-header.h
"
27
28
namespace
ns3
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"SeqTsEchoHeader"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(SeqTsEchoHeader);
33
34
SeqTsEchoHeader::SeqTsEchoHeader
()
35
: m_seq (0),
36
m_tsValue (
Simulator
::
Now
()),
37
m_tsEchoReply (
Seconds
(0))
38
{
39
NS_LOG_FUNCTION
(
this
);
40
}
41
42
void
43
SeqTsEchoHeader::SetSeq
(uint32_t seq)
44
{
45
NS_LOG_FUNCTION
(
this
<< seq);
46
m_seq
= seq;
47
}
48
49
uint32_t
50
SeqTsEchoHeader::GetSeq
(
void
)
const
51
{
52
NS_LOG_FUNCTION
(
this
);
53
return
m_seq
;
54
}
55
56
void
57
SeqTsEchoHeader::SetTsValue
(
Time
ts)
58
{
59
NS_LOG_FUNCTION
(
this
<< ts);
60
m_tsValue
= ts;
61
}
62
63
Time
64
SeqTsEchoHeader::GetTsValue
(
void
)
const
65
{
66
NS_LOG_FUNCTION
(
this
);
67
return
m_tsValue
;
68
}
69
70
void
71
SeqTsEchoHeader::SetTsEchoReply
(
Time
ts)
72
{
73
NS_LOG_FUNCTION
(
this
<< ts);
74
m_tsEchoReply
= ts;
75
}
76
77
Time
78
SeqTsEchoHeader::GetTsEchoReply
(
void
)
const
79
{
80
NS_LOG_FUNCTION
(
this
);
81
return
m_tsEchoReply
;
82
}
83
84
TypeId
85
SeqTsEchoHeader::GetTypeId
(
void
)
86
{
87
static
TypeId
tid =
TypeId
(
"ns3::SeqTsEchoHeader"
)
88
.
SetParent
<
Header
> ()
89
.SetGroupName (
"Applications"
)
90
.AddConstructor<
SeqTsEchoHeader
> ()
91
;
92
return
tid;
93
}
94
95
TypeId
96
SeqTsEchoHeader::GetInstanceTypeId
(
void
)
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
) <<
" Rx time="
<<
m_tsEchoReply
.
As
(
Time::S
) <<
")"
;
106
}
107
108
uint32_t
109
SeqTsEchoHeader::GetSerializedSize
(
void
)
const
110
{
111
NS_LOG_FUNCTION
(
this
);
112
return
4+8+8;
113
}
114
115
void
116
SeqTsEchoHeader::Serialize
(
Buffer::Iterator
start
)
const
117
{
118
NS_LOG_FUNCTION
(
this
<< &
start
);
119
Buffer::Iterator
i =
start
;
120
i.
WriteHtonU32
(
m_seq
);
121
i.
WriteHtonU64
(
m_tsValue
.
GetTimeStep
());
122
i.
WriteHtonU64
(
m_tsEchoReply
.
GetTimeStep
());
123
}
124
125
uint32_t
126
SeqTsEchoHeader::Deserialize
(
Buffer::Iterator
start
)
127
{
128
NS_LOG_FUNCTION
(
this
<< &
start
);
129
Buffer::Iterator
i =
start
;
130
m_seq
= i.
ReadNtohU32
();
131
m_tsValue
= TimeStep (i.
ReadNtohU64
());
132
m_tsEchoReply
= TimeStep (i.
ReadNtohU64
());
133
return
GetSerializedSize
();
134
}
135
136
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition:
buffer.cc:941
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64(void)
Definition:
buffer.cc:1044
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition:
buffer.h:924
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32(void)
Definition:
buffer.h:970
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:43
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::GetTsValue
Time GetTsValue(void) const
Definition:
seq-ts-echo-header.cc:64
ns3::SeqTsEchoHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const override
Get the most derived TypeId for this Object.
Definition:
seq-ts-echo-header.cc:96
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:57
ns3::SeqTsEchoHeader::m_seq
uint32_t m_seq
Sequence number.
Definition:
seq-ts-echo-header.h:92
ns3::SeqTsEchoHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const override
Definition:
seq-ts-echo-header.cc:109
ns3::SeqTsEchoHeader::SetSeq
void SetSeq(uint32_t seq)
Definition:
seq-ts-echo-header.cc:43
ns3::SeqTsEchoHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const override
Definition:
seq-ts-echo-header.cc:116
ns3::SeqTsEchoHeader::GetTsEchoReply
Time GetTsEchoReply(void) const
Definition:
seq-ts-echo-header.cc:78
ns3::SeqTsEchoHeader::SeqTsEchoHeader
SeqTsEchoHeader()
constructor
Definition:
seq-ts-echo-header.cc:34
ns3::SeqTsEchoHeader::GetSeq
uint32_t GetSeq(void) const
Definition:
seq-ts-echo-header.cc:50
ns3::SeqTsEchoHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
seq-ts-echo-header.cc:85
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:71
ns3::SeqTsEchoHeader::Print
virtual 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:69
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:103
ns3::Time::GetTimeStep
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Definition:
nstime.h:415
ns3::Time::S
@ S
second
Definition:
nstime.h:114
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition:
time.cc:418
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:922
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
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:244
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:287
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1244
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
visualizer.core.start
def start()
Definition:
core.py:1853
seq-ts-echo-header.h
src
applications
model
seq-ts-echo-header.cc
Generated on Tue Feb 6 2024 19:21:15 for ns-3 by
1.9.1