Worklog for Sub_Zero

Raw Socket test

Return to Worklogs

The first steps.... Understanding and then implementing(Posted 2007-01-02)
This christmas holiday I decided to fool around and learn the IP (Internet Protocol) and ICMP (Internet Control Message Protocol) protocols.
Determined to learn these packet layouts and layers from scratch (without using any library); reading specs on the internet, googling, googling some more.

Upon researching, I realized that the ICMP (Internet Control Message Protocol, RFC792), actually is essential to the IP protocol (Internet Protocol, RFC791).
According to the standards (RFC), any networking device, or networking software, that handles the IP Protocol, should also handle the ICMP protocol. Why? One example is that ICMP is used to send a detailed message back to the source if something goes wrong with the initial IP packet, for example a Destination Unreachable Message.

So, the IP protocol would not work well without the ICMP protocol, and the ICMP protocol will not be possible without the IP protocol.
It's all set up in protocol layers where the IP layer always is the first layer. If an ICMP packet is being sent, it will always be encapsulated in a IP packet, so the icmp packet will appear in a layer ontop the IP layer.
Neither the IP or ICMP protocols use any network ports.

Using SOCK_RAW, instead of maybe SOCK_STREAM (TCP (Transmission Control Protocol)) or SOCK_DGRAM (UDP (User Datagram Protocol)), a raw network socket can be opened, where you define yourself the structure of the protocols/packets to be sent/received.

I've managed to send icmp echo messages (ping requests) to my router, and even get echo reply messages (ping replies) in return. However, I'm still having a look at the calculation of the ICMP checksum, since ethereal (A network protocol/packet sniffer/capture software) is reporting that the checksum is incorrect, even if my router does reply to the echo request.
There's still a lot of work to do.

The ICMP protocol is so much more than just echo and echo reply packets.

Depending on how much spare time I have, I might eventually do a blitzmax ICMP type.