2. Familiar with TCP/IP protocol and tcpip Protocol

Source: Internet
Author: User

2. Familiar with TCP/IP protocol and tcpip Protocol
An article to familiarize you with the TCP/IP protocol (Network Protocol 2)

In the same way, this article is still quite long. Let's take a mind map and take it over again.

Figure 1 after reading this article

I. Computer Network Architecture hierarchy

Computer Network Architecture hierarchy
Computer Network Architecture hierarchy
It is not hard to see that TCP/IP and OSI are slightly different in hierarchical modules. The OSI reference model focuses on "What are the necessary functions of communication protocols", while TCP/IP emphasizes "What program should be developed to implement protocols on computers ".

Ii. TCP/IP basics 1. Specific meanings of TCP/IP

Literally, some people may think that TCP/IP refers to the two Protocols: TCP and IP. In real life, these two protocols are also true. However, in many cases, it is only a collective name of the Protocol group that is required for Communication Using IP addresses. Specifically, IP or ICMP, TCP or UDP, TELNET or FTP, and HTTP all belong to the TCP/IP protocol. They are closely related to TCP/IP and are an essential part of the Internet. TCP/IP refers to these Protocols. Therefore, TCP/IP is also called an Internet Protocol group.
When the Internet is used for communication, the corresponding network protocol is required. TCP/IP was originally developed for the use of the Internet. Therefore, the Internet protocol is TCP/IP, And the TCP/IP protocol is the Internet protocol.

Internet Protocol group

2. Data Packets

Packet, frame, packet, segment, message
The above five terms are used to express the unit of data, which are roughly divided into the following:

  • The package can be said to be a full term;
  • Frames are used to indicate the units in the data link layer;
  • A data packet is the unit of the packets in layers above the IP and UDP layers;
  • Segment indicates the information in the TCP data stream;
  • A message is a unit of data in an application protocol.

In each layer, a header is appended to the sent data, which contains the necessary information of the layer, such as the destination address of the sent message and protocol-related information. Generally, the information provided for the protocol is the packet header and the content to be sent is data. From the perspective of the next layer, all packets received from the previous layer are considered as data of the current layer.

Data packet header

Data Packets transmitted in the network are composed of two parts: one is the header used by the Protocol, and the other is the data transmitted from the previous layer. The header structure is defined in detail by the specific specifications of the Protocol. In the header of a data packet, it clearly indicates how the Protocol reads data. On the other hand, when we see the header, we can understand the necessary information of the Protocol and the data to be processed.The first packet is like the face of the Protocol.

3. Data Processing Process

Take user a as an example to send an email to user B:

Data Processing Process

  • ① Application Processing
    First, the application will perform encoding, which is equivalent to the OSI presentation layer function;
    After encoding conversion, emails may not be sent immediately. This management function is equivalent to the OSI Session Layer function when a communication connection is established and data is sent.
  • ② Processing of the TCP Module
    TCP is responsible for establishing a connection, sending data, and disconnecting according to application instructions. TCP provides reliable transmission of data sent from the application layer to the peer end. To achieve this function, you need to add a TCP header to the front end of the application layer data.
  • ③ IP module processing
    The IP address combines the TCP header and the TCP data transmitted over TCP as its own data, and adds its own IP header to the front end of the TCP header. After an IP package is generated, you can refer to the route control table to decide whether to accept the route or host of the IP package.
  • ④ Handling of network interfaces (Ethernet drivers)
    An IP packet transmitted from an IP address is data for Ethernet. Attach the Ethernet header to the data and send the data. The generated Ethernet data packets are transmitted to the receiving end through the physical layer.
  • ⑤ Handling of network interfaces (Ethernet drivers)
    After the host receives the Ethernet packet, it first finds the MAC address from the Ethernet packet header to determine whether the packet is sent to itself. If not, the data is discarded.
    If the packet is sent to itself, the data type is determined from the type in the Ethernet packet header, and then transmitted to the corresponding module, such as IP address and ARP. The example here is IP.
  • ⑥ IP module processing
    The IP module also performs similar processing after receiving data. Determine from the package header whether the IP address matches your own IP address. If yes, the data is sent to the corresponding module based on the protocol type of the header, such as TCP and UDP. The example here is TCP.
    In addition, in the case of a vro, the acceptor address is often not its own address. In this case, you need to use the routing control table to forward data after investigating the host or vro to be sent.
  • 7. Processing of the TCP Module
    In the TCP module, the checksum is calculated to determine whether the data is damaged. Then, check whether the data is received by serial number. Finally, check the port number to determine the specific application. After the data is completely received, it will be passed to the application identified by the port number.
  • Processing of ghost applications
    The receiving end application directly receives the data sent by the sending end. Parse the data to display the corresponding content.
