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-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#include "
seq-ts-header.h
"
10
11
#include "ns3/assert.h"
12
#include "ns3/header.h"
13
#include "ns3/log.h"
14
#include "ns3/simulator.h"
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"SeqTsHeader"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(SeqTsHeader);
22
23
SeqTsHeader::SeqTsHeader
()
24
: m_seq(0),
25
m_ts(
Simulator
::
Now
().GetTimeStep())
26
{
27
NS_LOG_FUNCTION
(
this
);
28
}
29
30
void
31
SeqTsHeader::SetSeq
(
uint32_t
seq)
32
{
33
NS_LOG_FUNCTION
(
this
<< seq);
34
m_seq
= seq;
35
}
36
37
uint32_t
38
SeqTsHeader::GetSeq
()
const
39
{
40
NS_LOG_FUNCTION
(
this
);
41
return
m_seq
;
42
}
43
44
Time
45
SeqTsHeader::GetTs
()
const
46
{
47
NS_LOG_FUNCTION
(
this
);
48
return
TimeStep(
m_ts
);
49
}
50
51
TypeId
52
SeqTsHeader::GetTypeId
()
53
{
54
static
TypeId
tid =
TypeId
(
"ns3::SeqTsHeader"
)
55
.
SetParent
<
Header
>()
56
.SetGroupName(
"Applications"
)
57
.AddConstructor<
SeqTsHeader
>();
58
return
tid;
59
}
60
61
TypeId
62
SeqTsHeader::GetInstanceTypeId
()
const
63
{
64
return
GetTypeId
();
65
}
66
67
void
68
SeqTsHeader::Print
(std::ostream& os)
const
69
{
70
NS_LOG_FUNCTION
(
this
<< &os);
71
os <<
"(seq="
<<
m_seq
<<
" time="
<< TimeStep(
m_ts
).As(
Time::S
) <<
")"
;
72
}
73
74
uint32_t
75
SeqTsHeader::GetSerializedSize
()
const
76
{
77
NS_LOG_FUNCTION
(
this
);
78
return
4 + 8;
79
}
80
81
void
82
SeqTsHeader::Serialize
(
Buffer::Iterator
start)
const
83
{
84
NS_LOG_FUNCTION
(
this
<< &start);
85
Buffer::Iterator
i = start;
86
i.
WriteHtonU32
(
m_seq
);
87
i.
WriteHtonU64
(
m_ts
);
88
}
89
90
uint32_t
91
SeqTsHeader::Deserialize
(
Buffer::Iterator
start)
92
{
93
NS_LOG_FUNCTION
(
this
<< &start);
94
Buffer::Iterator
i = start;
95
m_seq
= i.
ReadNtohU32
();
96
m_ts
= i.
ReadNtohU64
();
97
return
GetSerializedSize
();
98
}
99
100
}
// 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::SeqTsHeader
Packet header to carry sequence number and timestamp.
Definition
seq-ts-header.h:34
ns3::SeqTsHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
seq-ts-header.cc:52
ns3::SeqTsHeader::m_ts
uint64_t m_ts
Timestamp.
Definition
seq-ts-header.h:65
ns3::SeqTsHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
seq-ts-header.cc:82
ns3::SeqTsHeader::m_seq
uint32_t m_seq
Sequence number.
Definition
seq-ts-header.h:64
ns3::SeqTsHeader::Print
void Print(std::ostream &os) const override
Definition
seq-ts-header.cc:68
ns3::SeqTsHeader::SeqTsHeader
SeqTsHeader()
Definition
seq-ts-header.cc:23
ns3::SeqTsHeader::SetSeq
void SetSeq(uint32_t seq)
Definition
seq-ts-header.cc:31
ns3::SeqTsHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
seq-ts-header.cc:62
ns3::SeqTsHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
seq-ts-header.cc:75
ns3::SeqTsHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
seq-ts-header.cc:91
ns3::SeqTsHeader::GetTs
Time GetTs() const
Definition
seq-ts-header.cc:45
ns3::SeqTsHeader::GetSeq
uint32_t GetSeq() const
Definition
seq-ts-header.cc:38
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::S
@ S
second
Definition
nstime.h:105
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
seq-ts-header.h
src
applications
model
seq-ts-header.cc
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0