1. Overview
Lab 7 focuses parsing the different kinds of packets that Internet routers interact with. This document contains a summary of the header formats you are expected to encounter. The original RFCs, and Wikipedia summary pages are listed as follows:
-
Ethernet - RFC / Wikipedia / Visual Representation of Ethernet Header
-
ARP - RFC / Wikipedia / Visual Representation of ARP Header
-
IPv4 - RFC / Wikipedia / Visual Representation of IP Header
-
ICMP - RFC / Wikipedia / Visual Representation of ICMP Header
2. Ethernet
-
MAC destination (48 bits): 6 octets containing the destination MAC address
-
MAC source (48 bits): 6 octets containing the source MAC address
-
Ethertype or length (16 bits): Either the size of the payload in octets, or an Ethertype, which indicates the protocol encasulated in the frame. For the purposes of this lab, you can always assume it will be an Ethertype
-
Payload (variable length): The payload of the Ethernet packet. Size determined by previous field.
-
Frame check sequence (32 bits): A 4 octet cyclic redundancy check that allows checking for corrupted data.
3. ARP
-
HTYPE (16 bits): Two octets specifying the hardware type, the protocol used in the link layer that is being resolved (e.g. 1 for Ethernet)
-
PTYPE (16 bits): Two octets specifying the protocol type, the protocol used in the network layer (e.g. 0x0800 for IPv4)
-
HLEN (8 bits): One octet representing the length of a hardware address.
-
PLEN (8 bits): One octet representing the length of a internetwork address.
-
Operation (16 bits): Two octets specifying the requested operation. 1 for request, 2 for reply.
-
Sender Hardware Adress (variable length): Hardware address of the sender.
-
Sender Protocol Adress (variable length): Internetwork address of the sender.
-
Target Hardware Adress (variable length): Hardware address of the target. In a request, this is set to the broadcast address.
-
Target Hardware Adress (variable length): Internetwork address of the target.
4. IPv4
-
Version (4 bits): The version of the IP header. For IPv4, this should always be 4.
-
IHL (4 bits): The length of the header in 32 bit words.
-
Type of Service (8 bits): An octet field that can be used to specify a request for a particular type of service on the network
-
Total Length (16 bits): A two octet field specifying the length of the datagram in octets, including this header and the data.
-
Identification (16 bits): Two octets that are used to help reassemble fragmented packets.
-
Flags (3 bits): Various flags that help control fragmentation.
-
Fragment Offset (13 bits): The fragment offset of this fragment measured in octets.
-
Time to Live (8 bits): An octet representing the remaining time the datagram is allowed to remain on the internet before being dropped.
-
Protocol (8 bits): An octet representing the next protocol encapsulated by the header.
-
Header Checksum (16 bits): A two octet checksum on the header.
-
Source Address (32 bits): The 32 bit IPv4 address of the sender.
-
Destination Address (32 bits): The 32 bit IPv4 address of the destination.
-
Options (variable length): A variable length set of options on the datagram.
5. ICMP
-
Type (8 bits): An octet containing the ICMP type, which represents the kind of operation requested. For this lab, you use 0 (echo reply), 3 (destination unreachable), and 11 (Time exceeded)
-
Code (8 bits): An octet containing a code that indicates different statuses based on the type field. For the purposes of this lab, this can always be set to 0.
-
Checksum (16 bits): Two octet checksum of the ICMP header and data
-
Body (variable length): Variable length whose contents changes depending on the type and code of the ICMP header.