A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
trailer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#ifndef TRAILER_H
10
#define TRAILER_H
11
12
#include "
buffer.h
"
13
#include "
chunk.h
"
14
15
#include <stdint.h>
16
17
namespace
ns3
18
{
19
20
/**
21
* \ingroup packet
22
*
23
* \brief Protocol trailer serialization and deserialization.
24
*
25
* Every Protocol trailer which needs to be inserted or removed
26
* from a Packet instance must derive from this base class and
27
* implement the pure virtual methods defined here.
28
*/
29
class
Trailer
:
public
Chunk
30
{
31
public
:
32
/**
33
* \brief Get the type ID.
34
* \return the object TypeId
35
*/
36
static
TypeId
GetTypeId
();
37
~Trailer
()
override
;
38
/**
39
* \returns the expected size of the trailer.
40
*
41
* This method is used by Packet::AddTrailer
42
* to store a trailer into the byte buffer of a packet. This method
43
* should return the number of bytes which are needed to store
44
* the full trailer data by Serialize.
45
*/
46
virtual
uint32_t
GetSerializedSize
()
const
= 0;
47
/**
48
* \param start an iterator which points to where the trailer
49
* should be written.
50
*
51
* This method is used by Packet::AddTrailer to
52
* store a header into the byte buffer of a packet.
53
* The data written is expected to match bit-for-bit the
54
* representation of this trailer in real networks.
55
* The input iterator points to the end of the area where the
56
* data shall be written. This method is thus expected to call
57
* Buffer::Iterator::Prev prior to actually writing any data.
58
*/
59
virtual
void
Serialize
(
Buffer::Iterator
start)
const
= 0;
60
/**
61
* \param end an iterator which points to the end of the buffer
62
* where the trailer should be read from.
63
* \returns the number of bytes read.
64
*
65
* This method is used by Packet::RemoveTrailer to
66
* re-create a trailer from the byte buffer of a packet.
67
* The data read is expected to match bit-for-bit the
68
* representation of this trailer in real networks.
69
* The input iterator points to the end of the area where the
70
* data shall be read from. This method is thus expected to call
71
* Buffer::Iterator::Prev prior to actually reading any data.
72
*/
73
uint32_t
Deserialize
(
Buffer::Iterator
end)
override
= 0;
74
/**
75
* \param start an iterator which points to the start of the buffer
76
* where the trailer should be read from.
77
* \param end an iterator which points to the end of the buffer
78
* where the trailer should be read from.
79
* \returns the number of bytes read.
80
*
81
* This method is used by Packet::RemoveTrailer to
82
* re-create a trailer from the byte buffer of a packet.
83
* The data read is expected to match bit-for-bit the
84
* representation of this trailer in real networks.
85
* The input iterator end points to the end of the area where the
86
* data shall be read from.
87
*
88
* This variant should be provided by any variable-sized trailer subclass
89
* (i.e. if GetSerializedSize () does not return a constant).
90
*/
91
uint32_t
Deserialize
(
Buffer::Iterator
start,
Buffer::Iterator
end)
override
;
92
/**
93
* \param os output stream
94
* This method is used by Packet::Print to print the
95
* content of a trailer as ascii data to a c++ output stream.
96
* Although the trailer is free to format its output as it
97
* wishes, it is recommended to follow a few rules to integrate
98
* with the packet pretty printer: start with flags, small field
99
* values located between a pair of parens. Values should be separated
100
* by whitespace. Follow the parens with the important fields,
101
* separated by whitespace.
102
* i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5
103
*/
104
void
Print
(std::ostream& os)
const override
= 0;
105
};
106
107
/**
108
* \brief Stream insertion operator.
109
*
110
* \param os the stream
111
* \param trailer the trailer
112
* \returns a reference to the stream
113
*/
114
std::ostream&
operator<<
(std::ostream& os,
const
Trailer
& trailer);
115
116
}
// namespace ns3
117
118
#endif
/* TRAILER_H */
buffer.h
chunk.h
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Chunk
abstract base class for ns3::Header and ns3::Trailer
Definition
chunk.h:25
ns3::Trailer
Protocol trailer serialization and deserialization.
Definition
trailer.h:30
ns3::Trailer::~Trailer
~Trailer() override
Definition
trailer.cc:20
ns3::Trailer::Serialize
virtual void Serialize(Buffer::Iterator start) const =0
ns3::Trailer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
trailer.cc:26
ns3::Trailer::Print
void Print(std::ostream &os) const override=0
ns3::Trailer::Deserialize
uint32_t Deserialize(Buffer::Iterator end) override=0
ns3::Trailer::GetSerializedSize
virtual uint32_t GetSerializedSize() const =0
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
network
model
trailer.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0