IP datagrams and IP headers

IP datagram and IP header

 After acquiring the address information of the communication partner, the packet containing the data is actually sent out. The packet (IP datagram) sent out from the IP layer consists of the IP header and data.

Here, we will discuss IP datagrams and IP headers.

◆ IP datagram

 The basic header part of the IP header consists of 20 bytes (160bit). Options are not mandatory.

◆IP header

I will explain the information of each field in the IP header.

 The IP header is 20 bytes by default, since the size of the basic header is 20 bytes. The options add up to over 20 bytes, but the overall size is always adjusted to be a multiple of 4 bytes.

A description of each field follows.

1. Version (4bit)

"4" indicates IPv4, "6" indicates IPv6.

protocol numberprotocol

2. Header length (4bit)

Indicates the length of the IP header.

3. TOS: Service type (8bit)

The TOS (Type of Service) bit stores a numerical value for determining the priority of IP packets.

4. Packet length (16bit)

Indicates the length of the entire packet including IP header and data.

The next three pieces of information, "identification number", "flag", and "fragment offset", are related to data division and assembly.

5. Identification number (16bit)

 When transporting large amounts of data, the size of the MTU may be exceeded at network boundaries. To send this data, it must be split into multiple packets and sent. At that time, it is used to identify whether it is originally the same divided data or completely different data.

 The same value is entered in the "identification number" in the IP header of the divided data. If the "identification number" is the same, you can see that the original data was originally one piece of data.

6. Flag (3bit)

Used to control IP packet fragmentation.

bit number meaning
bit 0 Reserved (unused)
bit 1 A value that indicates whether splitting is allowed or not
0 ・・・ Dividable
1 ・・・ Cannot be divided
bit 2 a value representing whether the fragment is the last
0 ・・・ Indicates that it is the last fragment.
1 --- Indicates that there is a subsequent packet.

7. Fragment offset (13bit)

 It shows where the divided packets are located in the original data. The unit is 8 octets, and the maximum is 8 x 8,192 (2 13 ) = 65,536 octets.

8. TTL: time to live (8bit)

 TTL (Time to Live) is the time to live. Basically, it decreases by 1 each time it passes through the router, and when it reaches 0, the packet is discarded.

9. Protocol (8bit)

Represents the upper layer protocol of IP, and the following protocols are defined.

protocol numberprotocol
FiveST (data stream

10. Header checksum (16bit)

 It is there to check if there are any errors in the IP packet. Since the TTL value changes every time it passes through a router, it is recalculated at each router each time it passes through a router.
It's there.

11. Source IP address (32bit)

Contains the IP address of the sender.

12. Destination IP address (32bit)

Enter the IP address of the destination.

13. Option (Variable)

Specifies options to be added to IP packets.

14. Padding: Padding (variable)

 If the option is specified, it is used to adjust the length by padding with 0 so that the length is a multiple of 32 bits (4 bytes).