A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ipv4-header.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#ifndef IPV4_HEADER_H
22
#define IPV4_HEADER_H
23
24
#include "ns3/header.h"
25
#include "ns3/ipv4-address.h"
26
27
namespace
ns3 {
31
class
Ipv4Header
:
public
Header
32
{
33
public
:
37
Ipv4Header
();
41
void
EnableChecksum
(
void
);
45
void
SetPayloadSize
(uint16_t size);
51
void
SetIdentification
(uint16_t identification);
55
void
SetTos
(uint8_t tos);
64
enum
DscpType
65
{
66
DscpDefault
= 0x00,
67
68
// Prefixed with "DSCP" to avoid name clash (bug 1723)
69
DSCP_CS1
= 0x20,
70
DSCP_AF11
= 0x28,
71
DSCP_AF12
= 0x30,
72
DSCP_AF13
= 0x38,
73
74
DSCP_CS2
= 0x40,
75
DSCP_AF21
= 0x48,
76
DSCP_AF22
= 0x50,
77
DSCP_AF23
= 0x58,
78
79
DSCP_CS3
= 0x60,
80
DSCP_AF31
= 0x68,
81
DSCP_AF32
= 0x70,
82
DSCP_AF33
= 0x78,
83
84
DSCP_CS4
= 0x80,
85
DSCP_AF41
= 0x88,
86
DSCP_AF42
= 0x90,
87
DSCP_AF43
= 0x98,
88
89
DSCP_CS5
= 0xA0,
90
DSCP_EF
= 0xB8,
91
92
DSCP_CS6
= 0xC0,
93
DSCP_CS7
= 0xE0
94
95
};
100
void
SetDscp
(
DscpType
dscp);
101
106
enum
EcnType
107
{
108
// Prefixed with "ECN" to avoid name clash (bug 1723)
109
ECN_NotECT
= 0x00,
110
ECN_ECT1
= 0x01,
111
ECN_ECT0
= 0x02,
112
ECN_CE
= 0x03
113
};
118
void
SetEcn
(
EcnType
ecn);
122
void
SetMoreFragments
(
void
);
126
void
SetLastFragment
(
void
);
130
void
SetDontFragment
(
void
);
134
void
SetMayFragment
(
void
);
141
void
SetFragmentOffset
(uint16_t offsetBytes);
145
void
SetTtl
(uint8_t ttl);
149
void
SetProtocol
(uint8_t num);
153
void
SetSource
(
Ipv4Address
source);
157
void
SetDestination
(
Ipv4Address
destination);
161
uint16_t
GetPayloadSize
(
void
)
const
;
165
uint16_t
GetIdentification
(
void
)
const
;
169
uint8_t
GetTos
(
void
)
const
;
173
DscpType
GetDscp
(
void
)
const
;
177
std::string
DscpTypeToString
(
DscpType
dscp)
const
;
181
EcnType
GetEcn
(
void
)
const
;
185
std::string
EcnTypeToString
(
EcnType
ecn)
const
;
189
bool
IsLastFragment
(
void
)
const
;
193
bool
IsDontFragment
(
void
)
const
;
197
uint16_t
GetFragmentOffset
(
void
)
const
;
201
uint8_t
GetTtl
(
void
)
const
;
205
uint8_t
GetProtocol
(
void
)
const
;
209
Ipv4Address
GetSource
(
void
)
const
;
213
Ipv4Address
GetDestination
(
void
)
const
;
214
221
bool
IsChecksumOk
(
void
)
const
;
222
223
static
TypeId
GetTypeId
(
void
);
224
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
225
virtual
void
Print
(std::ostream &os)
const
;
226
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
227
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
228
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
229
private
:
230
231
enum
FlagsE
{
232
DONT_FRAGMENT
= (1<<0),
233
MORE_FRAGMENTS
= (1<<1)
234
};
235
236
bool
m_calcChecksum
;
237
238
uint16_t
m_payloadSize
;
239
uint16_t
m_identification
;
240
uint32_t
m_tos
: 8;
//Also used as DSCP + ECN value
241
uint32_t
m_ttl
: 8;
242
uint32_t
m_protocol
: 8;
243
uint32_t
m_flags
: 3;
244
uint16_t
m_fragmentOffset
;
245
Ipv4Address
m_source
;
246
Ipv4Address
m_destination
;
247
uint16_t
m_checksum
;
248
bool
m_goodChecksum
;
249
uint16_t
m_headerSize
;
250
};
251
252
}
// namespace ns3
253
254
255
#endif
/* IPV4_HEADER_H */
src
internet
model
ipv4-header.h
Generated on Fri Aug 30 2013 01:42:51 for ns-3 by
1.8.1.2