A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
ipv4-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#ifndef IPV4_HEADER_H
21
#define IPV4_HEADER_H
22
23
#include "ns3/header.h"
24
#include "ns3/ipv4-address.h"
25
26
namespace
ns3
27
{
33
class
Ipv4Header
:
public
Header
34
{
35
public
:
39
Ipv4Header
();
43
void
EnableChecksum
();
47
void
SetPayloadSize
(uint16_t size);
53
void
SetIdentification
(uint16_t identification);
57
void
SetTos
(uint8_t tos);
58
59
public
:
71
enum
DscpType
72
{
73
DscpDefault
= 0x00,
74
75
// Prefixed with "DSCP" to avoid name clash (bug 1723)
76
DSCP_CS1
= 0x08,
// octal 010
77
DSCP_AF11
= 0x0A,
// octal 012
78
DSCP_AF12
= 0x0C,
// octal 014
79
DSCP_AF13
= 0x0E,
// octal 016
80
81
DSCP_CS2
= 0x10,
// octal 020
82
DSCP_AF21
= 0x12,
// octal 022
83
DSCP_AF22
= 0x14,
// octal 024
84
DSCP_AF23
= 0x16,
// octal 026
85
86
DSCP_CS3
= 0x18,
// octal 030
87
DSCP_AF31
= 0x1A,
// octal 032
88
DSCP_AF32
= 0x1C,
// octal 034
89
DSCP_AF33
= 0x1E,
// octal 036
90
91
DSCP_CS4
= 0x20,
// octal 040
92
DSCP_AF41
= 0x22,
// octal 042
93
DSCP_AF42
= 0x24,
// octal 044
94
DSCP_AF43
= 0x26,
// octal 046
95
96
DSCP_CS5
= 0x28,
// octal 050
97
DSCP_EF
= 0x2E,
// octal 056
98
99
DSCP_CS6
= 0x30,
// octal 060
100
DSCP_CS7
= 0x38
// octal 070
101
};
102
107
void
SetDscp
(
DscpType
dscp);
108
113
enum
EcnType
114
{
115
// Prefixed with "ECN" to avoid name clash (bug 1723)
116
ECN_NotECT
= 0x00,
117
ECN_ECT1
= 0x01,
118
ECN_ECT0
= 0x02,
119
ECN_CE
= 0x03
120
};
121
126
void
SetEcn
(
EcnType
ecn);
130
void
SetMoreFragments
();
134
void
SetLastFragment
();
138
void
SetDontFragment
();
142
void
SetMayFragment
();
149
void
SetFragmentOffset
(uint16_t offsetBytes);
153
void
SetTtl
(uint8_t ttl);
157
void
SetProtocol
(uint8_t
num
);
161
void
SetSource
(
Ipv4Address
source);
165
void
SetDestination
(
Ipv4Address
destination);
169
uint16_t
GetPayloadSize
()
const
;
173
uint16_t
GetIdentification
()
const
;
177
uint8_t
GetTos
()
const
;
181
DscpType
GetDscp
()
const
;
186
std::string
DscpTypeToString
(
DscpType
dscp)
const
;
190
EcnType
GetEcn
()
const
;
195
std::string
EcnTypeToString
(
EcnType
ecn)
const
;
199
bool
IsLastFragment
()
const
;
203
bool
IsDontFragment
()
const
;
207
uint16_t
GetFragmentOffset
()
const
;
211
uint8_t
GetTtl
()
const
;
215
uint8_t
GetProtocol
()
const
;
219
Ipv4Address
GetSource
()
const
;
223
Ipv4Address
GetDestination
()
const
;
224
231
bool
IsChecksumOk
()
const
;
232
237
static
TypeId
GetTypeId
();
238
TypeId
GetInstanceTypeId
()
const override
;
239
void
Print
(std::ostream& os)
const override
;
240
uint32_t
GetSerializedSize
()
const override
;
241
void
Serialize
(
Buffer::Iterator
start
)
const override
;
242
uint32_t
Deserialize
(
Buffer::Iterator
start
)
override
;
243
244
private
:
246
enum
FlagsE
247
{
248
DONT_FRAGMENT
= (1 << 0),
249
MORE_FRAGMENTS
= (1 << 1)
250
};
251
252
bool
m_calcChecksum
;
253
254
uint16_t
m_payloadSize
;
255
uint16_t
m_identification
;
256
uint32_t
m_tos
: 8;
257
uint32_t
m_ttl
: 8;
258
uint32_t
m_protocol
: 8;
259
uint32_t
m_flags
: 3;
260
uint16_t
m_fragmentOffset
;
261
Ipv4Address
m_source
;
262
Ipv4Address
m_destination
;
263
uint16_t
m_checksum
;
264
bool
m_goodChecksum
;
265
uint16_t
m_headerSize
;
266
};
267
268
}
// namespace ns3
269
270
#endif
/* IPV4_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ipv4Header
Packet header for IPv4.
Definition:
ipv4-header.h:34
ns3::Ipv4Header::m_source
Ipv4Address m_source
source address
Definition:
ipv4-header.h:261
ns3::Ipv4Header::IsChecksumOk
bool IsChecksumOk() const
Definition:
ipv4-header.cc:323
ns3::Ipv4Header::Print
void Print(std::ostream &os) const override
Definition:
ipv4-header.cc:347
ns3::Ipv4Header::SetDestination
void SetDestination(Ipv4Address destination)
Definition:
ipv4-header.cc:309
ns3::Ipv4Header::GetSource
Ipv4Address GetSource() const
Definition:
ipv4-header.cc:302
ns3::Ipv4Header::m_fragmentOffset
uint16_t m_fragmentOffset
Fragment offset.
Definition:
ipv4-header.h:260
ns3::Ipv4Header::SetDontFragment
void SetDontFragment()
Don't fragment this packet: if you need to anyway, drop it.
Definition:
ipv4-header.cc:224
ns3::Ipv4Header::EcnTypeToString
std::string EcnTypeToString(EcnType ecn) const
Definition:
ipv4-header.cc:177
ns3::Ipv4Header::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
ipv4-header.cc:340
ns3::Ipv4Header::FlagsE
FlagsE
flags related to IP fragmentation
Definition:
ipv4-header.h:247
ns3::Ipv4Header::MORE_FRAGMENTS
@ MORE_FRAGMENTS
Definition:
ipv4-header.h:249
ns3::Ipv4Header::DONT_FRAGMENT
@ DONT_FRAGMENT
Definition:
ipv4-header.h:248
ns3::Ipv4Header::GetTos
uint8_t GetTos() const
Definition:
ipv4-header.cc:196
ns3::Ipv4Header::SetLastFragment
void SetLastFragment()
This packet is the last packet of a fragmented ipv4 packet.
Definition:
ipv4-header.cc:210
ns3::Ipv4Header::m_ttl
uint32_t m_ttl
TTL.
Definition:
ipv4-header.h:257
ns3::Ipv4Header::m_protocol
uint32_t m_protocol
Protocol.
Definition:
ipv4-header.h:258
ns3::Ipv4Header::SetPayloadSize
void SetPayloadSize(uint16_t size)
Definition:
ipv4-header.cc:57
ns3::Ipv4Header::GetEcn
EcnType GetEcn() const
Definition:
ipv4-header.cc:169
ns3::Ipv4Header::m_identification
uint16_t m_identification
identification
Definition:
ipv4-header.h:255
ns3::Ipv4Header::GetIdentification
uint16_t GetIdentification() const
Definition:
ipv4-header.cc:71
ns3::Ipv4Header::IsDontFragment
bool IsDontFragment() const
Definition:
ipv4-header.cc:238
ns3::Ipv4Header::GetProtocol
uint8_t GetProtocol() const
Definition:
ipv4-header.cc:281
ns3::Ipv4Header::m_payloadSize
uint16_t m_payloadSize
payload size
Definition:
ipv4-header.h:254
ns3::Ipv4Header::SetTtl
void SetTtl(uint8_t ttl)
Definition:
ipv4-header.cc:267
ns3::Ipv4Header::IsLastFragment
bool IsLastFragment() const
Definition:
ipv4-header.cc:217
ns3::Ipv4Header::m_tos
uint32_t m_tos
TOS, also used as DSCP + ECN value.
Definition:
ipv4-header.h:256
ns3::Ipv4Header::m_goodChecksum
bool m_goodChecksum
true if checksum is correct
Definition:
ipv4-header.h:264
ns3::Ipv4Header::SetMoreFragments
void SetMoreFragments()
This packet is not the last packet of a fragmented ipv4 packet.
Definition:
ipv4-header.cc:203
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination() const
Definition:
ipv4-header.cc:316
ns3::Ipv4Header::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
ipv4-header.cc:392
ns3::Ipv4Header::SetDscp
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition:
ipv4-header.cc:92
ns3::Ipv4Header::m_destination
Ipv4Address m_destination
destination address
Definition:
ipv4-header.h:262
ns3::Ipv4Header::SetMayFragment
void SetMayFragment()
If you need to fragment this packet, you can do it.
Definition:
ipv4-header.cc:231
ns3::Ipv4Header::EcnType
EcnType
ECN Type defined in RFC 3168
Definition:
ipv4-header.h:114
ns3::Ipv4Header::ECN_ECT0
@ ECN_ECT0
Definition:
ipv4-header.h:118
ns3::Ipv4Header::ECN_NotECT
@ ECN_NotECT
Definition:
ipv4-header.h:116
ns3::Ipv4Header::ECN_ECT1
@ ECN_ECT1
Definition:
ipv4-header.h:117
ns3::Ipv4Header::ECN_CE
@ ECN_CE
Definition:
ipv4-header.h:119
ns3::Ipv4Header::m_checksum
uint16_t m_checksum
checksum
Definition:
ipv4-header.h:263
ns3::Ipv4Header::m_headerSize
uint16_t m_headerSize
IP header size.
Definition:
ipv4-header.h:265
ns3::Ipv4Header::GetDscp
DscpType GetDscp() const
Definition:
ipv4-header.cc:108
ns3::Ipv4Header::GetPayloadSize
uint16_t GetPayloadSize() const
Definition:
ipv4-header.cc:64
ns3::Ipv4Header::SetEcn
void SetEcn(EcnType ecn)
Set ECN Field.
Definition:
ipv4-header.cc:100
ns3::Ipv4Header::DscpType
DscpType
DiffServ codepoints.
Definition:
ipv4-header.h:72
ns3::Ipv4Header::DSCP_AF23
@ DSCP_AF23
Definition:
ipv4-header.h:84
ns3::Ipv4Header::DSCP_CS2
@ DSCP_CS2
Definition:
ipv4-header.h:81
ns3::Ipv4Header::DscpDefault
@ DscpDefault
Definition:
ipv4-header.h:73
ns3::Ipv4Header::DSCP_AF31
@ DSCP_AF31
Definition:
ipv4-header.h:87
ns3::Ipv4Header::DSCP_AF32
@ DSCP_AF32
Definition:
ipv4-header.h:88
ns3::Ipv4Header::DSCP_AF13
@ DSCP_AF13
Definition:
ipv4-header.h:79
ns3::Ipv4Header::DSCP_AF22
@ DSCP_AF22
Definition:
ipv4-header.h:83
ns3::Ipv4Header::DSCP_AF43
@ DSCP_AF43
Definition:
ipv4-header.h:94
ns3::Ipv4Header::DSCP_AF11
@ DSCP_AF11
Definition:
ipv4-header.h:77
ns3::Ipv4Header::DSCP_CS3
@ DSCP_CS3
Definition:
ipv4-header.h:86
ns3::Ipv4Header::DSCP_AF42
@ DSCP_AF42
Definition:
ipv4-header.h:93
ns3::Ipv4Header::DSCP_AF21
@ DSCP_AF21
Definition:
ipv4-header.h:82
ns3::Ipv4Header::DSCP_AF33
@ DSCP_AF33
Definition:
ipv4-header.h:89
ns3::Ipv4Header::DSCP_AF12
@ DSCP_AF12
Definition:
ipv4-header.h:78
ns3::Ipv4Header::DSCP_CS5
@ DSCP_CS5
Definition:
ipv4-header.h:96
ns3::Ipv4Header::DSCP_EF
@ DSCP_EF
Definition:
ipv4-header.h:97
ns3::Ipv4Header::DSCP_CS4
@ DSCP_CS4
Definition:
ipv4-header.h:91
ns3::Ipv4Header::DSCP_CS7
@ DSCP_CS7
Definition:
ipv4-header.h:100
ns3::Ipv4Header::DSCP_CS6
@ DSCP_CS6
Definition:
ipv4-header.h:99
ns3::Ipv4Header::DSCP_CS1
@ DSCP_CS1
Definition:
ipv4-header.h:76
ns3::Ipv4Header::DSCP_AF41
@ DSCP_AF41
Definition:
ipv4-header.h:92
ns3::Ipv4Header::DscpTypeToString
std::string DscpTypeToString(DscpType dscp) const
Definition:
ipv4-header.cc:116
ns3::Ipv4Header::m_flags
uint32_t m_flags
flags
Definition:
ipv4-header.h:259
ns3::Ipv4Header::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
ipv4-header.cc:384
ns3::Ipv4Header::GetFragmentOffset
uint16_t GetFragmentOffset() const
Definition:
ipv4-header.cc:254
ns3::Ipv4Header::SetProtocol
void SetProtocol(uint8_t num)
Definition:
ipv4-header.cc:288
ns3::Ipv4Header::SetFragmentOffset
void SetFragmentOffset(uint16_t offsetBytes)
The offset is measured in bytes for the packet start.
Definition:
ipv4-header.cc:245
ns3::Ipv4Header::SetIdentification
void SetIdentification(uint16_t identification)
Definition:
ipv4-header.cc:78
ns3::Ipv4Header::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
ipv4-header.cc:330
ns3::Ipv4Header::GetTtl
uint8_t GetTtl() const
Definition:
ipv4-header.cc:274
ns3::Ipv4Header::EnableChecksum
void EnableChecksum()
Enable checksum calculation for this header.
Definition:
ipv4-header.cc:50
ns3::Ipv4Header::SetTos
void SetTos(uint8_t tos)
Definition:
ipv4-header.cc:85
ns3::Ipv4Header::SetSource
void SetSource(Ipv4Address source)
Definition:
ipv4-header.cc:295
ns3::Ipv4Header::Ipv4Header
Ipv4Header()
Construct a null IPv4 header.
Definition:
ipv4-header.cc:34
ns3::Ipv4Header::m_calcChecksum
bool m_calcChecksum
true if the checksum must be calculated
Definition:
ipv4-header.h:252
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
two-ray-to-three-gpp-ch-calibration.num
num
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
src
internet
model
ipv4-header.h
Generated on Sun Mar 3 2024 17:10:58 for ns-3 by
1.9.1