3. TCP and UDP in the transport layer

TCP/IP has two representative transport layer protocols: TCP and UDP.

  • TCP is a connection-oriented and reliable stream protocol. A stream is an uninterrupted data structure. When an application uses TCP to send messages, although the sending order can be ensured, it is as if there is no interval between the data streams sent to the receiving end. TCP implements "sequential control" or "re-transmission control" to provide reliable transmission. In addition, it also provides many functions such as "traffic control", "congestion control", and improved network utilization.
  • UDP is a non-reliable datagram protocol. Minor processing is done by the upper-layer applications. In UDP, although the size of the sent message can be ensured, the message cannot be reached. Therefore, applications sometimes resend based on their own needs.
  • The advantages and disadvantages of TCP and UDP cannot be compared simply and absolutely: TCP is used to achieve reliable transmission at the transport layer. On the one hand, UDP is mainly used for communications or Broadcast Communications that require high-speed transmission and real-time performance. TCP and UDP should be used as needed based on the purpose of the application.
1. Port Number

The addresses in the data link and IP address respectively refer to the MAC address and IP address. The former is used to identify different computers in the same link, and the latter is used to identify the host and router interconnected in the TCP/IP network. In the transport layer, this concept is similar to the address, that is, the port number. The port number is used to identify different applications for communication on the same computer. Therefore, it is also called a program address.

1.1 Identify applications based on port numbers

Multiple programs can be run on one computer at the same time. The transport layer protocol uses these port numbers to identify applications that are currently communicating on the machine and accurately transmit data.

Recognize applications by using port numbers

1.2 identify communication by IP address, port number, and Protocol Number
  • It is far from enough to identify a communication based on the target port number.


Identify Communication by port number, IP address, and Protocol Number

  • Communication between ① and ② is performed on two computers. Their destination port numbers are the same, all of which are 80. The source port numbers can be distinguished here.
  • ③ The destination port numbers and source port numbers are identical, but their source IP addresses are different.
  • In addition, when the IP addresses and port numbers are all the same, we can also distinguish them by protocol numbers (TCP and UDP ).
1.3 determine the port number
  • Standard established port number: This method is also called a static method. It indicates that each application has its specified port number. It does not mean that any port number can be used at will. For example, the port numbers used in HTTP, FTP, TELNET, and other widely used application protocols are fixed. These port numbers are known as well-known port numbers, which are distributed between 0 and ~ 1023; in addition to well-known port numbers, there are also some port numbers officially registered, they are distributed in 1024 ~ 49151, but these ports can be used for any communication purpose.
  • Time Series allocation method: it is necessary for the server to determine the listening port number, but the client receiving the service does not need to determine the port number. In this way, the client application does not need to set the port number, but is assigned to the operating system for allocation. The dynamically assigned port number range is 49152 ~ In the range of 65535.
1.4 port number and Protocol
  • The port number is determined by the transport layer protocol used. Therefore, different transport layer protocols can use the same port number.
  • In addition, the well-known port numbers are irrelevant to the transport layer protocol. The same application will be allocated for processing as long as the ports are consistent.
