IPv4 Packet
The header fields are discussed below:
- Version (always set to the value 4 in the current version of IP)
- IP Header Length (number of 32 -bit words forming the header, usually five)
- Type of Service (ToS), now known as Differentiated Services Code Point (DSCP) (usually set to 0, but may indicate particular Quality of Service needs from the network, the DSCP defines the way routers should queue packets while they are waiting to be forwarded).
- Total Length: Length of entire IP Packet (including IP header and IP Payload).
- Identification ( 16-bit number which together with the source address uniquely identifies this packet – used during reassembly of fragmented datagrams)
- Flags (a sequence of three flags (one of the 4 bits is unused) used to control whether routers are allowed to fragment a packet (i.e. the Don’t Fragment, DF, flag), and to indicate the parts of a packet to the receiver)
- Fragmentation Offset (a byte count from the start of the original sent packet, set by any router which performs IP router fragmentation)
- Time To Live (Number of hops /links which the packet may be routed over, decremented by most routers – used to prevent accidental routing loops)
- Protocol (Service Access Point (SAP) which indicates the type of transport packet being carried (e.g. 1 = ICMP; 2= IGMP; 6 = TCP; 17= UDP).
- Header Checksum (A 1’s complement checksum inserted by the sender and updated whenever the packet header is modified by a router – Used to detect processing errors introduced into the packet inside a router or bridge where the packet is not protected by a link layer cyclic redundancy check. Packets with an invalid checksum are discarded by all nodes in an IP network)
- Source Address (the IP address of the original sender of the packet)
- Destination Address (the IP address of the final destination of the packet)
- This is optional field, which is used if the value of IHL is greater than 5. These options may contain values for options such as Security, Record Route, Time Stamp, etc.
- Padding is basically used to make sure that the IP packet header has a length that is a multiple of 32 bits. It is needed because of the varying length of the options field in the IP header
IPV4 header is flexible in size and can vary from 20 bytes to 60 bytes. Usually it is 20 bytes in length.
Te Internet Protocol (IP) is defined in RFC 791. The RFC specifies the format of the IP header. In the header there is the IHL (Internet Header Length) field which is 4 bits long and specifies the header length in 32 bit words. The IHL field can hold values from 0 (Binary 0000) to 15 (Binary 1111).
So the longest Internet Header (IP header) size can be 15*32 Bits = 480 Bits = 60 Bytes. This is why the header has a maximum size of 60 Bytes.
The shortest header size is 20 bytes, where the IHL field has the value 5 (0101). This is because all the required fields in the header need 20 Bytes of space. So while in theory you could set the IHL to a value < 5 this would always be an incorrect value and thus an invalid packet header.
Total field in IPv4 is 13 and you can remember these by using the phrase as below.
VIT TIF FTP HSDO
V |
I |
T |
|
T |
I |
F |
|
F |
T |
P |
|
H |
S |
D |
O |
ver |
IHL |
TOS |
|
TL |
Indentifier |
Flag |
|
Fragment |
TTL |
Protocol |
|
Checksum |
SIP |
DIP |
Option |