To give an idea of how Internet Control Message Protocol – ICMP can handle the sending and receiving of ICMP messages, we present our version of an ICMP package made of two modules: an input module and an output module. Figure shows these two modules.
Input Model
The input module handles all received ICMP messages. It is invoked when an ICMP packet is delivered to it from the IP layer.
If the received packet is a request, the module creates a reply and sends it out. If the received packet is a redirection message, the module uses the information to update the routing table.
If the received packet is an error message, the module informs the protocol about the situation that caused the error.
The pseudocode is shown below:
1 ICMP_Input_module (ICMP_Packet) 2 { 3 If (the type is a request) 4 { 5 Create a reply 6 Send the reply 7 } 8 If (the type defines a redirection) 9 { 10 Modify the routing table 11 } 12 If (the type defines other error messages) 13 { 14 Inform the appropriate source protocol 15 } 16 Return 17 }
Output Model
The output module is responsible for creating request, solicitation, or error messages requested by a higher level or the IP protocol. The module receives a demand from IP, UDP, or TCP to send one of the Internet Control Message Protocol – ICMP error messages.
If the demand is from IP, the output module must first check that the request is allowed. Remember, an ICMP message cannot be created for four situations: an IP packet carrying an ICMP error message, a fragmented IP packet, a multicast IP packet, or an IP packet having IP address 0.0.0.0 or 127.X.Y. Z.
The output module may also receive a demand from an application program to send one of the ICMP request messages. The pseudocode is shown in Table.
1 ICMP_Output_Module (demand) 2 { 3 If (the demand defines an error message) 4 { 5 If (demand comes from IP AND is forbidden) 6 { 7 Return 8 } 9 If (demand is a valid redirection message) 10 { 11 Return 12 } 13 Create an error message 14 If (demand defines a request) 15 { 16 Create a request message 17 } 18 Send the message 19 Return 20 }
Read More Topics |
The address resolution protocol (ARP) |
Address mapping in computer networks |
Introduction to internet protocol |
Delivery and forwarding of IP packets |