2. UDP
  • UDP does not provide a complex control mechanism. It uses IP addresses to provide connectionless communication services.
  • In addition, it is a mechanism that sends data from an application to the network immediately as it is at the moment of receipt. Even in the case of network congestion, UDP cannot control traffic and avoid network congestion.
  • In addition, UDP is not responsible for re-sending Because packet loss occurs during transmission.
  • Even when the package arrives in an out-of-order, there is no correction function.
  • If the above detailed control is required, it must be handled by an application using UDP.
  • UDP is commonly used in the following aspects: 1. communications with a small amount of packets (such as DNS and SNMP); 2. multimedia communication such as video and audio (instant communication); 3. limited to application communication in a specific network such as LAN; 4. broadcast Communication (Broadcast and Multicast ).
3. TCP
  • The difference between TCP and UDP is quite large. It fully implements various control functions during data transmission, supports re-transmission control during packet loss, and sequential control of unordered subcontracting. None of these are in UDP.
  • In addition, as a connection-oriented protocol, TCP sends data only when the communication peer is confirmed to exist, which can control the waste of communication traffic.
  • According to these TCP mechanisms, high-reliability communication can also be achieved on non-connected networks such as IP addresses (mainly through checks, serial numbers, Confirmation responses, re-transmission control, connection management, and window control mechanisms ).
3.1 three-way handshake (important)
  • TCP provides connection-oriented communication transmission. For a connection, you must make preparations between the two ends before the data communication starts.
  • The three-way handshake means that when a TCP connection is established, the client and the server need to send a total of three packets to confirm the connection establishment. In socket programming, this process is triggered by the client executing connect.

Let's take a look at the three-way handshake flowchart:

Three-way handshake

  • The first handshake: the client sets the flag SYN to 1, generates a random value seq = J, and sends the packet to the server. The client enters the SYN_SENT status and waits for confirmation from the server.
  • The second handshake: After the server receives the data packet, the flag SYN = 1 knows that the client request is connected, and the server sets both the flag SYN and ACK to 1, ack = J + 1, generates a random value seq = K and sends the packet to the client to confirm the connection request. The server enters the SYN_RCVD status.
  • The third handshake: after the client receives the confirmation, it checks whether the ack is J + 1 and whether the ACK is 1. If yes, it sets the flag ACK to 1, ack = K + 1, send the packet to the server. The server checks whether ack is K + 1 and ACK is 1. If yes, the connection is ESTABLISHED successfully, and the client and server enter the ESTABLISHED status, after three handshakes, data can be transmitted between the client and the server.
3.2 four waves (Focus)
  • When you disconnect a TCP connection, the client and the server need to send a total of four packets to confirm the disconnection. In socket programming, this process is triggered by the close of either client or server side.
  • Because the TCP connection is full-duplex, every direction must be closed independently. This principle is that after one party completes the data transmission task, send a FIN to terminate the connection in this direction. If a FIN is received, it means that no data flow is sent to the upstream side, that is, no data will be received, however, data can still be sent over the TCP connection until FIN is also sent in this direction. The first party closes the service and the other party closes the service.

Let's take a look at the flowchart of the four waves:

Four Waves

  • The interrupted connection end can be a client or a server.
  • The first wave: the client sends a FIN = M, which is used to disable data transmission from the client to the server, and the client enters the FIN_WAIT_1 status. It means "no data is sent from my client to you", but if there is still data sent from your server, you do not have to rush to close the connection and can continue sending data.
  • Second wave: After the server receives the FIN, it first sends ack = M + 1, telling the client that I have received your request, but I am not ready yet, continue with your message. At this time, the client enters the FIN_WAIT_2 status and continues to wait for the server's FIN message.
  • The third wave: when the server determines that the data has been sent, it will send a FIN = N message to the client, telling the client that, okay, I have sent the data here, and I am ready to close the connection. The server enters the LAST_ACK status.
  • The fourth wave: after the client receives the FIN = N packet, it will know that the connection can be closed, but he still does not trust the network, for fear that the server does not know to close, therefore, after ack = N + 1 is sent, it enters the TIME_WAIT status. If the Server does not receive ACK, it can be re-transmitted. After the server receives the ACK, it will know that the connection can be disconnected. After the client waits for 2MSL, it still does not receive a reply, which indicates that the server has been properly shut down. Well, the client can also close the connection. Finally, four handshakes were completed.

