A Discrete-Event Network Simulator
API
ipv6-header.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007-2008 Louis Pasteur University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19 */
20
21#ifndef IPV6_HEADER_H
22#define IPV6_HEADER_H
23
24#include "ns3/header.h"
25#include "ns3/ipv6-address.h"
26#include "ns3/deprecated.h"
27
28namespace ns3 {
29
35class Ipv6Header : public Header
36{
37public:
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 };
78
84 {
97 IPV6_SCTP = 135,
100 };
101
106 static TypeId GetTypeId (void);
107
112 virtual TypeId GetInstanceTypeId (void) const;
113
117 Ipv6Header (void);
118
123 void SetTrafficClass (uint8_t traffic);
124
129 uint8_t GetTrafficClass (void) const;
130
135 void SetDscp (DscpType dscp);
136
140 DscpType GetDscp (void) const;
141
146 std::string DscpTypeToString (DscpType dscp) const;
147
153 {
154 // Prefixed with "ECN" to avoid name clash
156 ECN_ECT1 = 0x01,
157 ECN_ECT0 = 0x02,
158 ECN_CE = 0x03
159 };
160
165 void SetEcn (EcnType ecn);
166
170 EcnType GetEcn (void) const;
171
176 std::string EcnTypeToString (EcnType ecn) const;
177
182 void SetFlowLabel (uint32_t flow);
183
188 uint32_t GetFlowLabel (void) const;
189
194 void SetPayloadLength (uint16_t len);
195
200 uint16_t GetPayloadLength (void) const;
201
206 void SetNextHeader (uint8_t next);
207
212 uint8_t GetNextHeader (void) const;
213
218 void SetHopLimit (uint8_t limit);
219
224 uint8_t GetHopLimit (void) const;
225
230 void SetSource (Ipv6Address src);
231
238 void SetSourceAddress (Ipv6Address src);
239
244 Ipv6Address GetSource (void) const;
245
252 Ipv6Address GetSourceAddress (void) const;
253
258 void SetDestination (Ipv6Address dst);
259
267
272 Ipv6Address GetDestination (void) const;
273
281
286 virtual void Print (std::ostream& os) const;
287
292 virtual uint32_t GetSerializedSize (void) const;
293
298 virtual void Serialize (Buffer::Iterator start) const;
299
306
307private:
312
318
323
328
332 uint8_t m_hopLimit;
333
338
343};
344
345} /* namespace ns3 */
346
347#endif /* IPV6_HEADER_H */
348
iterator in a Buffer instance
Definition: buffer.h:99
Protocol header serialization and deserialization.
Definition: header.h:43
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:115
NS_DEPRECATED_3_35 Ipv6Address GetSourceAddress(void) const
Get the "Source address" field.
Definition: ipv6-header.cc:110
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
Definition: ipv6-header.cc:90
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: ipv6-header.cc:145
virtual void Print(std::ostream &os) const
Print some information about the packet.
Definition: ipv6-header.cc:150
void SetEcn(EcnType ecn)
Set ECN field bits.
Definition: ipv6-header.cc:215
NextHeader_e
IPv6 next-header value.
Definition: ipv6-header.h:84
@ IPV6_EXT_CONFIDENTIALITY
Definition: ipv6-header.h:92
@ IPV6_EXT_AUTHENTIFICATION
Definition: ipv6-header.h:93
Ipv6Address GetSource(void) const
Get the "Source address" field.
Definition: ipv6-header.cc:105
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: ipv6-header.cc:163
DscpType GetDscp(void) const
Definition: ipv6-header.cc:222
static TypeId GetTypeId(void)
Get the type identifier.
Definition: ipv6-header.cc:135
Ipv6Address m_destinationAddress
The destination address.
Definition: ipv6-header.h:342
void SetSource(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:95
uint8_t GetNextHeader(void) const
Get the next header.
Definition: ipv6-header.cc:80
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
Definition: ipv6-header.cc:85
uint32_t m_flowLabel
The flow label.
Definition: ipv6-header.h:317
void SetPayloadLength(uint16_t len)
Set the "Payload length" field.
Definition: ipv6-header.cc:65
NS_DEPRECATED_3_35 Ipv6Address GetDestinationAddress(void) const
Get the "Destination address" field.
Definition: ipv6-header.cc:130
Ipv6Header(void)
Constructor.
Definition: ipv6-header.cc:34
uint8_t GetTrafficClass(void) const
Get the "Traffic class" field.
Definition: ipv6-header.cc:50
uint16_t GetPayloadLength(void) const
Get the "Payload length" field.
Definition: ipv6-header.cc:70
void SetFlowLabel(uint32_t flow)
Set the "Flow label" field.
Definition: ipv6-header.cc:55
Ipv6Address m_sourceAddress
The source address.
Definition: ipv6-header.h:337
EcnType
ECN field bits.
Definition: ipv6-header.h:153
uint16_t m_payloadLength
The payload length.
Definition: ipv6-header.h:322
uint8_t m_nextHeader
The Next header number.
Definition: ipv6-header.h:327
NS_DEPRECATED_3_35 void SetSourceAddress(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:100
std::string DscpTypeToString(DscpType dscp) const
Definition: ipv6-header.cc:229
std::string EcnTypeToString(EcnType ecn) const
Definition: ipv6-header.cc:289
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: ipv6-header.cc:168
void SetTrafficClass(uint8_t traffic)
Set the "Traffic class" field.
Definition: ipv6-header.cc:45
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition: ipv6-header.cc:208
uint32_t GetFlowLabel(void) const
Get the "Flow label" field.
Definition: ipv6-header.cc:60
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Definition: ipv6-header.cc:184
Ipv6Address GetDestination(void) const
Get the "Destination address" field.
Definition: ipv6-header.cc:125
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition: ipv6-header.cc:75
uint32_t m_trafficClass
The traffic class.
Definition: ipv6-header.h:311
EcnType GetEcn(void) const
Definition: ipv6-header.cc:282
NS_DEPRECATED_3_35 void SetDestinationAddress(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:120
uint8_t m_hopLimit
The Hop limit value.
Definition: ipv6-header.h:332
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:59
#define NS_DEPRECATED_3_35
Tag for things deprecated in version ns-3.35.
Definition: deprecated.h:81
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853