TCP/IP note Protocol

Source: Internet
Author: User
1. The IP address provides an unreliable, connectionless point-to-point transmission mode.

Unreliable: only the best transmission service is provided, and it is not guaranteed that the destination can be successfully reached.

Connectionless: the processing of each datagram is independent. It can be received without sending order, and different routes can be selected for each message.

2. IP datagram header format (generally 20B)

(1) version (4bit) the current version number is 4, so it is called IPv4. (The IPv6 address is 6 + 1 power of 2, 128bit)

(2) The length of the header (4 Bit) is the number of the first part of the 4B, it can be seen that the first part is at most 60 B long

(3) TOS field (1B): A 3bit priority field (not used now, 000); A 4bit TOS field, the last bit is always 0

The 4bit TOS field is: Minimum latency, maximum throughput, maximum reliability, and minimum cost. A maximum of one bit is set to 1.

(4) total length field (2b): the total length of the IP datagram in bytes

(5), identifier (2B), identifier (3bit), and segment offset (13bit) fields: description at the end

(6) TTL field (1B): Time-to-live. The maximum number of routers that a datagram can pass through

(7) protocol field (1B): Upper Layer Protocol (ICMP: 1, IGMP: 2, TCP: 6, UDP: 17)

(8) header checksum (2b): During calculation, set the checksum field to 0, and then sum the 16bits of the IP header to fill the result with this field, it is also based on the first 16-bit anticode sum. If the result is all 1, OK.
 
Note: because the value of the TTL field is reduced by 1 every time a router exists, the checksum field may change for every vro.

(9) because the IP header length field is the number of 4B, the option field is bounded by 32 bits (if not enough, add the padding byte)

3. IP Route Selection

(1) process: When a network interface at the IP layer receives a data report, first check whether the IP address of the report is one of the local IP addresses or a broadcast address. If yes, process the report. Otherwise, if the IP layer is set to the vro function, it is forwarded. If no, It is discarded.

(2) Main content of the route table entry: the destination IP address (either a host or a network address), the IP address of the next hop router, and the identifier, specifying a network interface

(3) route selection sequence: Search the route table first to find the table items that exactly match the destination IP address, and find the table items that match the network address of the destination IP address; find the route entry with the default value.

Note: If the intermediate router forwards data to the next hop router address during data reporting, the IP address of the intermediate router is the final destination IP address, however, the target MAC address is changed to the MAC address of the next hop router. This route is called an indirect route.

4. subnet addressing:

(1) subnet division is blocked for external routers. That is to say, the external routers cannot see the subnet organization form within the network, but are not transparent to the routers inside the subnet.

(2) subnet mask: Used to understand the host numbers and network numbers of an IP address (the network number can be determined by the IP Address Header 8bit, the host number is determined by the zero part of the subnet mask. Except for the network number and host number, the remaining part is the subnet number)

5. Special IP addresses

(1) A number starting with class A 127 represents a loop (normally 127.0.0.1)

(2) hosts on the Network: All 0

(3) specific hosts on the network: The network number is 0, and the host number is the specified host number

(4) broadcast address: (when the host number is all 1): see broadcast and Multicast

6. commands for viewing IP addresses in Linux: ipconfig and netstat

7. IP sharding (use of field identification, field identification, and field offset)

(1) because the MTU of each network is different, when the MTU of each network is smaller than the length of the IP packet, the router will split the IP packet. Re-assemble after arriving at the destination

(2) When sharding, copy the header of the IP package and modify the following: The field indicates the serial number of the IP package, therefore, during the sharding process, copy the part to the package. one bit of the flag field indicates that more parts will exist, except the last one, the bitwise of the flag field is 1. The offset field indicates the position of the data of the image from the beginning of the original package. In addition, the total length field is changed to the length of the image.

(3) another bit of the flag is "non-sharding bit ". If this bit is 1, the packet is discarded and an ICMP error message is sent to the source host.

(4) Disadvantages: during transmission, even if a part is lost, the whole IP packet must be re-transmitted. UDP is generally prone to sharding, whereas TCP generally avoids sharding.

(5) Note: During partitioning, only the IP packet header is copied, so the upper layer protocol (such as UDP port information) can only be in the first partition. (It can be seen that the parts can only be divided once ).

(6) Partition example:

For example, if an IP datagram has a length of 3056 and the MTU of a network is 1500 during transmission, perform the sharding: (the header is marked with a field of 14007)
The following parts are output in the following format. Only the changed parts in the IP address header are listed:

(Marker, non-fragment marker, more data marker, third marker, part displacement, total length of the part)

Fragment 1: (14007, 0, 1, 0, 0, 1500) (Note: This is the first part, the part offset is 0, and the information of the upper layer protocol is included in this Part)
Part 2: (14007, 0, 1, 0, 1500,150 0)
Part 3: (14007, 0, 0, 0, 3000, 56) (Note: because the "more data" flag is 0, the part of the datagram has ended)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.