The above is the situation where one party closes the service proactively and the other party closes the service passively. In reality, the Service will also initiate active shutdown at the same time,
The specific process is as follows:

Waving at the same time

3.3 improve reliability by serial number and response confirmation
  • In TCP, when the data at the sending end reaches the receiving host, the receiving host returns a notification that the message has been received. This message is called ACK ). After sending data, the sender waits for confirmation from the peer. If a response is confirmed, the data has successfully arrived at the peer end.Otherwise, data loss is highly likely..
  • If you do not wait for a confirmation response within a certain period of time, the sender can think that the data has been lost and resend the data. Therefore, even if packet loss occurs, data can still reach the peer end and be reliably transmitted.
  • Not receiving a confirmation response does not mean that the data is lost. It may also be that the data has been received by the other party, but the returned confirmation response is lost on the way. In this case, the sender mistakenly thinks that the data has not reached the destination and resends the data.
  • In addition, there may also be some other reasons that may lead to the arrival of the confirmation response delay. It is not uncommon to arrive after the source host resends the data. In this case, the source host only needs to resend data according to the mechanism.
  • For the target host, it is not advisable to receive the same data repeatedly. To provide reliable transmission for upper-layer applications, the target host must discard repeated data packets. For this reason, we introduce the serial number.
  • The serial number is the number of each byte (8-byte) that sends data in order. The receiving end queries the serial number and Data Length in the TCP Header of the received data, and returns the serial number that you should receive in the next step as a confirmation response. Through serial numbers and response confirmation numbers, TCP can identify whether data has been received and determine whether data needs to be received for reliable transmission.

Serial number and confirm response

3.4 Determination of Retransmission timeout
  • Retransmission timeout refers to the specific interval at which the response is to be confirmed before the data is re-sent.If no response is received after this time, the sender resends the data. Ideally, find a minimum time, which can ensure that "a confirmation response will be returned within this time ".
  • TCP requires that high-performance communication be provided regardless of the network environment, and this feature must be maintained regardless of the network congestion. Therefore, it calculates the round-trip time and its deviation each time it sends a packet. The sum of the round-trip time and the deviation time, And the retransmission time-out time is a slightly larger value than the sum.
  • In BSD Unix and Windows systems, timeout is controlled in 0.5 seconds. Therefore, the Retransmission timeout is an integer multiple of 0.5 seconds. However, the default value for the initial Retransmission timeout is usually about 6 seconds.
  • If the response is not received after the data is re-sent, send it again. At this point, the waiting time for confirmation of the response will be extended by an exponential function of 2 or 4 times.
  • In addition,Data will not be repeatedly resending infinitely. After a certain number of resends, if no response is returned, the system determines that an exception occurs on the network or the peer host, and forces the connection to be closed. And the application communication is forcibly terminated due to an exception.
3.5 send data in Segments
  • When establishing a TCP connection, you can also determine the unit of the sent data packet. We can also call it "Maximum message length" (MSS ). Ideally, the maximum message length is exactly the maximum data length that will not be processed by the IP.
  • When a large amount of data is transmitted over TCP, the data is sent separately based on the size of the MSS. The Unit is MSS.
  • The MSS is calculated between the two hosts during the three-way handshake. When the host at both ends sends a connection establishment request, it will write the MSS option in the TCP Header, telling the other interface to adapt to the MSS size. Then a small value will be selected between the two for use.
3.6 increase speed with window control
  • TCP takes one segment as the unit, and each segment is sent for a confirmation response. One disadvantage of this transmission mode is that the longer the round-trip time of a packet, the lower the communication performance.
  • To solve this problem, TCP introduces the window concept. The validation response is no longer based on each segment, but on a larger unit, and the forwarding time will be greatly shortened. That is to say, after sending a segment, the sender host does not have to wait for confirmation but continues sending. As shown in:

    Window Control
  • Window Size refers to the maximum value that data can be sent without waiting for confirmation. The window size is 4 segments. This mechanism implements the function of using a large number of buffers to check and respond to multiple segments at the same time.

