A Discrete-Event Network Simulator
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
34namespace ns3
35{
36namespace 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*/
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 */
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 */
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 */
150
151 /**
152 * @brief Calculate padding.
153 * @param alignment alignment
154 * @return the number of bytes required to pad
155 */
157
158 /**
159 * @brief Data payload.
160 */
162
163 /**
164 * @brief The "next header" field.
165 */
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 */
175static inline std::ostream&
176operator<<(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 */
iterator in a Buffer instance
Definition buffer.h:109
automatically resized byte buffer
Definition buffer.h:103
Protocol header serialization and deserialization.
Definition header.h:36
a unique identifier for an interface.
Definition type-id.h:50
header for Dsr Options.
Dsr fixed size header Format.
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint16_t GetPayloadLength() const
Get the payload length of the header.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint32_t DeserializeOptions(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
~DsrRoutingHeader() override
Destructor.
uint32_t CalculatePad(DsrOptionHeader::Alignment alignment) const
Calculate padding.
uint32_t GetDsrOptionsOffset() const
Get the offset where the options begin, measured from the start of the extension header.
uint8_t GetNextHeader() const
Get the next header.
void Print(std::ostream &os) const override
Print some information about the packet.
uint8_t m_nextHeader
The "next header" field.
void SerializeOptions(Buffer::Iterator start) const
Serialize all added options.
static TypeId GetTypeId()
Get the type identificator.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Buffer m_optionData
Data payload.
static std::ostream & operator<<(std::ostream &os, const DsrOptionSRHeader &dsr)
Output streamer for DsrOptionSRHeader.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Represents the alignment requirements of an option header.