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
icmpv4.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 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 ICMPV4_H
22
#define ICMPV4_H
23
24
#include "ns3/header.h"
25
#include "ns3/ptr.h"
26
#include "ns3/ipv4-header.h"
27
#include <stdint.h>
28
29
namespace
ns3 {
30
31
class
Packet;
32
33
class
Icmpv4Header
:
public
Header
34
{
35
public
:
36
enum
{
37
ECHO_REPLY
= 0,
38
DEST_UNREACH
= 3,
39
ECHO
= 8,
40
TIME_EXCEEDED
= 11
41
};
42
43
void
EnableChecksum
(
void
);
44
void
SetType
(uint8_t type);
45
void
SetCode
(uint8_t code);
46
47
uint8_t
GetType
(
void
)
const
;
48
uint8_t
GetCode
(
void
)
const
;
49
50
static
TypeId
GetTypeId
(
void
);
51
Icmpv4Header
();
52
virtual
~Icmpv4Header
();
53
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
54
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
55
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
56
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
57
virtual
void
Print
(std::ostream &os)
const
;
58
59
private
:
60
uint8_t
m_type
;
61
uint8_t
m_code
;
62
bool
m_calcChecksum
;
63
};
64
65
class
Icmpv4Echo
:
public
Header
66
{
67
public
:
68
void
SetIdentifier
(uint16_t
id
);
69
void
SetSequenceNumber
(uint16_t seq);
70
void
SetData
(
Ptr<const Packet>
data
);
71
uint16_t
GetIdentifier
(
void
)
const
;
72
uint16_t
GetSequenceNumber
(
void
)
const
;
73
uint32_t
GetDataSize
(
void
)
const
;
74
uint32_t
GetData
(uint8_t payload[])
const
;
75
76
77
static
TypeId
GetTypeId
(
void
);
78
Icmpv4Echo
();
79
virtual
~Icmpv4Echo
();
80
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
81
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
82
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
83
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
84
virtual
void
Print
(std::ostream &os)
const
;
85
private
:
86
uint16_t
m_identifier
;
87
uint16_t
m_sequence
;
88
uint8_t *
m_data
;
89
uint32_t
m_dataSize
;
90
};
91
92
class
Icmpv4DestinationUnreachable
:
public
Header
93
{
94
public
:
95
enum
{
96
NET_UNREACHABLE
= 0,
97
HOST_UNREACHABLE
= 1,
98
PROTOCOL_UNREACHABLE
= 2,
99
PORT_UNREACHABLE
= 3,
100
FRAG_NEEDED
= 4,
101
SOURCE_ROUTE_FAILED
= 5
102
};
103
static
TypeId
GetTypeId
(
void
);
104
Icmpv4DestinationUnreachable
();
105
virtual
~Icmpv4DestinationUnreachable
();
106
107
void
SetNextHopMtu
(uint16_t mtu);
108
uint16_t
GetNextHopMtu
(
void
)
const
;
109
110
void
SetData
(
Ptr<const Packet>
data
);
111
void
SetHeader
(
Ipv4Header
header);
112
113
void
GetData
(uint8_t payload[8])
const
;
114
Ipv4Header
GetHeader
(
void
)
const
;
115
116
private
:
117
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
118
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
119
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
120
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
121
virtual
void
Print
(std::ostream &os)
const
;
122
private
:
123
uint16_t
m_nextHopMtu
;
124
Ipv4Header
m_header
;
125
uint8_t
m_data
[8];
126
};
127
128
129
class
Icmpv4TimeExceeded
:
public
Header
130
{
131
public
:
132
enum
{
133
TIME_TO_LIVE
= 0,
134
FRAGMENT_REASSEMBLY
= 1
135
};
136
137
void
SetData
(
Ptr<const Packet>
data
);
138
void
SetHeader
(
Ipv4Header
header);
139
140
void
GetData
(uint8_t payload[8])
const
;
141
Ipv4Header
GetHeader
(
void
)
const
;
142
143
static
TypeId
GetTypeId
(
void
);
144
Icmpv4TimeExceeded
();
145
virtual
~Icmpv4TimeExceeded
();
146
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
147
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
148
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
149
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
150
virtual
void
Print
(std::ostream &os)
const
;
151
152
private
:
153
Ipv4Header
m_header
;
154
uint8_t
m_data
[8];
155
};
156
157
}
// namespace ns3
158
159
#endif
/* ICMPV4_H */
src
internet
model
icmpv4.h
Generated on Tue Oct 9 2012 16:45:38 for ns-3 by
1.8.1.2