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-fs-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
*
8
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9
* ResiliNets Research Group https://resilinets.org/
10
* Information and Telecommunication Technology Center (ITTC)
11
* and Department of Electrical Engineering and Computer Science
12
* The University of Kansas Lawrence, KS USA.
13
*
14
* Work supported in part by NSF FIND (Future Internet Design) Program
15
* under grant CNS-0626918 (Postmodern Internet Architecture),
16
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
17
* US Department of Defense (DoD), and ITTC at The University of Kansas.
18
*/
19
20
#ifndef DSR_FS_HEADER_H
21
#define DSR_FS_HEADER_H
22
23
#include "
dsr-option-header.h
"
24
25
#include "ns3/header.h"
26
#include "ns3/ipv4-address.h"
27
28
#include <list>
29
#include <ostream>
30
#include <vector>
31
32
namespace
ns3
33
{
34
namespace
dsr
35
{
36
/**
37
* @class DsrHeader
38
* @brief Header for Dsr Routing.
39
*/
40
41
/**
42
* @ingroup dsr
43
* @brief Dsr fixed size header Format
44
\verbatim
45
| 0 | 1 | 2 | 3 |
46
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
47
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48
| Next Header |F| Reservd | Payload Length |
49
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
| Options |
51
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52
\endverbatim
53
*/
54
55
/**
56
* @ingroup dsr
57
* @brief The modified version of Dsr fixed size header Format
58
\verbatim
59
| 0 | 1 | 2 | 3 |
60
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
61
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62
| Next Header |F| Message Type | Payload Length |
63
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64
| Source Id | Dest Id |
65
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66
| Options |
67
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68
\endverbatim
69
*/
70
class
DsrFsHeader
:
public
Header
71
{
72
public
:
73
/**
74
* @brief Get the type identificator.
75
* @return type identificator
76
*/
77
static
TypeId
GetTypeId
();
78
/**
79
* @brief Get the instance type ID.
80
* @return instance type ID
81
*/
82
TypeId
GetInstanceTypeId
()
const override
;
83
/**
84
* @brief Constructor.
85
*/
86
DsrFsHeader
();
87
/**
88
* @brief Destructor.
89
*/
90
~DsrFsHeader
()
override
;
91
/**
92
* @brief Set the "Next header" field.
93
* @param protocol the next header number
94
*/
95
void
SetNextHeader
(uint8_t protocol);
96
/**
97
* @brief Get the next header.
98
* @return the next header number
99
*/
100
uint8_t
GetNextHeader
()
const
;
101
/**
102
* brief Set the message type of the header.
103
* @param messageType the message type of the header
104
*/
105
void
SetMessageType
(uint8_t messageType);
106
/**
107
* brief Get the message type of the header.
108
* @return message type the message type of the header
109
*/
110
uint8_t
GetMessageType
()
const
;
111
/**
112
* brief Set the source ID of the header.
113
* @param sourceId the source ID of the header
114
*/
115
void
SetSourceId
(uint16_t sourceId);
116
/**
117
* brief Get the source ID of the header.
118
* @return source ID the source ID of the header
119
*/
120
uint16_t
GetSourceId
()
const
;
121
/**
122
* brief Set the dest ID of the header.
123
* @param destId the destination ID of the header
124
*/
125
void
SetDestId
(uint16_t destId);
126
/**
127
* brief Get the dest ID of the header.
128
* @return dest ID the dest ID of the header
129
*/
130
uint16_t
GetDestId
()
const
;
131
/**
132
* brief Set the payload length of the header.
133
* @param length the payload length of the header in bytes
134
*/
135
void
SetPayloadLength
(uint16_t length);
136
/**
137
* @brief Get the payload length of the header.
138
* @return the payload length of the header
139
*/
140
uint16_t
GetPayloadLength
()
const
;
141
/**
142
* @brief Print some information about the packet.
143
* @param os output stream
144
*/
145
void
Print
(std::ostream& os)
const override
;
146
/**
147
* @brief Get the serialized size of the packet.
148
* @return size
149
*/
150
uint32_t
GetSerializedSize
()
const override
;
151
/**
152
* @brief Serialize the packet.
153
* @param start Buffer iterator
154
*/
155
void
Serialize
(
Buffer::Iterator
start)
const override
;
156
/**
157
* @brief Deserialize the packet.
158
* @param start Buffer iterator
159
* @return size of the packet
160
*/
161
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
162
163
private
:
164
/**
165
* @brief The "next header" field.
166
*/
167
uint8_t
m_nextHeader
;
168
/**
169
* @brief The type of the message.
170
*/
171
uint8_t
m_messageType
;
172
/**
173
* @brief The "payload length" field.
174
*/
175
uint16_t
m_payloadLen
;
176
/**
177
* @brief The source node id
178
*/
179
uint16_t
m_sourceId
;
180
/**
181
* @brief The destination node id
182
*/
183
uint16_t
m_destId
;
184
/**
185
* @brief The data of the extension.
186
*/
187
Buffer
m_data
;
188
};
189
190
/**
191
* @class DsrOptionField
192
* @brief Option field for an DsrFsHeader
193
* Enables adding options to an DsrFsHeader
194
*
195
* Implementor's note: Make sure to add the result of
196
* OptionField::GetSerializedSize () to your DsrFsHeader::GetSerializedSize ()
197
* return value. Call OptionField::Serialize and OptionField::Deserialize at the
198
* end of your corresponding DsrFsHeader methods.
199
*/
200
class
DsrOptionField
201
{
202
public
:
203
/**
204
* @brief Constructor.
205
* @param optionsOffset option offset
206
*/
207
DsrOptionField
(
uint32_t
optionsOffset);
208
/**
209
* @brief Destructor.
210
*/
211
~DsrOptionField
();
212
/**
213
* @brief Get the serialized size of the packet.
214
* @return size
215
*/
216
uint32_t
GetSerializedSize
()
const
;
217
/**
218
* @brief Serialize all added options.
219
* @param start Buffer iterator
220
*/
221
void
Serialize
(
Buffer::Iterator
start)
const
;
222
/**
223
* @brief Deserialize the packet.
224
* @param start Buffer iterator
225
* @param length length
226
* @return size of the packet
227
*/
228
uint32_t
Deserialize
(
Buffer::Iterator
start,
uint32_t
length);
229
/**
230
* @brief Serialize the option, prepending pad1 or padn option as necessary
231
* @param option the option header to serialize
232
*/
233
void
AddDsrOption
(
const
DsrOptionHeader
& option);
234
/**
235
* @brief Get the offset where the options begin, measured from the start of
236
* the extension header.
237
* @return the offset from the start of the extension header
238
*/
239
uint32_t
GetDsrOptionsOffset
()
const
;
240
/**
241
* @brief Get the buffer.
242
* @return buffer
243
*/
244
Buffer
GetDsrOptionBuffer
();
245
246
private
:
247
/**
248
* @brief Calculate padding.
249
* @param alignment alignment
250
* @return the number of bytes required to pad
251
*/
252
uint32_t
CalculatePad
(
DsrOptionHeader::Alignment
alignment)
const
;
253
/**
254
* @brief Data payload.
255
*/
256
Buffer
m_optionData
;
257
/**
258
* @brief Offset.
259
*/
260
uint32_t
m_optionsOffset
;
261
};
262
263
/**
264
* @class DsrRoutingHeader
265
* @brief Header of Dsr Routing
266
*/
267
class
DsrRoutingHeader
:
public
DsrFsHeader
,
public
DsrOptionField
268
{
269
public
:
270
/**
271
* @brief Get the type identificator.
272
* @return type identificator
273
*/
274
static
TypeId
GetTypeId
();
275
/**
276
* @brief Get the instance type ID.
277
* @return instance type ID
278
*/
279
TypeId
GetInstanceTypeId
()
const override
;
280
/**
281
* @brief Constructor.
282
*/
283
DsrRoutingHeader
();
284
/**
285
* @brief Destructor.
286
*/
287
~DsrRoutingHeader
()
override
;
288
/**
289
* @brief Print some information about the packet.
290
* @param os output stream
291
*/
292
void
Print
(std::ostream& os)
const override
;
293
/**
294
* @brief Get the serialized size of the packet.
295
* @return size
296
*/
297
uint32_t
GetSerializedSize
()
const override
;
298
/**
299
* @brief Serialize the packet.
300
* @param start Buffer iterator
301
*/
302
void
Serialize
(
Buffer::Iterator
start)
const override
;
303
/**
304
* @brief Deserialize the packet.
305
* @param start Buffer iterator
306
* @return size of the packet
307
*/
308
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
309
};
310
311
static
inline
std::ostream&
312
operator<<
(std::ostream& os,
const
DsrRoutingHeader
& dsr)
313
{
314
dsr.
Print
(os);
315
return
os;
316
}
317
318
}
// namespace dsr
319
}
// namespace ns3
320
321
#endif
/* DSR_FS_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer
automatically resized byte buffer
Definition
buffer.h:83
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::dsr::DsrFsHeader
Dsr fixed size header Format.
Definition
dsr-fs-header.h:71
ns3::dsr::DsrFsHeader::SetSourceId
void SetSourceId(uint16_t sourceId)
brief Set the source ID of the header.
Definition
dsr-fs-header.cc:105
ns3::dsr::DsrFsHeader::DsrFsHeader
DsrFsHeader()
Constructor.
Definition
dsr-fs-header.cc:54
ns3::dsr::DsrFsHeader::SetNextHeader
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
Definition
dsr-fs-header.cc:69
ns3::dsr::DsrFsHeader::SetDestId
void SetDestId(uint16_t destId)
brief Set the dest ID of the header.
Definition
dsr-fs-header.cc:117
ns3::dsr::DsrFsHeader::GetMessageType
uint8_t GetMessageType() const
brief Get the message type of the header.
Definition
dsr-fs-header.cc:87
ns3::dsr::DsrFsHeader::GetTypeId
static TypeId GetTypeId()
Get the type identificator.
Definition
dsr-fs-header.cc:39
ns3::dsr::DsrFsHeader::GetNextHeader
uint8_t GetNextHeader() const
Get the next header.
Definition
dsr-fs-header.cc:75
ns3::dsr::DsrFsHeader::m_destId
uint16_t m_destId
The destination node id.
Definition
dsr-fs-header.h:183
ns3::dsr::DsrFsHeader::m_sourceId
uint16_t m_sourceId
The source node id.
Definition
dsr-fs-header.h:179
ns3::dsr::DsrFsHeader::GetSourceId
uint16_t GetSourceId() const
brief Get the source ID of the header.
Definition
dsr-fs-header.cc:111
ns3::dsr::DsrFsHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Definition
dsr-fs-header.cc:49
ns3::dsr::DsrFsHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
dsr-fs-header.cc:144
ns3::dsr::DsrFsHeader::GetDestId
uint16_t GetDestId() const
brief Get the dest ID of the header.
Definition
dsr-fs-header.cc:123
ns3::dsr::DsrFsHeader::m_messageType
uint8_t m_messageType
The type of the message.
Definition
dsr-fs-header.h:171
ns3::dsr::DsrFsHeader::m_payloadLen
uint16_t m_payloadLen
The "payload length" field.
Definition
dsr-fs-header.h:175
ns3::dsr::DsrFsHeader::SetMessageType
void SetMessageType(uint8_t messageType)
brief Set the message type of the header.
Definition
dsr-fs-header.cc:81
ns3::dsr::DsrFsHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
dsr-fs-header.cc:158
ns3::dsr::DsrFsHeader::GetPayloadLength
uint16_t GetPayloadLength() const
Get the payload length of the header.
Definition
dsr-fs-header.cc:99
ns3::dsr::DsrFsHeader::SetPayloadLength
void SetPayloadLength(uint16_t length)
brief Set the payload length of the header.
Definition
dsr-fs-header.cc:93
ns3::dsr::DsrFsHeader::m_nextHeader
uint8_t m_nextHeader
The "next header" field.
Definition
dsr-fs-header.h:167
ns3::dsr::DsrFsHeader::m_data
Buffer m_data
The data of the extension.
Definition
dsr-fs-header.h:187
ns3::dsr::DsrFsHeader::Print
void Print(std::ostream &os) const override
Print some information about the packet.
Definition
dsr-fs-header.cc:129
ns3::dsr::DsrFsHeader::~DsrFsHeader
~DsrFsHeader() override
Destructor.
Definition
dsr-fs-header.cc:64
ns3::dsr::DsrFsHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
dsr-fs-header.cc:138
ns3::dsr::DsrOptionField
Option field for an DsrFsHeader Enables adding options to an DsrFsHeader.
Definition
dsr-fs-header.h:201
ns3::dsr::DsrOptionField::Serialize
void Serialize(Buffer::Iterator start) const
Serialize all added options.
Definition
dsr-fs-header.cc:205
ns3::dsr::DsrOptionField::AddDsrOption
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
Definition
dsr-fs-header.cc:236
ns3::dsr::DsrOptionField::Deserialize
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Definition
dsr-fs-header.cc:225
ns3::dsr::DsrOptionField::m_optionData
Buffer m_optionData
Data payload.
Definition
dsr-fs-header.h:256
ns3::dsr::DsrOptionField::GetDsrOptionBuffer
Buffer GetDsrOptionBuffer()
Get the buffer.
Definition
dsr-fs-header.cc:273
ns3::dsr::DsrOptionField::m_optionsOffset
uint32_t m_optionsOffset
Offset.
Definition
dsr-fs-header.h:260
ns3::dsr::DsrOptionField::GetDsrOptionsOffset
uint32_t GetDsrOptionsOffset() const
Get the offset where the options begin, measured from the start of the extension header.
Definition
dsr-fs-header.cc:267
ns3::dsr::DsrOptionField::GetSerializedSize
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Definition
dsr-fs-header.cc:198
ns3::dsr::DsrOptionField::CalculatePad
uint32_t CalculatePad(DsrOptionHeader::Alignment alignment) const
Calculate padding.
Definition
dsr-fs-header.cc:261
ns3::dsr::DsrOptionField::DsrOptionField
DsrOptionField(uint32_t optionsOffset)
Constructor.
Definition
dsr-fs-header.cc:187
ns3::dsr::DsrOptionField::~DsrOptionField
~DsrOptionField()
Destructor.
Definition
dsr-fs-header.cc:193
ns3::dsr::DsrOptionHeader
header for Dsr Options.
Definition
dsr-option-header.h:42
ns3::dsr::DsrRoutingHeader
Header of Dsr Routing.
Definition
dsr-fs-header.h:268
ns3::dsr::DsrRoutingHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
dsr-fs-header.cc:334
ns3::dsr::DsrRoutingHeader::DsrRoutingHeader
DsrRoutingHeader()
Constructor.
Definition
dsr-fs-header.cc:294
ns3::dsr::DsrRoutingHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
dsr-fs-header.cc:313
ns3::dsr::DsrRoutingHeader::~DsrRoutingHeader
~DsrRoutingHeader() override
Destructor.
Definition
dsr-fs-header.cc:299
ns3::dsr::DsrRoutingHeader::Print
void Print(std::ostream &os) const override
Print some information about the packet.
Definition
dsr-fs-header.cc:304
ns3::dsr::DsrRoutingHeader::GetTypeId
static TypeId GetTypeId()
Get the type identificator.
Definition
dsr-fs-header.cc:281
ns3::dsr::DsrRoutingHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Definition
dsr-fs-header.cc:289
ns3::dsr::DsrRoutingHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
dsr-fs-header.cc:320
uint32_t
dsr-option-header.h
ns3::dsr::operator<<
static std::ostream & operator<<(std::ostream &os, const DsrRoutingHeader &dsr)
Definition
dsr-fs-header.h:312
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:49
src
dsr
model
dsr-fs-header.h
Generated on Fri Dec 13 2024 09:20:39 for ns-3 by
1.11.0