3.7 sliding window control

Sliding Window

  • The data in the window in can be sent even if no confirmation response is received. However, if packet loss occurs in some of the data before the confirmation response in the window is reached, the sender is still responsible for retransmission. To this end, the sender host needs to set the cache to keep the data to be retransmitted until they receive their confirmation response.
  • The data that has not been sent and the data that has been received by the peer are included outside the sliding window. After the data is sent, if you receive a confirmation response as scheduled, you do not need to resend the data. In this case, the data can be cleared from the cache.
  • When a confirmation response is received, the window slides to the serial number position in the confirmation response. In this way, multiple segments can be sent at the same time to improve the communication performance. This mechanism is also called sliding window control.
3.8 resend control in window control

In the use of window control, packet loss is generally divided into two situations:

  • ① Confirm that the response fails to return. In this case, the data has arrived at the peer end and does not need to be resold, for example:

Partially confirmed response loss

  • ② Loss of a packet segment. If the receiving host receives data other than the serial number it should receive, it will return a confirmation response for the data received so far. As shown in, when a packet segment is lost, the sender will always receive a confirmation response with the serial number 1001. Therefore, when the window is large and the packet segment is lost, the confirmation response of the same serial number will be repeatedly returned. If the sender host receives the same confirmation response three times in a row, it resends the corresponding data. This mechanism is more efficient than previously mentioned timeout management, so it is also called high-speed re-transmission control.

High-speed re-transmission control

4. IP protocol at the network layer
  • The IP address (IPv4 and IPv6) is equivalent to the layer 3rd-network layer in the OSI reference model. The main role of the network layer is "communication between terminal nodes ". This kind of communication between terminal nodes is also called "point-to-point communication ".
  • The next layer of the network-the data link layer is used to transfer packets between nodes that interconnect the same data link. Once multiple data links are crossed, the network layer is required. The network layer can span different data links, and data packets can be transmitted between nodes on different data links.
  • IP addresses are roughly divided into three modules: IP address addressing, routing (forwarding until the final node), and IP packet forwarding and packet forwarding.
1. IP address 1.1 IP address Overview
  • In computer communication, an identifier similar to an address must be provided to identify the communication peer. The MAC address in the data link is an identifier used to identify different computers in the same link.
  • As the IP address of the network layer, this address information is also available, which is generally called an IP address. The IP address is used to identify the target address for communication among all hosts connected to the network ". Therefore, in TCP/IP communication, all hosts or routers must set their own IP addresses.
  • Regardless of the data link connecting a host, the IP address format remains unchanged.
  • The IP address (IPv4 address) is expressed by a 32-bit positive integer. The IP address is processed in binary mode in the computer. However, since we are not used to the binary method, we divide 32-bit IP addresses into four groups with every 8 bits. ", and then convert the number of each group to the decimal number. As follows:
28 28 28 28  
10101100 00010100 00000001 00000001 (Binary)
10101100. 00010100. 00000001. 00000001 (Binary)
172. 20. 1. 1 (Decimal)
1.2 The IP address consists of two parts: the network and the host.
  • For example, the network ID is configured with different values in each segment of the data link. The network ID must ensure that the addresses of each connected segment are not repeated. The connected hosts in the same segment must have the same network address. The "host ID" of the IP address cannot be repeated in the same CIDR block. Therefore, you can set the network address and host address to ensure that the IP addresses of each host do not overlap in the interconnected network. That is, the IP address is unique.

Host ID of the IP address

  • For example, when an IP packet is forwarded to a vro on the route, the network ID of the target IP address is used for routing. Because even if you do not look at the host ID, you only need to see the network ID to determine whether it is a host within the network segment.

Network ID of the IP address

