NetSim Source Code Help
Loading...
Searching...
No Matches
ICMP.h
Go to the documentation of this file.
1/************************************************************************************
2 * Copyright (C) 2020 *
3 * TETCOS, Bangalore. India *
4 * *
5 * Tetcos owns the intellectual property rights in the Product and its content. *
6 * The copying, redistribution, reselling or publication of any or all of the *
7 * Product or its content without express prior written consent of Tetcos is *
8 * prohibited. Ownership and / or any other right relating to the software and all *
9 * intellectual property rights therein shall remain at all times with Tetcos. *
10 * *
11 * Author: Shashi Kant Suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14
15/***********************************************************************
16
17Network Working Group J. Postel
18Request for Comments: 792 ISI
19 September 1981
20Updates: RFCs 777, 760
21Updates: IENs 109, 128
22
23 INTERNET CONTROL MESSAGE PROTOCOL
24
25 DARPA INTERNET PROGRAM
26 PROTOCOL SPECIFICATION
27
28*************************************************************************/
29
30#ifndef _NETSIM_ICMP_H_
31#define _NETSIM_ICMP_H_
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define ICMP_MAX_RETRY 5
37#define ICMP_SEND_TIME (1*SECOND)
38
39 //Typedef of ICMP message
43
44 /**
45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46 As per RFC 792 page 3 :
47 Destination Unreachable Message
48
49 0 1 2 3
50 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
51 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 | Type | Code | Checksum |
53 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 | unused |
55 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 | Internet Header + 64 bits of Original Data Datagram |
57 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 */
61 {
62 char Type; //3
63 char code; /**<
64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65 0 = net unreachable;
66 1 = host unreachable;
67 2 = protocol unreachable;
68 3 = port unreachable;
69 4 = fragmentation needed and DF set;
70 5 = source route failed.
71 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 */
73 unsigned short int Checksum; /**<
74 The checksum is the 16-bit ones's complement of the one's
75 complement sum of the ICMP message starting with the ICMP Type.
76 For computing the checksum , the checksum field should be zero.
77 This checksum may be replaced in the future.
78 */
79 unsigned int unused;
80 void* InternetHeader; /**<
81 The internet header plus the first 64 bits of the original
82 datagram's data. This data is used by the host to match the
83 message to the appropriate process. If a higher level protocol
84 uses port numbers, they are assumed to be in the first 64 data
85 bits of the original datagram's data.
86 */
87 };
88
89
90 /**
91 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92 RFC 792 page 13
93 Echo or Echo Reply Message
94
95 0 1 2 3
96 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
97 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98 | Type | Code | Checksum |
99 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
100 | Identifier | Sequence Number |
101 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
102 | Data ...
103 +-+-+-+-+-
104 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 */
107 {
108 char Type; /**<
109 ~~~~~~~~~~~~~~~~~~~~~~~~~
110 8 for echo message;
111 0 for echo reply message.
112 ~~~~~~~~~~~~~~~~~~~~~~~~~
113 */
114 char Code; //0
115 unsigned short int Checksum; /**<
116 The checksum is the 16-bit ones's complement of the one's
117 complement sum of the ICMP message starting with the ICMP Type.
118 For computing the checksum , the checksum field should be zero.
119 If the total length is odd, the received data is padded with one
120 octet of zeros for computing the checksum. This checksum may be replaced in the future.
121 */
122 unsigned short int Identifier; ///< If code = 0, an identifier to aid in matching echos and replies,may be zero.
123 unsigned short int SequenceNumber; ///< If code = 0, a sequence number to aid in matching echos and replies, may be zero.
124 void* Data;
125 };
126
127/**
128 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129 Network Working Group S. Deering, Editor
130 Request for Comments: 1256 Xerox PARC
131 September 1991
132
133
134 ICMP Router Advertisement Message
135
136 0 1 2 3
137 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
138 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 | Type | Code | Checksum |
140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 | Num Addrs |Addr Entry Size| Lifetime |
142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 | Router Address[1] |
144 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 | Preference Level[1] |
146 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
147 | Router Address[2] |
148 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149 | Preference Level[2] |
150 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151 | . |
152 | . |
153 | . |
154
155
156 IP Fields:
157
158 Source Address An IP address belonging to the interface
159 from which this message is sent.
160
161 Destination Address The configured AdvertisementAddress or the
162 IP address of a neighboring host.
163
164 Time-to-Live 1 if the Destination Address is an IP
165 multicast address; at least 1 otherwise.
166
167
168 ICMP Fields:
169
170 Type 9
171
172 Code 0
173
174 Checksum The 16-bit one's complement of the one's
175 complement sum of the ICMP message, start-
176 ing with the ICMP Type. For computing the
177 checksum, the Checksum field is set to 0.
178
179
180 Num Addrs The number of router addresses advertised
181 in this message.
182
183 Addr Entry Size The number of 32-bit words of information
184 per each router address (2, in the version
185 of the protocol described here).
186
187 Lifetime The maximum number of seconds that the
188 router addresses may be considered valid.
189
190 Router Address[i], The sending router's IP address(es) on the
191 i = 1..Num Addrs interface from which this message is sent.
192
193 Preference Level[i], The preferability of each Router Address[i]
194 i = 1..Num Addrs as a default router address, relative to
195 other router addresses on the same subnet.
196 A signed, twos-complement value; higher
197 values mean more preferable.
198 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199*/
201 {
202 char Type; //9
203 char Code; //0
204 unsigned short int CheckSum;
207 unsigned short int Lifetime;
209 unsigned int* PreferenceLevel;
210 };
211
212#ifdef __cplusplus
213}
214#endif
215#endif
unsigned short int Identifier
If code = 0, an identifier to aid in matching echos and replies,may be zero.
Definition: ICMP.h:122
unsigned short int Checksum
Definition: ICMP.h:115
unsigned short int SequenceNumber
If code = 0, a sequence number to aid in matching echos and replies, may be zero.
Definition: ICMP.h:123
unsigned short int Lifetime
Definition: ICMP.h:207
NETSIM_IPAddress * RouterAddress
Definition: ICMP.h:208
unsigned int * PreferenceLevel
Definition: ICMP.h:209
unsigned short int CheckSum
Definition: ICMP.h:204