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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
icmpv4.h
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 */
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::Icmpv4Echo::Print
virtual void Print(std::ostream &os) const
Definition:
icmpv4.cc:262
ns3::Icmpv4DestinationUnreachable::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
icmpv4.cc:338
ns3::Ptr< const Packet >
ns3::Icmpv4Echo::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
icmpv4.cc:225
ns3::Icmpv4TimeExceeded
Definition:
icmpv4.h:129
ns3::Icmpv4TimeExceeded::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
icmpv4.cc:456
ns3::Icmpv4TimeExceeded::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
icmpv4.cc:473
ns3::Icmpv4TimeExceeded::Print
virtual void Print(std::ostream &os) const
Definition:
icmpv4.cc:487
ns3::Icmpv4Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
icmpv4.cc:92
ns3::Icmpv4TimeExceeded::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
icmpv4.cc:462
ns3::Icmpv4Header
Definition:
icmpv4.h:33
ns3::Icmpv4Header::Print
virtual void Print(std::ostream &os) const
Definition:
icmpv4.cc:101
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::Icmpv4Echo::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
icmpv4.cc:237
ns3::Icmpv4Header::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
icmpv4.cc:68
ns3::Ipv4Header
Packet header for IPv4.
Definition:
ipv4-header.h:31
ns3::Icmpv4Echo::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
icmpv4.cc:231
ns3::Icmpv4Header::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
icmpv4.cc:62
ns3::Icmpv4Echo
Definition:
icmpv4.h:65
ns3::Icmpv4DestinationUnreachable::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
icmpv4.cc:362
ns3::Icmpv4DestinationUnreachable::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
icmpv4.cc:344
ns3::Icmpv4DestinationUnreachable
Definition:
icmpv4.h:92
ns3::Icmpv4TimeExceeded::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
icmpv4.cc:450
ns3::Icmpv4Echo::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
icmpv4.cc:245
ns3::Icmpv4Header::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
icmpv4.cc:74
ns3::Icmpv4DestinationUnreachable::Print
virtual void Print(std::ostream &os) const
Definition:
icmpv4.cc:377
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:44
ns3::Icmpv4DestinationUnreachable::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
icmpv4.cc:350
src
internet
model
icmpv4.h
Generated on Sun Mar 16 2014 11:25:04 for ns-3 by
1.8.6