1. 程式人生 > 其它 >IP資料包格式總結

IP資料包格式總結

IP資料包格式總結

覺得這幾種圖能代表相關思想(感謝國外的原創作者)

IPv4 - Packet Structure

Internet Protocol Version 4 (IPv4)
Internet Protocol is one of the major protocols in the TCP/IP protocols suite. This protocol works at the network layer of the OSI model and at the Internet layer of the TCP/IP model. Thus this protocol has the responsibility of identifying hosts based upon their logical addresses and to route data among them over the underlying network.

IP provides a mechanism to uniquely identify hosts by an IP addressing scheme. IP uses best effort delivery, i.e. it does not guarantee that packets would be delivered to the destined host, but it will do its best to reach the destination. Internet Protocol version 4 uses 32-bit logical address.


Internet Protocol being a layer-3 protocol (OSI) takes data Segments from layer-4 (Transport) and divides it into packets. IP packet encapsulates data unit received from above layer and add to its own header information.

IP Encapsulation
The encapsulated data is referred to as IP Payload. IP header contains all the necessary information to deliver the packet at the other end.

IP Header
IP header includes many relevant information including Version Number, which, in this context, is 4. Other details are as follows −

Version

− Version no. of Internet Protocol used (e.g. IPv4).

IHL − Internet Header Length; Length of entire IP header.

DSCP − Differentiated Services Code Point; this is Type of Service.

ECN − Explicit Congestion Notification; It carries information about the congestion seen in the route.

Total Length − Length of entire IP Packet (including IP header and IP Payload).

Identification − If IP packet is fragmented during the transmission, all the fragments contain same identification number. to identify original IP packet they belong to.

Flags − As required by the network resources, if IP Packet is too large to handle, these ‘flags’ tells if they can be fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.

Fragment Offset − This offset tells the exact position of the fragment in the original IP Packet.

Time to Live − To avoid looping in the network, every packet is sent with some TTL value set, which tells the network how many routers (hops) this packet can cross. At each hop, its value is decremented by one and when the value reaches zero, the packet is discarded.

Protocol − Tells the Network layer at the destination host, to which Protocol this packet belongs to, i.e. the next level Protocol. For example protocol number of ICMP is 1, TCP is 6 and UDP is 17.

Header Checksum − This field is used to keep checksum value of entire header which is then used to check if the packet is received error-free.

Source Address − 32-bit address of the Sender (or source) of the packet.

Destination Address − 32-bit address of the Receiver (or destination) of the packet.

Options − 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.