I’m currently experimenting with the Icmp protocol and I would like to implement a new class IcmpPacket.
I read about the protocol on Wikipedia and I also found an article about pinging with Icmp on MSDN.
I’m a bit confused because of some differences between both websites.
Wikipedia defines the structure of a Icmp packet as the following:
1 Byte Type
1 Byte Code
2 Byte Checksum
4 Byte Rest of header (whatever this is)
On MSDN there is an example given for such an IcmpPacket class (extract of the class)
public class IcmpPacket {
public byte Type;
public byte SubCode;
public UInt16 CheckSum;
public UInt16 Identifier;
public UInt16 SequenceNumber;
public byte[] Data;
}
the first three attributes are clear but what about Identifier and SequenceNumber (=> Rest of header?)
Another question I got is if I would like to use an IcmpPacket to ping a server, do I really need Identifier, SequenceNumber and Data? (My hoster said that the smallest IcmpPacket possible is about 28Bytes large, so if taking Identifier and SequenceNumber, do I have to fill the remaining 20 Bytes with Data?)
P.S.: Is there maybe a website out which well describes the structure if Icmp?
Identifier and SequenceNumber are values meaningful to your implementation to match echo requests with the corresponding echo replies. RFC 792 offers a suggestion for using them…
Identifier, SequenceNumber and Data fields must exist in the frame…
If they are talking about a 28 byte IPv4 packet, then the smallest packet must include the minimum 20-byte IPv4 header + 8 bytes of ICMP header.
You should read RFC 792 online…