IP protocol is the core protocol in TCP protocol stack, and it is also one of the foundation of Network programming.
Network layer Overview IP service features:
The IP protocol provides stateless, non-connected, unreliable services for upper layer protocols.
- Stateless: IP communication between the two sides of the different state of the transmission of information, so all IP datagram send and receive are independent of each other, so that it can not handle the chaotic sequence, duplicate IP datagram. As opposed to connection-oriented settings, such as the TCP protocol, it is able to handle the disorderly sequence, repeating the message segment. The content he submitted to the upper class was absolutely orderly and correct. But the state of the IP protocol has its advantages, it is simple and efficient, because we do not need to allocate some kernel data structures to ensure its state.
- No connection: Both sides of the communication are not long to maintain the other side of any information, then you need the upper layer protocol to specify the IP address of the transmission.
- Unreliable services: Unreliable refers to the IP protocol does not guarantee that the IP datagram is complete and accurate to reach the receiving end. Therefore, the use of IP upper layer protocol needs to do its own data validation, time-out retransmission and other reliable transmission mechanism.
IPV4 Head Structure:
Figure One:
The IPV4 header structure consists of 20 bytes. A maximum of 40 option bytes is also included.
- 4-bit version number: Specifies the version of the IP protocol
- 4-bit head length: Identifies the number of four bytes.
- 8-bit service type (TOS): Includes a 3-bit priority field (now being ignored), 4-bit TOS field (minimum delay, maximum throughput, maximum reliability, minimum cost), and 1-bit reserved fields. The above information determines the resiliency of the IP protocol.
- 16-bit total length (bytes): The length of the entire IP datagram. This means that the maximum level of IP datagram is 2^16-1. Because of the MTU limit. Maximum transmission cannot reach this value.
Implementation principle of ====== partition transmission =========
- 16-bit ID: uniquely identifies each number that is sent by the host as reported. The initial values are randomly generated by the system. Each time a datagram is sent, the value is +1. Therefore shards of the same datagram have the same identity value
3-bit flag:
(1) The first position is reserved.
(2) The second position prohibits sharding (if this is set, the IP module will not shard The datagram, so imagine what we just mentioned, if the datagram is longer than the MTU, the datagram will be discarded, returning the ICMP error message)
(3) The third digit represents a multiple shard (except for the last shard of the IP datagram, the other shards are set to 1).
- 13-bit offset: is the offset of the Shard relative to the beginning of the original IP datagram.
These three fields work together to form the function of the IP segment.
=======================
- 8-bit time-to-Live (TTL): It is the number of route hops allowed before the datagram arrives at the destination. This value is reduced by 1 per route during the sending process. When the TTL bit 0 o'clock, the router discards the datagram and returns the ICMP error message. It prevents data from getting stuck in a routing loop.
- The 8-bit protocol surges to differentiate the upper layer protocol. ICMP bit 1,tcp is 6,UDP bit 17
- 16-bit Header checksum: it is populated by the sending side. At the receiving end, the CRC check algorithm is used to verify that the header information is damaged during transmission.
- 32-bit Origin IP: Indicates the send-side IP
- 32-bit Destination IP: Indicates the receiving end IP
- IPV4 head Variable-length options section with up to 401 bytes, optional IP options include: (1) record routing, (2) timestamp, (3) Loose source routing, (4) Strict routing (these introductions will be shared later)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Interpretation of IP protocol (i.)