A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
applications
model
seq-ts-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
*
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "ns3/assert.h"
22
#include "ns3/log.h"
23
#include "ns3/header.h"
24
#include "ns3/simulator.h"
25
#include "
seq-ts-header.h
"
26
27
namespace
ns3
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"SeqTsHeader"
);
30
31
NS_OBJECT_ENSURE_REGISTERED
(SeqTsHeader);
32
33
SeqTsHeader::SeqTsHeader
()
34
: m_seq (0),
35
m_ts (
Simulator
::
Now
().GetTimeStep ())
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
void
41
SeqTsHeader::SetSeq
(uint32_t seq)
42
{
43
NS_LOG_FUNCTION
(
this
<< seq);
44
m_seq
= seq;
45
}
46
uint32_t
47
SeqTsHeader::GetSeq
(
void
)
const
48
{
49
NS_LOG_FUNCTION
(
this
);
50
return
m_seq
;
51
}
52
53
Time
54
SeqTsHeader::GetTs
(
void
)
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
return
TimeStep
(
m_ts
);
58
}
59
60
TypeId
61
SeqTsHeader::GetTypeId
(
void
)
62
{
63
static
TypeId
tid =
TypeId
(
"ns3::SeqTsHeader"
)
64
.
SetParent
<
Header
> ()
65
.SetGroupName(
"Applications"
)
66
.AddConstructor<
SeqTsHeader
> ()
67
;
68
return
tid;
69
}
70
TypeId
71
SeqTsHeader::GetInstanceTypeId
(
void
)
const
72
{
73
return
GetTypeId
();
74
}
75
void
76
SeqTsHeader::Print
(std::ostream &os)
const
77
{
78
NS_LOG_FUNCTION
(
this
<< &os);
79
os <<
"(seq="
<<
m_seq
<<
" time="
<<
TimeStep
(
m_ts
).
GetSeconds
() <<
")"
;
80
}
81
uint32_t
82
SeqTsHeader::GetSerializedSize
(
void
)
const
83
{
84
NS_LOG_FUNCTION
(
this
);
85
return
4+8;
86
}
87
88
void
89
SeqTsHeader::Serialize
(
Buffer::Iterator
start
)
const
90
{
91
NS_LOG_FUNCTION
(
this
<< &
start
);
92
Buffer::Iterator
i =
start
;
93
i.
WriteHtonU32
(
m_seq
);
94
i.
WriteHtonU64
(
m_ts
);
95
}
96
uint32_t
97
SeqTsHeader::Deserialize
(
Buffer::Iterator
start
)
98
{
99
NS_LOG_FUNCTION
(
this
<< &
start
);
100
Buffer::Iterator
i =
start
;
101
m_seq
= i.
ReadNtohU32
();
102
m_ts
= i.
ReadNtohU64
();
103
return
GetSerializedSize
();
104
}
105
106
}
// namespace ns3
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition:
buffer.cc:940
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
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:213
ns3::SeqTsHeader::SeqTsHeader
SeqTsHeader()
Definition:
seq-ts-header.cc:33
ns3::Simulator
Control the scheduling of simulation events.
Definition:
simulator.h:68
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition:
nstime.h:355
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64(void)
Definition:
buffer.cc:1043
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32(void)
Definition:
buffer.h:970
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::SeqTsHeader::m_ts
uint64_t m_ts
Timestamp.
Definition:
seq-ts-header.h:68
ns3::SeqTsHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
seq-ts-header.cc:61
ns3::SeqTsHeader
Packet header for UDP client/server application.
Definition:
seq-ts-header.h:36
ns3::SeqTsHeader::GetSeq
uint32_t GetSeq(void) const
Definition:
seq-ts-header.cc:47
ns3::SeqTsHeader::Print
virtual void Print(std::ostream &os) const
Definition:
seq-ts-header.cc:76
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SeqTsHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
seq-ts-header.cc:89
ns3::TimeStep
Time TimeStep(uint64_t ts)
Definition:
nstime.h:1071
seq-ts-header.h
ns3::SeqTsHeader::m_seq
uint32_t m_seq
Sequence number.
Definition:
seq-ts-header.h:67
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition:
buffer.h:924
ns3::SeqTsHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
seq-ts-header.cc:97
ns3::SeqTsHeader::SetSeq
void SetSeq(uint32_t seq)
Definition:
seq-ts-header.cc:41
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:365
ns3::SeqTsHeader::GetTs
Time GetTs(void) const
Definition:
seq-ts-header.cc:54
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:915
ns3::SeqTsHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
seq-ts-header.cc:82
ns3::SeqTsHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
seq-ts-header.cc:71
Generated on Wed Nov 7 2018 10:01:47 for ns-3 by
1.8.14