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