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
dsr-routing-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Yufei Cheng
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Yufei Cheng <yfcheng@ittc.ku.edu>
7
* Modified by: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8
* Lorenzo Bartolini <l.bartolini02@gmail.com>
9
*
10
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
11
* ResiliNets Research Group https://resilinets.org/
12
* Information and Telecommunication Technology Center (ITTC)
13
* and Department of Electrical Engineering and Computer Science
14
* The University of Kansas Lawrence, KS USA.
15
*
16
* Work supported in part by NSF FIND (Future Internet Design) Program
17
* under grant CNS-0626918 (Postmodern Internet Architecture),
18
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
19
* US Department of Defense (DoD), and ITTC at The University of Kansas.
20
*/
21
22
#ifndef DSR_FS_HEADER_H
23
#define DSR_FS_HEADER_H
24
25
#include "
dsr-option-header.h
"
26
27
#include "ns3/header.h"
28
#include "ns3/ipv4-address.h"
29
30
#include <list>
31
#include <ostream>
32
#include <vector>
33
34
namespace
ns3
35
{
36
namespace
dsr
37
{
38
/**
39
* @class DsrRoutingHeader
40
* @brief Header of Dsr Routing
41
*/
42
/**
43
* @ingroup dsr
44
* @brief Dsr fixed size header Format
45
\verbatim
46
| 0 | 1 | 2 | 3 |
47
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
48
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49
| Next Header |F| Reserved | Payload Length |
50
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51
| Options |
52
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53
\endverbatim
54
*/
55
class
DsrRoutingHeader
:
public
Header
56
{
57
public
:
58
/**
59
* @brief Get the type identificator.
60
* @return type identificator
61
*/
62
static
TypeId
GetTypeId
();
63
64
/**
65
* @brief Get the instance type ID.
66
* @return instance type ID
67
*/
68
TypeId
GetInstanceTypeId
()
const override
;
69
70
/**
71
* @brief Constructor.
72
*/
73
DsrRoutingHeader
();
74
75
/**
76
* @brief Destructor.
77
*/
78
~DsrRoutingHeader
()
override
;
79
80
/**
81
* @brief Print some information about the packet.
82
* @param os output stream
83
*/
84
void
Print
(std::ostream& os)
const override
;
85
86
/**
87
* @brief Set the "Next header" field.
88
* @param protocol the next header number
89
*/
90
void
SetNextHeader
(uint8_t protocol);
91
92
/**
93
* @brief Get the next header.
94
* @return the next header number
95
*/
96
uint8_t
GetNextHeader
()
const
;
97
98
/**
99
* @brief Get the serialized size of the packet.
100
* @return size
101
*/
102
uint32_t
GetSerializedSize
()
const override
;
103
104
/**
105
* @brief Serialize the packet.
106
* @param start Buffer iterator
107
*/
108
void
Serialize
(
Buffer::Iterator
start)
const override
;
109
110
/**
111
* @brief Deserialize the packet.
112
* @param start Buffer iterator
113
* @return size of the packet
114
*/
115
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
116
117
/**
118
* @brief Serialize the option, prepending pad1 or padn option as necessary
119
* @param option the option header to serialize
120
*/
121
void
AddDsrOption
(
const
DsrOptionHeader
& option);
122
123
/**
124
* @brief Get the payload length of the header.
125
* @return the payload length of the header
126
*/
127
uint16_t
GetPayloadLength
()
const
;
128
129
/**
130
* @brief Get the offset where the options begin, measured from the start of
131
* the extension header.
132
* @return the offset from the start of the extension header
133
*/
134
uint32_t
GetDsrOptionsOffset
()
const
;
135
136
private
:
137
/**
138
* @brief Serialize all added options.
139
* @param start Buffer iterator
140
*/
141
void
SerializeOptions
(
Buffer::Iterator
start)
const
;
142
143
/**
144
* @brief Deserialize the packet.
145
* @param start Buffer iterator
146
* @param length length
147
* @return size of the packet
148
*/
149
uint32_t
DeserializeOptions
(
Buffer::Iterator
start,
uint32_t
length);
150
151
/**
152
* @brief Calculate padding.
153
* @param alignment alignment
154
* @return the number of bytes required to pad
155
*/
156
uint32_t
CalculatePad
(
DsrOptionHeader::Alignment
alignment)
const
;
157
158
/**
159
* @brief Data payload.
160
*/
161
Buffer
m_optionData
;
162
163
/**
164
* @brief The "next header" field.
165
*/
166
uint8_t
m_nextHeader
;
167
};
168
169
/**
170
* @brief Output streamer for DsrRoutingHeader
171
* @param os The output stream
172
* @param dsr The DsrRoutingHeader
173
* @return The stream
174
*/
175
static
inline
std::ostream&
176
operator<<
(std::ostream& os,
const
DsrRoutingHeader
&
dsr
)
177
{
178
dsr
.Print(os);
179
return
os;
180
}
181
182
}
// namespace dsr
183
}
// namespace ns3
184
185
#endif
/* DSR_FS_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:109
ns3::Buffer
automatically resized byte buffer
Definition
buffer.h:103
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:36
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::dsr::DsrOptionHeader
header for Dsr Options.
Definition
dsr-option-header.h:44
ns3::dsr::DsrRoutingHeader
Dsr fixed size header Format.
Definition
dsr-routing-header.h:56
ns3::dsr::DsrRoutingHeader::SetNextHeader
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
Definition
dsr-routing-header.cc:78
ns3::dsr::DsrRoutingHeader::AddDsrOption
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
Definition
dsr-routing-header.cc:165
ns3::dsr::DsrRoutingHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
dsr-routing-header.cc:112
ns3::dsr::DsrRoutingHeader::DsrRoutingHeader
DsrRoutingHeader()
Constructor.
Definition
dsr-routing-header.cc:60
ns3::dsr::DsrRoutingHeader::GetPayloadLength
uint16_t GetPayloadLength() const
Get the payload length of the header.
Definition
dsr-routing-header.cc:126
ns3::dsr::DsrRoutingHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
dsr-routing-header.cc:90
ns3::dsr::DsrRoutingHeader::DeserializeOptions
uint32_t DeserializeOptions(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Definition
dsr-routing-header.cc:154
ns3::dsr::DsrRoutingHeader::~DsrRoutingHeader
~DsrRoutingHeader() override
Destructor.
Definition
dsr-routing-header.cc:66
ns3::dsr::DsrRoutingHeader::CalculatePad
uint32_t CalculatePad(DsrOptionHeader::Alignment alignment) const
Calculate padding.
Definition
dsr-routing-header.cc:196
ns3::dsr::DsrRoutingHeader::GetDsrOptionsOffset
uint32_t GetDsrOptionsOffset() const
Get the offset where the options begin, measured from the start of the extension header.
Definition
dsr-routing-header.cc:190
ns3::dsr::DsrRoutingHeader::GetNextHeader
uint8_t GetNextHeader() const
Get the next header.
Definition
dsr-routing-header.cc:84
ns3::dsr::DsrRoutingHeader::Print
void Print(std::ostream &os) const override
Print some information about the packet.
Definition
dsr-routing-header.cc:71
ns3::dsr::DsrRoutingHeader::m_nextHeader
uint8_t m_nextHeader
The "next header" field.
Definition
dsr-routing-header.h:166
ns3::dsr::DsrRoutingHeader::SerializeOptions
void SerializeOptions(Buffer::Iterator start) const
Serialize all added options.
Definition
dsr-routing-header.cc:134
ns3::dsr::DsrRoutingHeader::GetTypeId
static TypeId GetTypeId()
Get the type identificator.
Definition
dsr-routing-header.cc:45
ns3::dsr::DsrRoutingHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Definition
dsr-routing-header.cc:55
ns3::dsr::DsrRoutingHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
dsr-routing-header.cc:100
ns3::dsr::DsrRoutingHeader::m_optionData
Buffer m_optionData
Data payload.
Definition
dsr-routing-header.h:161
uint32_t
dsr-option-header.h
ns3::dsr
Definition
dsr-errorbuff.cc:37
ns3::dsr::operator<<
static std::ostream & operator<<(std::ostream &os, const DsrOptionSRHeader &dsr)
Output streamer for DsrOptionSRHeader.
Definition
dsr-option-header.h:1273
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::dsr::DsrOptionHeader::Alignment
Represents the alignment requirements of an option header.
Definition
dsr-option-header.h:51
src
dsr
model
dsr-routing-header.h
Generated on
for ns-3 by
1.16.1