New to Busy?

What is ICMP?

2 comments

alexcodes
42
3 years agoSteemit2 min read

What is ICMP? How are we going to use it in our program?

ICMP stands for Internet Control Message Protocol. It is used by network devices to send error messages and operational information. For instance, we want to know if a device is connected to the LAN, so we ping it with an ICMP packet, and then we get response indicating whether it is or is not online.

The ICMP packet is 32 bytes in length.
IP Header - 20 bytes
ICMP Header - 8 bytes
ICMP Payload - 4 bytes
ICMP_packet.png

We can forget about the technicals of the IP Header since Python will take care of that for us.

Within the ICMP packet we have the following variables:

Type - 1 byte; here we specify what type of message this is. For ping, we use 8, which represents the Echo Request type.
Code - 1 byte; A type can have codes that mean different things. Our code will be 0
Checksum - 2 bytes; this is for error checking purposes. Did the entire packet reach it's destination? Is the data the same as when it was sent? We will find out here.
Header data - 4 bytes; In here we keep a copy of the IP header and

That's about it for ICMP, now we just have to make the magic happen in a Python script. In the next section we are going to go over network communication in Python. We need to know how that works in order to combine the forces of the Python networking standard library (socket) and our knowledge of ICMP.

PS - I apologize for not having any code in here yet, but in order to write a nice script, we have to know the background details first.

Comments

Sort byBest