A Discrete-Event Network Simulator
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
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("SeqTsHeader");
20
22
24 : m_seq(0),
25 m_ts(Simulator::Now().GetTimeStep())
26{
27 NS_LOG_FUNCTION(this);
28}
29
30void
32{
33 NS_LOG_FUNCTION(this << seq);
34 m_seq = seq;
35}
36
39{
40 NS_LOG_FUNCTION(this);
41 return m_seq;
42}
43
44Time
46{
47 NS_LOG_FUNCTION(this);
48 return TimeStep(m_ts);
49}
50
53{
54 static TypeId tid = TypeId("ns3::SeqTsHeader")
56 .SetGroupName("Applications")
57 .AddConstructor<SeqTsHeader>();
58 return tid;
59}
60
63{
64 return GetTypeId();
65}
66
67void
68SeqTsHeader::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
76{
77 NS_LOG_FUNCTION(this);
78 return 4 + 8;
79}
80
81void
83{
84 NS_LOG_FUNCTION(this << &start);
85 Buffer::Iterator i = start;
88}
89
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
iterator in a Buffer instance
Definition buffer.h:89
void WriteHtonU64(uint64_t data)
Definition buffer.cc:923
uint64_t ReadNtohU64()
Definition buffer.cc:1030
uint32_t ReadNtohU32()
Definition buffer.h:967
void WriteHtonU32(uint32_t data)
Definition buffer.h:922
Protocol header serialization and deserialization.
Definition header.h:33
Packet header to carry sequence number and timestamp.
static TypeId GetTypeId()
Get the type ID.
uint64_t m_ts
Timestamp.
void Serialize(Buffer::Iterator start) const override
uint32_t m_seq
Sequence number.
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:57
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
@ S
second
Definition nstime.h:105
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition simulator.cc:294
Every class exported by the ns3 library is enclosed in the ns3 namespace.