A Discrete-Event Network Simulator
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
27namespace ns3
28{
29
30NS_LOG_COMPONENT_DEFINE("SeqTsHeader");
31
33
35 : m_seq(0),
36 m_ts(Simulator::Now().GetTimeStep())
37{
38 NS_LOG_FUNCTION(this);
39}
40
41void
43{
44 NS_LOG_FUNCTION(this << seq);
45 m_seq = seq;
46}
47
50{
51 NS_LOG_FUNCTION(this);
52 return m_seq;
53}
54
55Time
57{
58 NS_LOG_FUNCTION(this);
59 return TimeStep(m_ts);
60}
61
64{
65 static TypeId tid = TypeId("ns3::SeqTsHeader")
67 .SetGroupName("Applications")
68 .AddConstructor<SeqTsHeader>();
69 return tid;
70}
71
74{
75 return GetTypeId();
76}
77
78void
79SeqTsHeader::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
87{
88 NS_LOG_FUNCTION(this);
89 return 4 + 8;
90}
91
92void
94{
95 NS_LOG_FUNCTION(this << &start);
99}
100
103{
104 NS_LOG_FUNCTION(this << &start);
106 m_seq = i.ReadNtohU32();
107 m_ts = i.ReadNtohU64();
108 return GetSerializedSize();
109}
110
111} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:937
uint64_t ReadNtohU64()
Definition: buffer.cc:1044
uint32_t ReadNtohU32()
Definition: buffer.h:978
void WriteHtonU32(uint32_t data)
Definition: buffer.h:933
Protocol header serialization and deserialization.
Definition: header.h:44
Packet header to carry sequence number and timestamp.
Definition: seq-ts-header.h:45
static TypeId GetTypeId()
Get the type ID.
uint64_t m_ts
Timestamp.
Definition: seq-ts-header.h:76
void Serialize(Buffer::Iterator start) const override
uint32_t m_seq
Sequence number.
Definition: seq-ts-header.h:75
void Print(std::ostream &os) const override
void SetSeq(uint32_t seq)
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
Time GetTs() const
uint32_t GetSeq() const
Control the scheduling of simulation events.
Definition: simulator.h:68
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
@ S
second
Definition: nstime.h:116
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1864