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
28
29void
31{
32 NS_LOG_FUNCTION(this << seq);
33 m_seq = seq;
34}
35
38{
39 NS_LOG_FUNCTION(this);
40 return m_seq;
41}
42
43Time
45{
46 NS_LOG_FUNCTION(this);
47 return m_ts;
48}
49
52{
53 static TypeId tid = TypeId("ns3::SeqTsHeader")
55 .SetGroupName("Applications")
56 .AddConstructor<SeqTsHeader>();
57 return tid;
58}
59
62{
63 return GetTypeId();
64}
65
66void
67SeqTsHeader::Print(std::ostream& os) const
68{
69 NS_LOG_FUNCTION(this << &os);
70 os << "(seq=" << m_seq << " time=" << m_ts.As(Time::S) << ")";
71}
72
75{
76 NS_LOG_FUNCTION(this);
77 return 4 + 8;
78}
79
80void
82{
83 NS_LOG_FUNCTION(this << &start);
84 Buffer::Iterator i = start;
86 i.WriteHtonU64(m_ts.GetTimeStep());
87}
88
91{
92 NS_LOG_FUNCTION(this << &start);
93 Buffer::Iterator i = start;
94 m_seq = i.ReadNtohU32();
96 return GetSerializedSize();
97}
98
99} // 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.
void Serialize(Buffer::Iterator start) const override
uint32_t m_seq
Sequence number.
void Print(std::ostream &os) const override
Time m_ts
Timestamp.
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:96
Time TimeStep(uint64_t ts)
Scheduler interface.
Definition nstime.h:1451
@ S
second
Definition nstime.h:107
a unique identifier for an interface.
Definition type-id.h:49
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.