A Discrete-Event Network Simulator
API
seq-ts-size-header.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 INRIA
3  * Copyright (c) 2018 Natale Patriciello <natale.patriciello@gmail.com>
4  * (added timestamp and size fields)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  */
20 
21 #include "seq-ts-size-header.h"
22 
23 #include "ns3/log.h"
24 
25 namespace ns3
26 {
27 
28 NS_LOG_COMPONENT_DEFINE("SeqTsSizeHeader");
29 
30 NS_OBJECT_ENSURE_REGISTERED(SeqTsSizeHeader);
31 
33  : SeqTsHeader()
34 {
35  NS_LOG_FUNCTION(this);
36 }
37 
38 TypeId
40 {
41  static TypeId tid = TypeId("ns3::SeqTsSizeHeader")
43  .SetGroupName("Applications")
44  .AddConstructor<SeqTsSizeHeader>();
45  return tid;
46 }
47 
48 TypeId
50 {
51  return GetTypeId();
52 }
53 
54 void
56 {
57  m_size = size;
58 }
59 
60 uint64_t
62 {
63  return m_size;
64 }
65 
66 void
67 SeqTsSizeHeader::Print(std::ostream& os) const
68 {
69  NS_LOG_FUNCTION(this << &os);
70  os << "(size=" << m_size << ") AND ";
72 }
73 
74 uint32_t
76 {
77  return SeqTsHeader::GetSerializedSize() + 8;
78 }
79 
80 void
82 {
83  NS_LOG_FUNCTION(this << &start);
87 }
88 
89 uint32_t
91 {
92  NS_LOG_FUNCTION(this << &start);
94  m_size = i.ReadNtohU64();
96  return GetSerializedSize();
97 }
98 
99 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:934
uint64_t ReadNtohU64()
Definition: buffer.cc:1041
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Packet header to carry sequence number and timestamp.
Definition: seq-ts-header.h:45
void Serialize(Buffer::Iterator start) const override
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
Header with a sequence, a timestamp, and a "size" attribute.
uint32_t GetSerializedSize() const override
uint64_t GetSize() const
Get the size information that the header is carrying.
void Print(std::ostream &os) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void Serialize(Buffer::Iterator start) const override
void SetSize(uint64_t size)
Set the size information that the header will carry.
uint64_t m_size
The 'size' information that the header is carrying.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.