1.3 IP address category
  • IP addresses are divided into four levels: Class A, Class B, Class C, and Class D. The network ID and host ID of an IP address are distinguished based on the bit column from 1st to 4th bits.
  • Class a ip address is the first address starting with "0.The network ID is from 1st to 8th bits. In decimal format, 0.0.0.0 ~ 127.0.0.0 is the network address of Class. The last 24 bits of the Class A address are equivalent to the host ID. Therefore, a single network segment can accommodate up to 16,777,214 host addresses.
  • Class B IP addresses are the first two "10" addresses.The network ID is from 1st to 16th bits. In decimal format, 128.0.0.0 ~ 191.255.0.0 is a network address of type B. The last 16 bits of the Class B address are equivalent to the host ID. Therefore, a single network segment can accommodate up to 65,534 host addresses.
  • Class c ip addresses are the first three "110" addresses.The network ID is from 1st to 24th bits. 192.0.0.0 ~ in decimal format ~ 223.255.255.0 is the network address of class C. The last eight digits of the class C address are equivalent to the host ID. Therefore, a single network segment can accommodate up to 254 host addresses.
  • The Class d ip address is the first four addresses with "1110.The network ID is from 1st to 32nd bits. 224.0.0.0 ~ in decimal format ~ 239.00000000255 is the network address of class D. Class D addresses are not identified by the host and are often used for multicasting.
  • When assigning an IP address, pay attention to the host ID. That is, when the host address is expressed in bits, not all 0 or all 1. Because 0 is used only when the corresponding network address or IP address is unknown. The host with all values of 1 is generally used as the broadcast address. Therefore, the two situations should be removed during the allocation process. This is why each CIDR block of a Class C address can have a maximum of 254 (28-2 = 254) host addresses.
1.4 broadcast address
  • A broadcast address is used to send packets between hosts connected to each other on the same link. Set the host address in the IP address to 1, and then the broadcast address.
  • Broadcast can be divided into local broadcast and direct broadcast. The broadcast in this network is called local broadcast, and the broadcast between different networks is called direct broadcast.
1.5 IP Multicast
  • Multicast is used to send packets to all hosts in a specific group. Because it uses an IP address directly, there is no reliable transmission.
  • Compared with broadcast, multicast can penetrate both the router and send packets only to those necessary groups. See:
    IP Multicast
  • Multicast uses Class D addresses. Therefore, if "4th" is the first bit, it can be considered as a multicast address. The remaining 28 digits can be multicast group numbers.
  • In addition, for multicast, all hosts (hosts other than routers and terminal hosts) must belong to the 224.0.0.1 group, and all routers must belong to the 224.0.0.2 group.
1.6 Subnet Mask
  • The network ID and host ID of an IP address are no longer restricted by the type of the address, instead, an identifier called "subnet mask" is used to precisely distinguish networks with smaller granularity than Class A, Class B, and class C network addresses. In this way, the host address section in the original Class A, Class B, and class C categories is used as A subnet address, and the original network can be divided into multiple physical networks.
  • The subnet mask is represented in binary format and is also a 32-bit number. All the bits corresponding to the IP address network identifier are "1", and all the corresponding IP address Host IDS are "0 ". Therefore, an IP address can no longer be limited by its own category, but can use this subnet mask to freely locate its network ID length. Of course, the subnet mask must be the first consecutive "1" starting from the IP address ".
  • The subnet mask can be expressed in two ways. The first is to use two lines to represent the IP address and subnet mask respectively. Take 172.20.100.52 as an example:
IP address 172. 20. 100. 52
Subnet Mask 255. 255. 255. 192
         
Network Address 172. 20. 100. 0
Subnet Mask 255. 255. 255. 192
         
Broadcast address 172. 20. 100. 63
Subnet Mask 255. 255. 255. 192
  • The second way is to separate the number of BITs appended to each IP address with "/", as shown below:
IP address 172. 20. 100. 52 /26
Network Address 172. 20. 100. 0 /26
Broadcast address 172. 20. 100. 63 /26
  • In addition, you can omit "0" when describing the network address in the second method ". For example, 172.255.0.0/26 and 172.20/26 actually mean one thing.
