Standards/Ethernet/Ping
(→ICMP header) |
|||
(One intermediate revision by one user not shown) | |||
Line 17: | Line 17: | ||
00 0c 29 7d ae c7 00 50 56 c0 00 08 08 00 | 00 0c 29 7d ae c7 00 50 56 c0 00 08 08 00 | ||
− | IP header with protocol <code>01</code>: | + | the IP header with protocol <code>01</code>: |
45 00 | 45 00 | ||
00 26 ba 96 00 00 40 01 3a 6f c0 a8 02 01 c0 a8 | 00 26 ba 96 00 00 40 01 3a 6f c0 a8 02 01 c0 a8 | ||
02 80 | 02 80 | ||
− | [https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Header ICMP header] with echo request (<code>0800</code>): | + | an [https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Header ICMP header] with echo request (<code>0800</code>) type: |
08 00 ee dd 12 04 00 00 | 08 00 ee dd 12 04 00 00 | ||
Line 44: | Line 44: | ||
== ICMP header == | == ICMP header == | ||
+ | |||
+ | {| class="wikitable" style="margin: 0 auto; text-align: center;" | ||
+ | |- align="center" | ||
+ | ! byte\bit offset | ||
+ | ! colspan="16" width="150px" | 0 – 7 | ||
+ | ! colspan="16" width="150px" | 8 – 15 | ||
+ | |- align="center" | ||
+ | ! 0 | ||
+ | | colspan="16" | [[#Type and code|Type]] | ||
+ | | colspan="16" | [[#Type and code|Code]] | ||
+ | |- align="center" | ||
+ | ! 2 | ||
+ | | colspan="32" | [[#Checksum|Checksum]] | ||
+ | |- align="center" | ||
+ | |} | ||
+ | |||
+ | === Type and code === | ||
+ | |||
+ | The [https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages ICMP control messages] are specified by a type and a code which serves as a subtype. | ||
+ | |||
+ | For ping, we have: | ||
+ | * 0 / 0 : [https://en.wikipedia.org/wiki/Ping_(networking_utility)#Echo_reply echo reply] | ||
+ | * 8 / 0 : [https://en.wikipedia.org/wiki/Ping_(networking_utility)#Echo_request echo request] | ||
+ | |||
+ | === Checksum === | ||
+ | |||
+ | The [https://tools.ietf.org/html/rfc792 checksum] is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type. | ||
+ | For computing the checksum , the checksum field is set to zero. | ||
+ | If the total length is odd, the data is padded with one octet of zeros for computing the checksum. |
Latest revision as of 10:52, 7 March 2016
|
Frame examples
Ping echo request
Typing in a terminal:
ping -c 1 -s 10 -p 0102 192.168.2.128
creates the frame:
00 0c 29 7d ae c7 00 50 56 c0 00 08 08 00 45 00 00 26 ba 96 00 00 40 01 3a 6f c0 a8 02 01 c0 a8 02 80 08 00 ee dd 12 04 00 00 56 dd 33 e1 00 01 6b 5c 01 02
This frame contains the Ethernet header, with destination and source MAC addresses and IP Ethertype (0800
):
00 0c 29 7d ae c7 00 50 56 c0 00 08 08 00
the IP header with protocol 01
:
45 00 00 26 ba 96 00 00 40 01 3a 6f c0 a8 02 01 c0 a8 02 80
an ICMP header with echo request (0800
) type:
08 00 ee dd 12 04 00 00
and 10 bytes data:
56 dd 33 e1 00 01 6b 5c 01 02
The first 8 data bytes provide an identifier and a sequence number. The last 2 bytes come from the pattern requested in the ping command.
Ping echo reply
The previous echo request receives as answer:
00 50 56 c0 00 08 00 0c 29 7d ae c7 08 00 45 00 00 26 fa 0b 00 00 80 01 ba f9 c0 a8 02 80 c0 a8 02 01 00 00 f6 dd 12 04 00 00 56 dd 33 e1 00 01 6b 5c 01 02
The ICMP header now has echo reply code (0000
).
It provides the same data as the echo request message.
ICMP header
byte\bit offset | 0 – 7 | 8 – 15 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Type | Code | ||||||||||||||||||||||||||||||
2 | Checksum |
Type and code
The ICMP control messages are specified by a type and a code which serves as a subtype.
For ping, we have:
- 0 / 0 : echo reply
- 8 / 0 : echo request
Checksum
The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type. For computing the checksum , the checksum field is set to zero. If the total length is odd, the data is padded with one octet of zeros for computing the checksum.