A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
dsr
model
dsr-fs-header.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Yufei Cheng
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19
*
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
* Work supported in part by NSF FIND (Future Internet Design) Program
27
* under grant CNS-0626918 (Postmodern Internet Architecture),
28
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29
* US Department of Defense (DoD), and ITTC at The University of Kansas.
30
*/
31
32
#ifndef DSR_FS_HEADER_H
33
#define DSR_FS_HEADER_H
34
35
#include <vector>
36
#include <list>
37
#include <ostream>
38
39
#include "ns3/header.h"
40
#include "ns3/ipv4-address.h"
41
#include "
dsr-option-header.h
"
42
43
namespace
ns3
{
44
namespace
dsr {
79
class
DsrFsHeader
:
public
Header
80
{
81
public
:
86
static
TypeId
GetTypeId
();
91
virtual
TypeId
GetInstanceTypeId
()
const
;
95
DsrFsHeader
();
99
virtual
~DsrFsHeader
();
104
void
SetNextHeader
(uint8_t protocol);
109
uint8_t
GetNextHeader
()
const
;
114
void
SetMessageType
(uint8_t messageType);
119
uint8_t
GetMessageType
()
const
;
124
void
SetSourceId
(uint16_t sourceId);
129
uint16_t
GetSourceId
()
const
;
134
void
SetDestId
(uint16_t destId);
139
uint16_t
GetDestId
()
const
;
144
void
SetPayloadLength
(uint16_t length);
149
uint16_t
GetPayloadLength
()
const
;
155
virtual
void
Print
(std::ostream &os)
const
;
160
virtual
uint32_t
GetSerializedSize
()
const
;
165
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
171
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
172
173
private
:
177
uint8_t
m_nextHeader
;
181
uint8_t
m_messageType
;
185
uint16_t
m_payloadLen
;
189
uint16_t
m_sourceId
;
193
uint16_t
m_destId
;
197
Buffer
m_data
;
198
};
199
210
class
DsrOptionField
211
{
212
public
:
217
DsrOptionField
(uint32_t optionsOffset);
221
~DsrOptionField
();
226
uint32_t
GetSerializedSize
()
const
;
231
void
Serialize
(
Buffer::Iterator
start
)
const
;
238
uint32_t
Deserialize
(
Buffer::Iterator
start
, uint32_t length);
243
void
AddDsrOption
(
DsrOptionHeader
const
& option);
249
uint32_t
GetDsrOptionsOffset
();
254
Buffer
GetDsrOptionBuffer
();
255
256
private
:
262
uint32_t
CalculatePad
(
DsrOptionHeader::Alignment
alignment)
const
;
266
Buffer
m_optionData
;
270
uint32_t
m_optionsOffset
;
271
};
272
277
class
DsrRoutingHeader
:
public
DsrFsHeader
,
278
public
DsrOptionField
279
{
280
public
:
285
static
TypeId
GetTypeId
();
290
virtual
TypeId
GetInstanceTypeId
()
const
;
294
DsrRoutingHeader
();
298
virtual
~DsrRoutingHeader
();
304
virtual
void
Print
(std::ostream &os)
const
;
309
virtual
uint32_t
GetSerializedSize
()
const
;
314
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
320
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
321
};
322
323
static
inline
std::ostream &
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 */
333
ns3::dsr::DsrOptionField::~DsrOptionField
~DsrOptionField()
Destructor.
Definition:
dsr-fs-header.cc:185
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::dsr::DsrRoutingHeader::GetSerializedSize
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Definition:
dsr-fs-header.cc:296
ns3::dsr::DsrOptionField::CalculatePad
uint32_t CalculatePad(DsrOptionHeader::Alignment alignment) const
Calculate padding.
Definition:
dsr-fs-header.cc:248
ns3::dsr::DsrRoutingHeader::GetTypeId
static TypeId GetTypeId()
Get the type identificator.
Definition:
dsr-fs-header.cc:265
ns3::dsr::DsrRoutingHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Definition:
dsr-fs-header.cc:274
ns3::dsr::DsrRoutingHeader::DsrRoutingHeader
DsrRoutingHeader()
Constructor.
Definition:
dsr-fs-header.cc:279
ns3::dsr::DsrRoutingHeader::Print
virtual void Print(std::ostream &os) const
Print some information about the packet.
Definition:
dsr-fs-header.cc:288
ns3::dsr::DsrFsHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition:
dsr-fs-header.cc:137
ns3::dsr::DsrFsHeader::GetDestId
uint16_t GetDestId() const
brief Get the dest ID of the header.
Definition:
dsr-fs-header.cc:119
ns3::dsr::DsrOptionField::Deserialize
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Definition:
dsr-fs-header.cc:214
ns3::dsr::DsrFsHeader::GetNextHeader
uint8_t GetNextHeader() const
Get the next header.
Definition:
dsr-fs-header.cc:79
ns3::Buffer
automatically resized byte buffer
Definition:
buffer.h:92
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::dsr::DsrOptionField::m_optionsOffset
uint32_t m_optionsOffset
Offset.
Definition:
dsr-fs-header.h:270
ns3::dsr::DsrFsHeader::GetSerializedSize
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Definition:
dsr-fs-header.cc:132
ns3::dsr::DsrFsHeader::SetNextHeader
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
Definition:
dsr-fs-header.cc:74
ns3::dsr::DsrFsHeader::~DsrFsHeader
virtual ~DsrFsHeader()
Destructor.
Definition:
dsr-fs-header.cc:70
ns3::dsr::DsrFsHeader::SetSourceId
void SetSourceId(uint16_t sourceId)
brief Set the source ID of the header.
Definition:
dsr-fs-header.cc:104
ns3::dsr::DsrFsHeader
Dsr fixed size header Format.
Definition:
dsr-fs-header.h:79
ns3::dsr::DsrFsHeader::SetDestId
void SetDestId(uint16_t destId)
brief Set the dest ID of the header.
Definition:
dsr-fs-header.cc:114
ns3::dsr::DsrOptionField
Option field for an DsrFsHeader Enables adding options to an DsrFsHeader.
Definition:
dsr-fs-header.h:210
ns3::dsr::DsrOptionHeader::Alignment
represents the alignment requirements of an option header
Definition:
dsr-option-header.h:57
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::dsr::DsrFsHeader::Print
virtual void Print(std::ostream &os) const
Print some information about the packet.
Definition:
dsr-fs-header.cc:124
ns3::dsr::DsrFsHeader::GetPayloadLength
uint16_t GetPayloadLength() const
Get the payload length of the header.
Definition:
dsr-fs-header.cc:99
ns3::dsr::DsrOptionField::GetDsrOptionsOffset
uint32_t GetDsrOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header.
Definition:
dsr-fs-header.cc:253
ns3::dsr::DsrFsHeader::GetSourceId
uint16_t GetSourceId() const
brief Get the source ID of the header.
Definition:
dsr-fs-header.cc:109
ns3::dsr::DsrFsHeader::m_destId
uint16_t m_destId
The destination node id.
Definition:
dsr-fs-header.h:193
ns3::dsr::DsrFsHeader::GetMessageType
uint8_t GetMessageType() const
brief Get the message type of the header.
Definition:
dsr-fs-header.cc:89
ns3::dsr::DsrFsHeader::m_nextHeader
uint8_t m_nextHeader
The "next header" field.
Definition:
dsr-fs-header.h:177
ns3::dsr::DsrFsHeader::m_payloadLen
uint16_t m_payloadLen
The "payload length" field.
Definition:
dsr-fs-header.h:185
ns3::dsr::DsrFsHeader::SetPayloadLength
void SetPayloadLength(uint16_t length)
brief Set the payload length of the header.
Definition:
dsr-fs-header.cc:94
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::dsr::DsrOptionField::GetSerializedSize
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Definition:
dsr-fs-header.cc:189
ns3::dsr::DsrFsHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Definition:
dsr-fs-header.cc:150
ns3::dsr::DsrRoutingHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition:
dsr-fs-header.cc:302
ns3::dsr::DsrFsHeader::DsrFsHeader
DsrFsHeader()
Constructor.
Definition:
dsr-fs-header.cc:60
ns3::dsr::DsrFsHeader::m_messageType
uint8_t m_messageType
The type of the message.
Definition:
dsr-fs-header.h:181
ns3::dsr::DsrFsHeader::SetMessageType
void SetMessageType(uint8_t messageType)
brief Set the message type of the header.
Definition:
dsr-fs-header.cc:84
ns3::dsr::DsrFsHeader::m_sourceId
uint16_t m_sourceId
The source node id.
Definition:
dsr-fs-header.h:189
ns3::dsr::DsrFsHeader::GetTypeId
static TypeId GetTypeId()
Get the type identificator.
Definition:
dsr-fs-header.cc:45
ns3::dsr::DsrFsHeader::m_data
Buffer m_data
The data of the extension.
Definition:
dsr-fs-header.h:197
ns3::dsr::DsrRoutingHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Definition:
dsr-fs-header.cc:315
ns3::dsr::DsrOptionField::DsrOptionField
DsrOptionField(uint32_t optionsOffset)
Constructor.
Definition:
dsr-fs-header.cc:179
ns3::dsr::DsrOptionField::AddDsrOption
void AddDsrOption(DsrOptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
Definition:
dsr-fs-header.cc:224
ns3::dsr::DsrOptionHeader
Introspection did not find any typical Config paths.
Definition:
dsr-option-header.h:50
ns3::dsr::DsrRoutingHeader::~DsrRoutingHeader
virtual ~DsrRoutingHeader()
Destructor.
Definition:
dsr-fs-header.cc:284
dsr-option-header.h
ns3::dsr::DsrFsHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Definition:
dsr-fs-header.cc:55
ns3::dsr::DsrOptionField::Serialize
void Serialize(Buffer::Iterator start) const
Serialize all added options.
Definition:
dsr-fs-header.cc:195
ns3::dsr::operator<<
static std::ostream & operator<<(std::ostream &os, const DsrRoutingHeader &dsr)
Definition:
dsr-fs-header.h:323
ns3::dsr::DsrRoutingHeader
Header of Dsr Routing.
Definition:
dsr-fs-header.h:277
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::dsr::DsrOptionField::m_optionData
Buffer m_optionData
Data payload.
Definition:
dsr-fs-header.h:266
ns3::dsr::DsrOptionField::GetDsrOptionBuffer
Buffer GetDsrOptionBuffer()
Get the buffer.
Definition:
dsr-fs-header.cc:258
Generated on Wed Nov 7 2018 10:01:51 for ns-3 by
1.8.14