2. Routing
  • The IP address used to send data packets is the network layer address, that is, the IP address. However, the IP address alone is not enough to send data packets to the peer destination address. During the data transmission process, it also needs information similar to "specifying the router or host" so that the data can be truly sent to the destination address. The routing control table is used to save this information.
  • The routing control table can be created in two ways: one is manually set by the Administrator, and the other is automatically refreshed when the router and other routers exchange information. The former is also called Static Routing control, while the latter is called dynamic routing control.
  • The IP protocol always considers the route table correct. Then, the IP itself does not define the protocol for creating a route control table. That is, the IP address does not have a routing control table mechanism. This representation is made up of a protocol called "routing protocol.
2.1 IP address and route control
  • The IP address network address is used for route control.
  • The routing control table records the network address and the address that should be sent to the router in the next step.
  • When sending an IP packet, you must first determine the target address in the IP packet header, and then find the record that has the same network address as the address in the routing control table, based on this record, the IP packet is forwarded to the corresponding next vro. If multiple records with the same network address exist in the routing control table, select the most consistent network address.

Route control table and IP packet sending

3. IP subcontracting and group packages
  • The maximum transmission unit (MTU) of each data link is different because different data links have different purposes. The MTU can be carried for different purposes.
  • It is necessary for any host to process IP segments accordingly. Fragments are often processed only when a large packet cannot be sent out at once on the network.
  • IP datagram After partitioning can only be performed by the target host when it is restructured. Although the router is sharded, it will not be reorganized.
3.1 path MTU discovery
  • The sharding mechanism also has its shortcomings. Such as increasing the processing load of the router. Therefore, you do not want the router to perform IP packet sharding as long as it permits.
  • To address the shortcomings of the sharding mechanism, the path MTU discovery technology emerged. The path MTU indicates that the maximum MTU size does not need to be split between the sending host and the receiving host. That is, the smallest MTU in all data links in the path.
  • If you find the path MTU, you can avoid sharding on the middle router or send larger packets in TCP.
4. IPv6
  • IPv6 (IP version 6) is a standardized Internet Protocol to fundamentally solve the problem of IPv4 address depletion. The IPv4 address length is 4 8-bit, that is, 32-bit. The IPv6 address is four times the original length, namely 128 bits. Generally, it is written as eight 16-bit bytes.
4.1 IPv6 features
  • The expansion of the IP address and the aggregation of the route control table.
  • Performance improvement. The length of the first packet uses a fixed value (40 bytes) and no header verification code is used. Simplify the header structure to reduce the burden on the router. The router does not perform sharding.
  • Plug-and-play is supported. An IP address can be automatically allocated even if no DHCP server is available.
  • Authentication and encryption are used. Network security functions of forged IP addresses and functions to prevent line eavesdropping.
  • Multicast and Mobile IP are extended functions.
4.2 How to mark IP addresses in IPv6
  • Generally, 128 bits of IP addresses are grouped by 16 bits. Each group is marked by colons.
  • In addition, if consecutive 0 values are displayed, these 0 values can be omitted and separated by two colons. However, only two consecutive colons can appear at a time in an IP address.
4.3 structure of IPv6 address
  • Similar to IPv4, IPv6 identifies the IP address type by the first few digits of the IP address.
  • A global unicast address is used in Internet communication. It is the only address on the Internet and does not need to be officially assigned.
Undefined 0000 .. 0000 (128 bits) :/128
Loop address 0000 .. 0001 (128 bits) : 1/128
Unique local address 1111 110 FC00:/7
Local unicast link address 1111 1110 10 FE80:/10
Multicast address 1111 1111 FF00:/8
Global unicast address (Others)
4.4 global unicast address
  • A global unicast address is the only address in the world. It is the most common IPv6 address for Internet communication and internal communication in various domains.
  • As shown in, the formats used in IPv6 networks are n = 48, m = 16, and 128-n-m = 64. That is, the first 64 bits are network IDs, and the last 64 bits are Host IDS.

Global unicast address

4.5 local unicast link address
  • A local unicast link is a unique address in the same data link. It is used for communication in the same link without passing through the router. Generally, the interface ID stores the 64-bit MAC address.

