A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
seq-ts-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#include "
seq-ts-header.h
"
21
22
#include "ns3/assert.h"
23
#include "ns3/header.h"
24
#include "ns3/log.h"
25
#include "ns3/simulator.h"
26
27
namespace
ns3
28
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"SeqTsHeader"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(SeqTsHeader);
33
34
SeqTsHeader::SeqTsHeader
()
35
: m_seq(0),
36
m_ts(
Simulator
::
Now
().GetTimeStep())
37
{
38
NS_LOG_FUNCTION
(
this
);
39
}
40
41
void
42
SeqTsHeader::SetSeq
(uint32_t seq)
43
{
44
NS_LOG_FUNCTION
(
this
<< seq);
45
m_seq
= seq;
46
}
47
48
uint32_t
49
SeqTsHeader::GetSeq
()
const
50
{
51
NS_LOG_FUNCTION
(
this
);
52
return
m_seq
;
53
}
54
55
Time
56
SeqTsHeader::GetTs
()
const
57
{
58
NS_LOG_FUNCTION
(
this
);
59
return
TimeStep(
m_ts
);
60
}
61
62
TypeId
63
SeqTsHeader::GetTypeId
()
64
{
65
static
TypeId
tid =
TypeId
(
"ns3::SeqTsHeader"
)
66
.
SetParent
<
Header
>()
67
.SetGroupName(
"Applications"
)
68
.AddConstructor<
SeqTsHeader
>();
69
return
tid;
70
}
71
72
TypeId
73
SeqTsHeader::GetInstanceTypeId
()
const
74
{
75
return
GetTypeId
();
76
}
77
78
void
79
SeqTsHeader::Print
(std::ostream& os)
const
80
{
81
NS_LOG_FUNCTION
(
this
<< &os);
82
os <<
"(seq="
<<
m_seq
<<
" time="
<< TimeStep(
m_ts
).As(
Time::S
) <<
")"
;
83
}
84
85
uint32_t
86
SeqTsHeader::GetSerializedSize
()
const
87
{
88
NS_LOG_FUNCTION
(
this
);
89
return
4 + 8;
90
}
91
92
void
93
SeqTsHeader::Serialize
(
Buffer::Iterator
start
)
const
94
{
95
NS_LOG_FUNCTION
(
this
<< &
start
);
96
Buffer::Iterator
i =
start
;
97
i.
WriteHtonU32
(
m_seq
);
98
i.
WriteHtonU64
(
m_ts
);
99
}
100
101
uint32_t
102
SeqTsHeader::Deserialize
(
Buffer::Iterator
start
)
103
{
104
NS_LOG_FUNCTION
(
this
<< &
start
);
105
Buffer::Iterator
i =
start
;
106
m_seq
= i.
ReadNtohU32
();
107
m_ts
= i.
ReadNtohU64
();
108
return
GetSerializedSize
();
109
}
110
111
}
// 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::SeqTsHeader
Packet header to carry sequence number and timestamp.
Definition:
seq-ts-header.h:45
ns3::SeqTsHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
seq-ts-header.cc:63
ns3::SeqTsHeader::m_ts
uint64_t m_ts
Timestamp.
Definition:
seq-ts-header.h:76
ns3::SeqTsHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
seq-ts-header.cc:93
ns3::SeqTsHeader::m_seq
uint32_t m_seq
Sequence number.
Definition:
seq-ts-header.h:75
ns3::SeqTsHeader::Print
void Print(std::ostream &os) const override
Definition:
seq-ts-header.cc:79
ns3::SeqTsHeader::SeqTsHeader
SeqTsHeader()
Definition:
seq-ts-header.cc:34
ns3::SeqTsHeader::SetSeq
void SetSeq(uint32_t seq)
Definition:
seq-ts-header.cc:42
ns3::SeqTsHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
seq-ts-header.cc:73
ns3::SeqTsHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
seq-ts-header.cc:86
ns3::SeqTsHeader::GetTs
Time GetTs() const
Definition:
seq-ts-header.cc:56
ns3::SeqTsHeader::GetSeq
uint32_t GetSeq() const
Definition:
seq-ts-header.cc:49
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::S
@ S
second
Definition:
nstime.h:116
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
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-header.h
src
applications
model
seq-ts-header.cc
Generated on Sun Mar 3 2024 17:10:54 for ns-3 by
1.9.1