欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

IIlustration of the IPv4 Header

程序员文章站 2022-06-24 18:18:30
...


IIlustration of the IPv4 Header
            
    
    博客分类: 网络编程 IPTCPUDPHeader网络编程 

 

version: the version of ip service, For IPv4, its value is 4, for IPV6, its value is 6.


header length: the length of ip header, the maximum value is 60 because of using 4 bits representing the length. Generally, its value is 20.

 

type of service: the 8 bits are divided into 3 parts. the first part using 3 bits has been discarded, the second part uses 4 bits,  each bit denotes a functionality.

 

the first bit tells ip module using strategy of minimum delay; the second bit tells ip module using strategy of maxmum throughput; the third bit tells ip module

 

using strategy of maxmum reliability and the fourth bit tells ip module using strategy of minimum cost. The four bits can be only one bit set to 1 at a time.

 

The last bit of type of service is reserved, not using.

 

total length: the length of IP datagram including length of ip header and length of data.

 

identification: It is unique to identify a datagram. Its value is produced randomly. Its value is automatically added by 1 after sending a datagram and would be copied

 

to each fragmentation, therefore all of fragmentations have the same identification.

 

flags: It indicates if there are fragmentations. the first bit is reserved. The second bit denotes "Don't Fragment", if this flag is set, ip module would not fragment datagram.

 

In this situation, if the length of datagram is greater than the MTU, ip module would abandon this datagram and return an ICMP error datagram. The third bit denotes "More Fragment".

 

Other fragmentation must set this bit to 1 except the last fragmentaion in the same group.

 

fragmentaion offset: It indicates the data offset, not including header, of a fragmentation relativing to the original datagram. The actual value using by ip module is the value left

 

shifting 3 bits, which means the length of each fragmentation must be multiples of 8 except the last fragmentation in the same group.

 

time to live: it denotes the maxmum passed steps of the datagram from source  to destination, the value is generally set to 64. the value would be subtracted by 1 while the datagram

 

passed a router. while the value is 0, router would abandon datagram and reuturn an ICMP error datagram. This value can avoid data falling into the trap of Routing Loops.

 

protocol: It can be used to distinguish the protocol of upper layer, TCP, UDP, ICMP and so on.

 

header checksum: It is filled by sender and used by receiver to check if the header of ip datagram is entire and valid.

 

source IP address: It denotes the IP address of sender.

 

destination IP address: It denotes the IP address of receiver.

 

options: They are not used often and here we will not illustrate them.

 

  • IIlustration of the IPv4 Header
            
    
    博客分类: 网络编程 IPTCPUDPHeader网络编程 
  • 大小: 8.3 KB