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 
27 namespace ns3 {
28 
33 class Ipv6Header : public Header
34 {
35 public:
44  enum DscpType
45  {
46  DscpDefault = 0x00,
47 
48  // Prefixed with "DSCP" to avoid name clash (bug 1723)
49  DSCP_CS1 = 0x08, // octal 010
50  DSCP_AF11 = 0x0A, // octal 012
51  DSCP_AF12 = 0x0C, // octal 014
52  DSCP_AF13 = 0x0E, // octal 016
53 
54  DSCP_CS2 = 0x10, // octal 020
55  DSCP_AF21 = 0x12, // octal 022
56  DSCP_AF22 = 0x14, // octal 024
57  DSCP_AF23 = 0x16, // octal 026
58 
59  DSCP_CS3 = 0x18, // octal 030
60  DSCP_AF31 = 0x1A, // octal 032
61  DSCP_AF32 = 0x1C, // octal 034
62  DSCP_AF33 = 0x1E, // octal 036
63 
64  DSCP_CS4 = 0x20, // octal 040
65  DSCP_AF41 = 0x22, // octal 042
66  DSCP_AF42 = 0x24, // octal 044
67  DSCP_AF43 = 0x26, // octal 046
68 
69  DSCP_CS5 = 0x28, // octal 050
70  DSCP_EF = 0x2E, // octal 056
71 
72  DSCP_CS6 = 0x30, // octal 060
73  DSCP_CS7 = 0x38 // octal 070
74 
75  };
76 
82  {
84  IPV6_IPV4 = 4,
85  IPV6_TCP = 6,
86  IPV6_UDP = 17,
87  IPV6_IPV6 = 41,
95  IPV6_SCTP = 135,
98  };
99 
104  static TypeId GetTypeId (void);
105 
110  virtual TypeId GetInstanceTypeId (void) const;
111 
115  Ipv6Header (void);
116 
121  void SetTrafficClass (uint8_t traffic);
122 
127  uint8_t GetTrafficClass (void) const;
128 
133  void SetDscp (DscpType dscp);
134 
138  DscpType GetDscp (void) const;
139 
144  std::string DscpTypeToString (DscpType dscp) const;
145 
150  void SetFlowLabel (uint32_t flow);
151 
156  uint32_t GetFlowLabel (void) const;
157 
162  void SetPayloadLength (uint16_t len);
163 
168  uint16_t GetPayloadLength (void) const;
169 
174  void SetNextHeader (uint8_t next);
175 
180  uint8_t GetNextHeader (void) const;
181 
186  void SetHopLimit (uint8_t limit);
187 
192  uint8_t GetHopLimit (void) const;
193 
198  void SetSourceAddress (Ipv6Address src);
199 
204  Ipv6Address GetSourceAddress (void) const;
205 
211 
216  Ipv6Address GetDestinationAddress (void) const;
217 
223  virtual void Print (std::ostream& os) const;
224 
229  virtual uint32_t GetSerializedSize (void) const;
230 
235  virtual void Serialize (Buffer::Iterator start) const;
236 
242  virtual uint32_t Deserialize (Buffer::Iterator start);
243 
244 private:
248  uint32_t m_trafficClass : 8;
249 
254  uint32_t m_flowLabel : 20;
255 
259  uint16_t m_payloadLength;
260 
264  uint8_t m_nextHeader;
265 
269  uint8_t m_hopLimit;
270 
275 
280 };
281 
282 } /* namespace ns3 */
283 
284 #endif /* IPV6_HEADER_H */
285 
Protocol header serialization and deserialization.
Definition: header.h:42
uint8_t GetTrafficClass(void) const
Get the "Traffic class" field.
Definition: ipv6-header.cc:50
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Definition: ipv6-header.cc:143
uint8_t GetNextHeader(void) const
Get the next header.
Definition: ipv6-header.cc:80
void SetPayloadLength(uint16_t len)
Set the "Payload length" field.
Definition: ipv6-header.cc:65
uint32_t m_flowLabel
The flow label.
Definition: ipv6-header.h:254
Introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
def start()
Definition: core.py:1482
uint32_t m_trafficClass
The traffic class.
Definition: ipv6-header.h:248
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition: ipv6-header.cc:75
DscpType
DiffServ Code Points Code Points defined in Assured Forwarding (AF) RFC 2597 Expedited Forwarding (EF...
Definition: ipv6-header.h:44
Ipv6Address m_sourceAddress
The source address.
Definition: ipv6-header.h:274
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Definition: ipv6-header.cc:125
NextHeader_e
IPv6 next-header value.
Definition: ipv6-header.h:81
iterator in a Buffer instance
Definition: buffer.h:98
DscpType GetDscp(void) const
Definition: ipv6-header.cc:195
Ipv6Address m_destinationAddress
The destination address.
Definition: ipv6-header.h:279
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:164
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
Definition: ipv6-header.cc:90
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
Definition: ipv6-header.cc:130
uint16_t GetPayloadLength(void) const
Get the "Payload length" field.
Definition: ipv6-header.cc:70
std::string DscpTypeToString(DscpType dscp) const
Definition: ipv6-header.cc:202
Ipv6Header(void)
Constructor.
Definition: ipv6-header.cc:34
static TypeId GetTypeId(void)
Get the type identifier.
Definition: ipv6-header.cc:115
void SetSourceAddress(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:95
Describes an IPv6 address.
Definition: ipv6-address.h:48
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Definition: ipv6-header.cc:148
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
Definition: ipv6-header.cc:85
Ipv6Address GetSourceAddress(void) const
Get the "Source address" field.
Definition: ipv6-header.cc:100
void SetFlowLabel(uint32_t flow)
Set the "Flow label" field.
Definition: ipv6-header.cc:55
uint16_t m_payloadLength
The payload length.
Definition: ipv6-header.h:259
void SetTrafficClass(uint8_t traffic)
Set the "Traffic class" field.
Definition: ipv6-header.cc:45
uint8_t m_hopLimit
The Hop limit value.
Definition: ipv6-header.h:269
uint8_t m_nextHeader
The Next header number.
Definition: ipv6-header.h:264
a unique identifier for an interface.
Definition: type-id.h:58
void SetDestinationAddress(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:105
Ipv6Address GetDestinationAddress(void) const
Get the "Destination address" field.
Definition: ipv6-header.cc:110
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition: ipv6-header.cc:188