A Discrete-Event Network Simulator
API
ipv6-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2008 Louis Pasteur University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18 */
19
20#ifndef IPV6_HEADER_H
21#define IPV6_HEADER_H
22
23#include "ns3/deprecated.h"
24#include "ns3/header.h"
25#include "ns3/ipv6-address.h"
26
27namespace ns3
28{
29
35class Ipv6Header : public Header
36{
37 public:
47 {
49
50 // Prefixed with "DSCP" to avoid name clash (bug 1723)
51 DSCP_CS1 = 0x08, // octal 010
52 DSCP_AF11 = 0x0A, // octal 012
53 DSCP_AF12 = 0x0C, // octal 014
54 DSCP_AF13 = 0x0E, // octal 016
55
56 DSCP_CS2 = 0x10, // octal 020
57 DSCP_AF21 = 0x12, // octal 022
58 DSCP_AF22 = 0x14, // octal 024
59 DSCP_AF23 = 0x16, // octal 026
60
61 DSCP_CS3 = 0x18, // octal 030
62 DSCP_AF31 = 0x1A, // octal 032
63 DSCP_AF32 = 0x1C, // octal 034
64 DSCP_AF33 = 0x1E, // octal 036
65
66 DSCP_CS4 = 0x20, // octal 040
67 DSCP_AF41 = 0x22, // octal 042
68 DSCP_AF42 = 0x24, // octal 044
69 DSCP_AF43 = 0x26, // octal 046
70
71 DSCP_CS5 = 0x28, // octal 050
72 DSCP_EF = 0x2E, // octal 056
73
74 DSCP_CS6 = 0x30, // octal 060
75 DSCP_CS7 = 0x38 // octal 070
76 };
77
83 {
96 IPV6_SCTP = 135,
99 };
100
105 static TypeId GetTypeId();
106
111 TypeId GetInstanceTypeId() const override;
112
116 Ipv6Header();
117
122 void SetTrafficClass(uint8_t traffic);
123
128 uint8_t GetTrafficClass() const;
129
134 void SetDscp(DscpType dscp);
135
139 DscpType GetDscp() const;
140
145 std::string DscpTypeToString(DscpType dscp) const;
146
152 {
153 // Prefixed with "ECN" to avoid name clash
155 ECN_ECT1 = 0x01,
156 ECN_ECT0 = 0x02,
157 ECN_CE = 0x03
158 };
159
164 void SetEcn(EcnType ecn);
165
169 EcnType GetEcn() const;
170
175 std::string EcnTypeToString(EcnType ecn) const;
176
181 void SetFlowLabel(uint32_t flow);
182
187 uint32_t GetFlowLabel() const;
188
193 void SetPayloadLength(uint16_t len);
194
199 uint16_t GetPayloadLength() const;
200
205 void SetNextHeader(uint8_t next);
206
211 uint8_t GetNextHeader() const;
212
217 void SetHopLimit(uint8_t limit);
218
223 uint8_t GetHopLimit() const;
224
229 void SetSource(Ipv6Address src);
230
238
243 Ipv6Address GetSource() const;
244
252
257 void SetDestination(Ipv6Address dst);
258
266
272
280
285 void Print(std::ostream& os) const override;
286
291 uint32_t GetSerializedSize() const override;
292
297 void Serialize(Buffer::Iterator start) const override;
298
305
306 private:
311
317
322
327
331 uint8_t m_hopLimit;
332
337
342};
343
344} /* namespace ns3 */
345
346#endif /* IPV6_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
Describes an IPv6 address.
Definition: ipv6-address.h:50
Packet header for IPv6.
Definition: ipv6-header.h:36
void SetDestination(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:130
uint32_t GetFlowLabel() const
Get the "Flow label" field.
Definition: ipv6-header.cc:64
void SetEcn(EcnType ecn)
Set ECN field bits.
Definition: ipv6-header.cc:239
NextHeader_e
IPv6 next-header value.
Definition: ipv6-header.h:83
@ IPV6_EXT_CONFIDENTIALITY
Definition: ipv6-header.h:91
@ IPV6_EXT_AUTHENTIFICATION
Definition: ipv6-header.h:92
NS_DEPRECATED_3_35 Ipv6Address GetSourceAddress() const
Get the "Source address" field.
Definition: ipv6-header.cc:124
DscpType GetDscp() const
Definition: ipv6-header.cc:247
Ipv6Address m_destinationAddress
The destination address.
Definition: ipv6-header.h:341
void SetSource(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:106
NS_DEPRECATED_3_35 Ipv6Address GetDestinationAddress() const
Get the "Destination address" field.
Definition: ipv6-header.cc:148
void Print(std::ostream &os) const override
Print some information about the packet.
Definition: ipv6-header.cc:170
uint8_t GetHopLimit() const
Get the "Hop limit" field (TTL).
Definition: ipv6-header.cc:100
uint8_t GetNextHeader() const
Get the next header.
Definition: ipv6-header.cc:88
static TypeId GetTypeId()
Get the type identifier.
Definition: ipv6-header.cc:154
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
Definition: ipv6-header.cc:94
Ipv6Address GetDestination() const
Get the "Destination address" field.
Definition: ipv6-header.cc:142
uint16_t GetPayloadLength() const
Get the "Payload length" field.
Definition: ipv6-header.cc:76
uint8_t GetTrafficClass() const
Get the "Traffic class" field.
Definition: ipv6-header.cc:52
uint32_t m_flowLabel
The flow label.
Definition: ipv6-header.h:316
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
Definition: ipv6-header.cc:164
EcnType GetEcn() const
Definition: ipv6-header.cc:308
void SetPayloadLength(uint16_t len)
Set the "Payload length" field.
Definition: ipv6-header.cc:70
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Definition: ipv6-header.cc:183
void SetFlowLabel(uint32_t flow)
Set the "Flow label" field.
Definition: ipv6-header.cc:58
Ipv6Header()
Constructor.
Definition: ipv6-header.cc:34
Ipv6Address m_sourceAddress
The source address.
Definition: ipv6-header.h:336
Ipv6Address GetSource() const
Get the "Source address" field.
Definition: ipv6-header.cc:118
EcnType
ECN field bits.
Definition: ipv6-header.h:152
uint16_t m_payloadLength
The payload length.
Definition: ipv6-header.h:321
uint8_t m_nextHeader
The Next header number.
Definition: ipv6-header.h:326
NS_DEPRECATED_3_35 void SetSourceAddress(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:112
std::string DscpTypeToString(DscpType dscp) const
Definition: ipv6-header.cc:255
std::string EcnTypeToString(EcnType ecn) const
Definition: ipv6-header.cc:316
void SetTrafficClass(uint8_t traffic)
Set the "Traffic class" field.
Definition: ipv6-header.cc:46
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition: ipv6-header.cc:231
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Definition: ipv6-header.cc:189
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Definition: ipv6-header.cc:206
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition: ipv6-header.cc:82
uint32_t m_trafficClass
The traffic class.
Definition: ipv6-header.h:310
NS_DEPRECATED_3_35 void SetDestinationAddress(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:136
uint8_t m_hopLimit
The Hop limit value.
Definition: ipv6-header.h:331
DscpType
DiffServ Code Points Code Points defined in Assured Forwarding (AF) RFC 2597 Expedited Forwarding (EF...
Definition: ipv6-header.h:47
a unique identifier for an interface.
Definition: type-id.h:60
#define NS_DEPRECATED_3_35
Tag for things deprecated in version ns-3.35.
Definition: deprecated.h:87
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1861