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
ipv6-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007-2008 Louis Pasteur University
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7
*/
8
9
#ifndef IPV6_HEADER_H
10
#define IPV6_HEADER_H
11
12
#include "ns3/header.h"
13
#include "ns3/ipv6-address.h"
14
15
namespace
ns3
16
{
17
18
/**
19
* \ingroup ipv6
20
*
21
* \brief Packet header for IPv6
22
*/
23
class
Ipv6Header
:
public
Header
24
{
25
public
:
26
/**
27
* \enum DscpType
28
* \brief DiffServ Code Points
29
* Code Points defined in
30
* Assured Forwarding (AF) \RFC{2597}
31
* Expedited Forwarding (EF) \RFC{2598}
32
* Default and Class Selector (CS) \RFC{2474}
33
*/
34
enum
DscpType
35
{
36
DscpDefault
= 0x00,
37
38
// Prefixed with "DSCP" to avoid name clash (bug 1723)
39
DSCP_CS1
= 0x08,
// octal 010
40
DSCP_AF11
= 0x0A,
// octal 012
41
DSCP_AF12
= 0x0C,
// octal 014
42
DSCP_AF13
= 0x0E,
// octal 016
43
44
DSCP_CS2
= 0x10,
// octal 020
45
DSCP_AF21
= 0x12,
// octal 022
46
DSCP_AF22
= 0x14,
// octal 024
47
DSCP_AF23
= 0x16,
// octal 026
48
49
DSCP_CS3
= 0x18,
// octal 030
50
DSCP_AF31
= 0x1A,
// octal 032
51
DSCP_AF32
= 0x1C,
// octal 034
52
DSCP_AF33
= 0x1E,
// octal 036
53
54
DSCP_CS4
= 0x20,
// octal 040
55
DSCP_AF41
= 0x22,
// octal 042
56
DSCP_AF42
= 0x24,
// octal 044
57
DSCP_AF43
= 0x26,
// octal 046
58
59
DSCP_CS5
= 0x28,
// octal 050
60
DSCP_EF
= 0x2E,
// octal 056
61
62
DSCP_CS6
= 0x30,
// octal 060
63
DSCP_CS7
= 0x38
// octal 070
64
};
65
66
/**
67
* \enum NextHeader_e
68
* \brief IPv6 next-header value
69
*/
70
enum
NextHeader_e
71
{
72
IPV6_EXT_HOP_BY_HOP
= 0,
73
IPV6_IPV4
= 4,
74
IPV6_TCP
= 6,
75
IPV6_UDP
= 17,
76
IPV6_IPV6
= 41,
77
IPV6_EXT_ROUTING
= 43,
78
IPV6_EXT_FRAGMENTATION
= 44,
79
IPV6_EXT_CONFIDENTIALITY
= 50,
80
IPV6_EXT_AUTHENTICATION
= 51,
81
IPV6_ICMPV6
= 58,
82
IPV6_EXT_END
= 59,
83
IPV6_EXT_DESTINATION
= 60,
84
IPV6_SCTP
= 135,
85
IPV6_EXT_MOBILITY
= 135,
86
IPV6_UDP_LITE
= 136,
87
};
88
89
/**
90
* \brief Get the type identifier.
91
* \return type identifier
92
*/
93
static
TypeId
GetTypeId
();
94
95
/**
96
* \brief Return the instance type identifier.
97
* \return instance type ID
98
*/
99
TypeId
GetInstanceTypeId
()
const override
;
100
101
/**
102
* \brief Constructor.
103
*/
104
Ipv6Header
();
105
106
/**
107
* \brief Set the "Traffic class" field.
108
* \param traffic the 8-bit value
109
*/
110
void
SetTrafficClass
(uint8_t traffic);
111
112
/**
113
* \brief Get the "Traffic class" field.
114
* \return the traffic value
115
*/
116
uint8_t
GetTrafficClass
()
const
;
117
118
/**
119
* \brief Set DSCP Field
120
* \param dscp DSCP value
121
*/
122
void
SetDscp
(
DscpType
dscp);
123
124
/**
125
* \returns the DSCP field of this packet.
126
*/
127
DscpType
GetDscp
()
const
;
128
129
/**
130
* \param dscp the dscp
131
* \returns std::string of DSCPType
132
*/
133
std::string
DscpTypeToString
(
DscpType
dscp)
const
;
134
135
/**
136
* \enum EcnType
137
* \brief ECN field bits
138
*/
139
enum
EcnType
140
{
141
// Prefixed with "ECN" to avoid name clash
142
ECN_NotECT
= 0x00,
143
ECN_ECT1
= 0x01,
144
ECN_ECT0
= 0x02,
145
ECN_CE
= 0x03
146
};
147
148
/**
149
* \brief Set ECN field bits
150
* \param ecn ECN field bits
151
*/
152
void
SetEcn
(
EcnType
ecn);
153
154
/**
155
* \return the ECN field bits of this packet.
156
*/
157
EcnType
GetEcn
()
const
;
158
159
/**
160
* \param ecn the ECNType
161
* \return std::string of ECNType
162
*/
163
std::string
EcnTypeToString
(
EcnType
ecn)
const
;
164
165
/**
166
* \brief Set the "Flow label" field.
167
* \param flow the 20-bit value
168
*/
169
void
SetFlowLabel
(
uint32_t
flow);
170
171
/**
172
* \brief Get the "Flow label" field.
173
* \return the flow label value
174
*/
175
uint32_t
GetFlowLabel
()
const
;
176
177
/**
178
* \brief Set the "Payload length" field.
179
* \param len the length of the payload in bytes
180
*/
181
void
SetPayloadLength
(uint16_t len);
182
183
/**
184
* \brief Get the "Payload length" field.
185
* \return the payload length
186
*/
187
uint16_t
GetPayloadLength
()
const
;
188
189
/**
190
* \brief Set the "Next header" field.
191
* \param next the next header number
192
*/
193
void
SetNextHeader
(uint8_t next);
194
195
/**
196
* \brief Get the next header.
197
* \return the next header number
198
*/
199
uint8_t
GetNextHeader
()
const
;
200
201
/**
202
* \brief Set the "Hop limit" field (TTL).
203
* \param limit the 8-bit value
204
*/
205
void
SetHopLimit
(uint8_t limit);
206
207
/**
208
* \brief Get the "Hop limit" field (TTL).
209
* \return the hop limit value
210
*/
211
uint8_t
GetHopLimit
()
const
;
212
213
/**
214
* \brief Set the "Source address" field.
215
* \param src the source address
216
*/
217
void
SetSource
(
Ipv6Address
src);
218
219
/**
220
* \brief Get the "Source address" field.
221
* \return the source address
222
*/
223
Ipv6Address
GetSource
()
const
;
224
225
/**
226
* \brief Set the "Destination address" field.
227
* \param dst the destination address
228
*/
229
void
SetDestination
(
Ipv6Address
dst);
230
231
/**
232
* \brief Get the "Destination address" field.
233
* \return the destination address
234
*/
235
Ipv6Address
GetDestination
()
const
;
236
237
/**
238
* \brief Print some information about the packet.
239
* \param os output stream
240
*/
241
void
Print
(std::ostream& os)
const override
;
242
243
/**
244
* \brief Get the serialized size of the packet.
245
* \return size
246
*/
247
uint32_t
GetSerializedSize
()
const override
;
248
249
/**
250
* \brief Serialize the packet.
251
* \param start Buffer iterator
252
*/
253
void
Serialize
(
Buffer::Iterator
start)
const override
;
254
255
/**
256
* \brief Deserialize the packet.
257
* \param start Buffer iterator
258
* \return size of the packet
259
*/
260
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
261
262
private
:
263
/**
264
* \brief The traffic class.
265
*/
266
uint32_t
m_trafficClass
: 8;
267
268
/**
269
* \brief The flow label.
270
* \note This is 20-bit value.
271
*/
272
uint32_t
m_flowLabel
: 20;
273
274
/**
275
* \brief The payload length.
276
*/
277
uint16_t
m_payloadLength
;
278
279
/**
280
* \brief The Next header number.
281
*/
282
uint8_t
m_nextHeader
;
283
284
/**
285
* \brief The Hop limit value.
286
*/
287
uint8_t
m_hopLimit
;
288
289
/**
290
* \brief The source address.
291
*/
292
Ipv6Address
m_sourceAddress
;
293
294
/**
295
* \brief The destination address.
296
*/
297
Ipv6Address
m_destinationAddress
;
298
};
299
300
}
/* namespace ns3 */
301
302
#endif
/* IPV6_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6Header
Packet header for IPv6.
Definition
ipv6-header.h:24
ns3::Ipv6Header::SetDestination
void SetDestination(Ipv6Address dst)
Set the "Destination address" field.
Definition
ipv6-header.cc:107
ns3::Ipv6Header::GetFlowLabel
uint32_t GetFlowLabel() const
Get the "Flow label" field.
Definition
ipv6-header.cc:53
ns3::Ipv6Header::SetEcn
void SetEcn(EcnType ecn)
Set ECN field bits.
Definition
ipv6-header.cc:204
ns3::Ipv6Header::NextHeader_e
NextHeader_e
IPv6 next-header value.
Definition
ipv6-header.h:71
ns3::Ipv6Header::IPV6_EXT_END
@ IPV6_EXT_END
Definition
ipv6-header.h:82
ns3::Ipv6Header::IPV6_IPV6
@ IPV6_IPV6
Definition
ipv6-header.h:76
ns3::Ipv6Header::IPV6_SCTP
@ IPV6_SCTP
Definition
ipv6-header.h:84
ns3::Ipv6Header::IPV6_EXT_ROUTING
@ IPV6_EXT_ROUTING
Definition
ipv6-header.h:77
ns3::Ipv6Header::IPV6_EXT_FRAGMENTATION
@ IPV6_EXT_FRAGMENTATION
Definition
ipv6-header.h:78
ns3::Ipv6Header::IPV6_ICMPV6
@ IPV6_ICMPV6
Definition
ipv6-header.h:81
ns3::Ipv6Header::IPV6_EXT_CONFIDENTIALITY
@ IPV6_EXT_CONFIDENTIALITY
Definition
ipv6-header.h:79
ns3::Ipv6Header::IPV6_EXT_HOP_BY_HOP
@ IPV6_EXT_HOP_BY_HOP
Definition
ipv6-header.h:72
ns3::Ipv6Header::IPV6_UDP_LITE
@ IPV6_UDP_LITE
Definition
ipv6-header.h:86
ns3::Ipv6Header::IPV6_IPV4
@ IPV6_IPV4
Definition
ipv6-header.h:73
ns3::Ipv6Header::IPV6_EXT_AUTHENTICATION
@ IPV6_EXT_AUTHENTICATION
Definition
ipv6-header.h:80
ns3::Ipv6Header::IPV6_EXT_DESTINATION
@ IPV6_EXT_DESTINATION
Definition
ipv6-header.h:83
ns3::Ipv6Header::IPV6_EXT_MOBILITY
@ IPV6_EXT_MOBILITY
Definition
ipv6-header.h:85
ns3::Ipv6Header::IPV6_TCP
@ IPV6_TCP
Definition
ipv6-header.h:74
ns3::Ipv6Header::IPV6_UDP
@ IPV6_UDP
Definition
ipv6-header.h:75
ns3::Ipv6Header::GetDscp
DscpType GetDscp() const
Definition
ipv6-header.cc:212
ns3::Ipv6Header::m_destinationAddress
Ipv6Address m_destinationAddress
The destination address.
Definition
ipv6-header.h:297
ns3::Ipv6Header::SetSource
void SetSource(Ipv6Address src)
Set the "Source address" field.
Definition
ipv6-header.cc:95
ns3::Ipv6Header::Print
void Print(std::ostream &os) const override
Print some information about the packet.
Definition
ipv6-header.cc:135
ns3::Ipv6Header::GetHopLimit
uint8_t GetHopLimit() const
Get the "Hop limit" field (TTL).
Definition
ipv6-header.cc:89
ns3::Ipv6Header::GetNextHeader
uint8_t GetNextHeader() const
Get the next header.
Definition
ipv6-header.cc:77
ns3::Ipv6Header::GetTypeId
static TypeId GetTypeId()
Get the type identifier.
Definition
ipv6-header.cc:119
ns3::Ipv6Header::SetHopLimit
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
Definition
ipv6-header.cc:83
ns3::Ipv6Header::GetDestination
Ipv6Address GetDestination() const
Get the "Destination address" field.
Definition
ipv6-header.cc:113
ns3::Ipv6Header::GetPayloadLength
uint16_t GetPayloadLength() const
Get the "Payload length" field.
Definition
ipv6-header.cc:65
ns3::Ipv6Header::GetTrafficClass
uint8_t GetTrafficClass() const
Get the "Traffic class" field.
Definition
ipv6-header.cc:41
ns3::Ipv6Header::m_flowLabel
uint32_t m_flowLabel
The flow label.
Definition
ipv6-header.h:272
ns3::Ipv6Header::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition
ipv6-header.cc:129
ns3::Ipv6Header::GetEcn
EcnType GetEcn() const
Definition
ipv6-header.cc:273
ns3::Ipv6Header::SetPayloadLength
void SetPayloadLength(uint16_t len)
Set the "Payload length" field.
Definition
ipv6-header.cc:59
ns3::Ipv6Header::GetSerializedSize
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition
ipv6-header.cc:148
ns3::Ipv6Header::SetFlowLabel
void SetFlowLabel(uint32_t flow)
Set the "Flow label" field.
Definition
ipv6-header.cc:47
ns3::Ipv6Header::Ipv6Header
Ipv6Header()
Constructor.
Definition
ipv6-header.cc:23
ns3::Ipv6Header::m_sourceAddress
Ipv6Address m_sourceAddress
The source address.
Definition
ipv6-header.h:292
ns3::Ipv6Header::GetSource
Ipv6Address GetSource() const
Get the "Source address" field.
Definition
ipv6-header.cc:101
ns3::Ipv6Header::EcnType
EcnType
ECN field bits.
Definition
ipv6-header.h:140
ns3::Ipv6Header::ECN_NotECT
@ ECN_NotECT
Definition
ipv6-header.h:142
ns3::Ipv6Header::ECN_ECT1
@ ECN_ECT1
Definition
ipv6-header.h:143
ns3::Ipv6Header::ECN_ECT0
@ ECN_ECT0
Definition
ipv6-header.h:144
ns3::Ipv6Header::ECN_CE
@ ECN_CE
Definition
ipv6-header.h:145
ns3::Ipv6Header::m_payloadLength
uint16_t m_payloadLength
The payload length.
Definition
ipv6-header.h:277
ns3::Ipv6Header::m_nextHeader
uint8_t m_nextHeader
The Next header number.
Definition
ipv6-header.h:282
ns3::Ipv6Header::DscpTypeToString
std::string DscpTypeToString(DscpType dscp) const
Definition
ipv6-header.cc:220
ns3::Ipv6Header::EcnTypeToString
std::string EcnTypeToString(EcnType ecn) const
Definition
ipv6-header.cc:281
ns3::Ipv6Header::SetTrafficClass
void SetTrafficClass(uint8_t traffic)
Set the "Traffic class" field.
Definition
ipv6-header.cc:35
ns3::Ipv6Header::SetDscp
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition
ipv6-header.cc:196
ns3::Ipv6Header::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition
ipv6-header.cc:154
ns3::Ipv6Header::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition
ipv6-header.cc:171
ns3::Ipv6Header::SetNextHeader
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition
ipv6-header.cc:71
ns3::Ipv6Header::m_trafficClass
uint32_t m_trafficClass
The traffic class.
Definition
ipv6-header.h:266
ns3::Ipv6Header::m_hopLimit
uint8_t m_hopLimit
The Hop limit value.
Definition
ipv6-header.h:287
ns3::Ipv6Header::DscpType
DscpType
DiffServ Code Points Code Points defined in Assured Forwarding (AF) RFC 2597 Expedited Forwarding (EF...
Definition
ipv6-header.h:35
ns3::Ipv6Header::DSCP_AF43
@ DSCP_AF43
Definition
ipv6-header.h:57
ns3::Ipv6Header::DSCP_AF23
@ DSCP_AF23
Definition
ipv6-header.h:47
ns3::Ipv6Header::DSCP_AF32
@ DSCP_AF32
Definition
ipv6-header.h:51
ns3::Ipv6Header::DSCP_AF21
@ DSCP_AF21
Definition
ipv6-header.h:45
ns3::Ipv6Header::DSCP_AF11
@ DSCP_AF11
Definition
ipv6-header.h:40
ns3::Ipv6Header::DscpDefault
@ DscpDefault
Definition
ipv6-header.h:36
ns3::Ipv6Header::DSCP_AF13
@ DSCP_AF13
Definition
ipv6-header.h:42
ns3::Ipv6Header::DSCP_CS2
@ DSCP_CS2
Definition
ipv6-header.h:44
ns3::Ipv6Header::DSCP_CS7
@ DSCP_CS7
Definition
ipv6-header.h:63
ns3::Ipv6Header::DSCP_CS3
@ DSCP_CS3
Definition
ipv6-header.h:49
ns3::Ipv6Header::DSCP_CS6
@ DSCP_CS6
Definition
ipv6-header.h:62
ns3::Ipv6Header::DSCP_CS1
@ DSCP_CS1
Definition
ipv6-header.h:39
ns3::Ipv6Header::DSCP_AF41
@ DSCP_AF41
Definition
ipv6-header.h:55
ns3::Ipv6Header::DSCP_AF42
@ DSCP_AF42
Definition
ipv6-header.h:56
ns3::Ipv6Header::DSCP_EF
@ DSCP_EF
Definition
ipv6-header.h:60
ns3::Ipv6Header::DSCP_AF22
@ DSCP_AF22
Definition
ipv6-header.h:46
ns3::Ipv6Header::DSCP_AF33
@ DSCP_AF33
Definition
ipv6-header.h:52
ns3::Ipv6Header::DSCP_AF12
@ DSCP_AF12
Definition
ipv6-header.h:41
ns3::Ipv6Header::DSCP_CS5
@ DSCP_CS5
Definition
ipv6-header.h:59
ns3::Ipv6Header::DSCP_AF31
@ DSCP_AF31
Definition
ipv6-header.h:50
ns3::Ipv6Header::DSCP_CS4
@ DSCP_CS4
Definition
ipv6-header.h:54
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
model
ipv6-header.h
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0