What is ICMP?

in python •  8 years ago  (edited)

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.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Cool, I'll be following this :) Brush up on some "legacy I.T" :'D

Congratulations @alexcodes! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update
Vote for @Steemitboard as a witness to get one more award and increased upvotes!