A Discrete-Event Network Simulator
API
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
27namespace ns3 {
28
29NS_LOG_COMPONENT_DEFINE ("SeqTsHeader");
30
31NS_OBJECT_ENSURE_REGISTERED (SeqTsHeader);
32
34 : m_seq (0),
35 m_ts (Simulator::Now ().GetTimeStep ())
36{
37 NS_LOG_FUNCTION (this);
38}
39
40void
42{
43 NS_LOG_FUNCTION (this << seq);
44 m_seq = seq;
45}
48{
49 NS_LOG_FUNCTION (this);
50 return m_seq;
51}
52
53Time
55{
56 NS_LOG_FUNCTION (this);
57 return TimeStep (m_ts);
58}
59
62{
63 static TypeId tid = TypeId ("ns3::SeqTsHeader")
64 .SetParent<Header> ()
65 .SetGroupName("Applications")
66 .AddConstructor<SeqTsHeader> ()
67 ;
68 return tid;
69}
72{
73 return GetTypeId ();
74}
75void
76SeqTsHeader::Print (std::ostream &os) const
77{
78 NS_LOG_FUNCTION (this << &os);
79 os << "(seq=" << m_seq << " time=" << TimeStep (m_ts).As (Time::S) << ")";
80}
83{
84 NS_LOG_FUNCTION (this);
85 return 4+8;
86}
87
88void
90{
91 NS_LOG_FUNCTION (this << &start);
95}
98{
99 NS_LOG_FUNCTION (this << &start);
101 m_seq = i.ReadNtohU32 ();
102 m_ts = i.ReadNtohU64 ();
103 return GetSerializedSize ();
104}
105
106} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:941
uint64_t ReadNtohU64(void)
Definition: buffer.cc:1044
void WriteHtonU32(uint32_t data)
Definition: buffer.h:924
uint32_t ReadNtohU32(void)
Definition: buffer.h:970
Protocol header serialization and deserialization.
Definition: header.h:43
Packet header to carry sequence number and timestamp.
Definition: seq-ts-header.h:45
uint64_t m_ts
Timestamp.
Definition: seq-ts-header.h:76
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint32_t m_seq
Sequence number.
Definition: seq-ts-header.h:75
virtual uint32_t Deserialize(Buffer::Iterator start)
void SetSeq(uint32_t seq)
uint32_t GetSeq(void) const
static TypeId GetTypeId(void)
Get the type ID.
Time GetTs(void) const
virtual void Serialize(Buffer::Iterator start) const
virtual uint32_t GetSerializedSize(void) const
virtual void Print(std::ostream &os) const
Control the scheduling of simulation events.
Definition: simulator.h:69
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
@ S
second
Definition: nstime.h:114
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853