Local unicast link address

4.6 unique local address
  • The unique local address is used when no Internet communication is performed.
  • Although the unique local address is not connected to the Internet, it will randomly generate a unique global ID as much as possible.
  • L usually set to 1
  • The value of the global ID is randomly determined.
  • The subnet ID refers to the subnet address of this domain.
  • The Interface ID is the interface ID.

Unique local address

4.7 IPv6 segment Processing
  • IPv6 fragment is only performed on the sender host that serves as the starting point, and the router does not participate in the fragment.
  • The minimum MTU in IPv6 is 1280 bytes. Therefore, for devices with certain system resource restrictions in embedded systems, "path MTU discovery" is not required ", instead, the IP packet is sent in 1280 bytes.
4.8 IP header (Omitted) 5. IP protocol-related technologies
  • The IP address is designed to allow the final target host to receive data packets. However, in this process, only IP addresses are available for communication. You must also have the ability to parse host names and MAC addresses, and handle abnormal data packets during transmission.
5.1 DNS
  • Generally, when accessing a website, we do not apply to IP addresses. Instead, we use a string consisting of a Roman character and a dot. Generally, users do not use IP addresses when using TCP/IP for communication. This is because the DNS (Domain Name System) function is supported. DNS can automatically convert the string to a specific IP address.
  • This DNS not only applies to IPv4, but also IPv6.
5.2 ARP
  • Once the IP address is determined, IP datagram can be sent to the target address. However, it is necessary to know the MAC address corresponding to each IP address during actual communication at the underlying data link layer.
  • ARP is a protocol to address problems. The target IP address is used as a clue to locate the MAC address of the next network device that should receive data packets. However, ARP is only applicable to IPv4 and cannot be used for IPv6. In IPv6, ICMPv6 can replace ARP to send Neighbor Discovery messages.
  • RARP is a protocol that reversely locates IP addresses from MAC addresses.
5.3 ICMP
  • The main functions of ICMP include checking whether IP packets are successfully delivered to the target address, notifying specific reasons for IP packets being discarded during sending, and improving network settings.
  • In IPv4, ICMP is only used as an aid to support IPv4. That is to say, in the IPv4 period, IP communication can still be implemented even if there is no ICMP. However, in IPv6, the role of ICMP is extended. Without ICMPv6, IPv6 cannot communicate normally.
5.4 DHCP
  • It is very cumbersome to set IP addresses for each host one by one. Especially when mobile devices use laptops, terminals, tablets, and other devices, IP addresses must be reset every time they move to a new place.
  • Therefore, in order to automatically set IP addresses and uniformly manage IP Address allocation, a DHCP (Dynamic Host Configuration Protocol) Protocol is generated. With DHCP, the computer can communicate with TCP/IP as long as it is connected to the network. That is to say, DHCP makes out-of-the-box use possible.
  • DHCP is not only available in IPv4, but also in IPv6.
5.5 NAT
  • NAT (Network Address Translator) is a technology used to use private addresses in a local Network and use global IP addresses when connecting to the Internet.
  • In addition to converting IP addresses, the Network Address Ports Translator (NAPT) technology that can be used to convert TCP and UDP port numbers is also available. Therefore, one global IP Address can be used to communicate with multiple hosts.
  • NAT (NAPT) is actually a technology developed for IPv4 address depletion. However, in IPv6, NAT is also used to improve network security. NAT-PT is often used in the communication between IPv4 and IPv6.
5.6 IP tunneling

Two IPv6 networks with IPv4 networks attached

    • For example, in A network environment, Network A and Network B cannot communicate directly. In order to allow normal communication between them, IP tunneling must be used.
    • The IP tunnel can combine IPv6 packets sent from network A into one data, append an IPv4 header to it, and then forward it to Network C.
    • Generally, the IP header is the TCP or UDP header. However, in today's applications, "IP first followed by IP first" or "IP first followed by IPv6 first" are increasingly common. This communication method that appends the network layer header after the network layer header is called "IP Tunnel ".

Related Article

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.