Finish this article in one picture
First, computer network architecture stratification
Computer network architecture layering
Computer network architecture layering
As you can see, TCP/IP differs slightly from OSI in layered modules. The OSI reference model focuses on “what are the necessary functions of the communication protocol”, while TCP/IP puts more emphasis on “what programs should be developed to implement the protocol on the computer”.
Second, TCP/IP foundation
1. TCP/IP
In a literal sense, one might think that TCP/IP refers to both TCP and IP. In real life, these two agreements are sometimes referred to. However, in many cases, it is just a general name of the protocol group that must be used to communicate with IP. Specifically, IP or ICMP, TCP or UDP, TELNET or FTP, and HTTP are all TCP/IP protocols. They are closely related to TCP or IP and are an integral part of the Internet. The term TCP/IP refers broadly to these protocols, and as a result, TCP/IP is sometimes referred to as the Internet Protocol Group.
Communication over the Internet requires corresponding network protocols. TCP/IP is a protocol family developed for the use of the Internet. So, the protocol of the Internet is TCP/IP, and TCP/IP is the protocol of the Internet.
Internet protocol group
2. The packet
Packet, frame, packet, segment, message
The above five terms are used to describe units of data, which are roughly divided as follows:
- Package is the totipotency term;
- Frames are used to represent units of packets in the data link layer;
- A packet is a unit of packets in layers above the network layer, such as IP and UDP.
- Segments represent information in the TCP data flow.
- A message is a unit of data in an application protocol.
In each layer, the data to be sent is appended with a header that contains information necessary for the layer, such as the destination address to be sent and protocol-related information. Typically, the information supplied to the protocol is the packet header, and the content to be sent is data. From the point of view of the next layer, all packets received from the previous layer are considered data of this layer.
Packet header
The packet transmitted over the network consists of two parts: one is the header used by the protocol, and the other is the data transmitted from the previous layer. The structure of the header is defined in detail by the protocol specification. At the beginning of the packet, it clearly states how the protocol should read the data. On the other hand, by looking at the header, you can see the information necessary for the protocol and the data to be processed. The front of the package is like the face of the agreement.
3. Data processing process
The following figure shows the email message sent by user A to user B:
Data processing process
- ① Application processing
- First, the application performs coding that corresponds to the OSI presentation layer functions.
- The ability to manage when a communication connection is established and when data is sent is equivalent to OSI’s session layer functionality.
- ② TCP module processing
- TCP establishes the connection, sends data, and disconnects the connection according to the instructions of the application. TCP provides reliable transmission of data sent from the application layer to the peer end. To achieve this function, you need to attach a TCP header to the data front of the application layer.
- ③ IP module processing
- IP combines the TCP header and TCP data as its own data and adds its own IP header to the front end of the TCP header. After an IP packet is generated, the route or host that accepts the IP packet is determined by referring to the routing control table.
- ④ Network interface (Ethernet driver) processing
- IP packets from IP are data to Ethernet. The Ethernet header is attached to these data and sent. The Ethernet packets generated will be transmitted to the receiver through the physical layer.
- ⑤ Network interface (Ethernet driver) processing
- After receiving an Ethernet packet, the host searches for the MAC address from the Ethernet packet header to check whether the packet is destined for the host. If the packet is not destined for the host, the host discards the packet.
- 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 and ARP. The example here is IP.
- ⑥ IP module processing
- The IP module does the same when it receives the data. Check whether the IP address in the packet header matches its own IP address. If yes, the packet is sent to the corresponding module, such as TCP or UDP, based on the protocol type of the packet header. The example here is TCP.
- In addition, in the case of a router, the address of the receiving end is often not its own address. In this case, it is necessary to use the routing control table to investigate the host or router that should be sent before forwarding the data.
- ⑦ TCP module processing
- In the TCP module, the checksum is first evaluated to determine whether the data is corrupted. Then check to see if you are receiving data in sequence. Finally, check the port number to determine the specific application. Once the data has been received in its entirety, it is passed to the application identified by the port number.
- ⑧ Application processing
- The receiver application receives the data directly from the sender. By parsing the data, the corresponding content is displayed.
TCP and UDP in transport layer
TCP/IP has two representative transport layer protocols, namely TCP and UDP.
- TCP is a connection-oriented, reliable streaming protocol. A stream is an uninterrupted data structure. When an application uses TCP to send messages, the sequence can be guaranteed, but it is still like a data stream without any interval being sent to the receiver. TCP implements sequence control or retransmission control to provide reliable transmission. In addition, it has many functions such as “flow control”, “congestion control” and improving network utilization.
- UDP is an unreliable datagram protocol. It’s going to hand over the subtlety to the upper application. In the case of UDP, while you can ensure the size of a message sent, you can’t guarantee that it will arrive. As a result, the application sometimes performs retransmission processing as needed.
- The advantages and disadvantages of TCP and UDP cannot be simply and absolutely compared: TCP is used when reliable transport is necessary 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 on demand according to the purpose of application.
1. The port number
The address in data link and IP address refers to MAC address and IP address respectively. The former is used to identify different computers in the same link, while the latter is used to identify interconnected hosts and routers in TCP/IP networks. At the transport layer, there is also the concept of an address, which is a port number. Port numbers are used to identify different applications that communicate on the same computer. Therefore, it is also called the program address.
1.1 Identifying Applications based on port numbers
You can run more than one program simultaneously on a single computer. It is these port numbers that the transport layer protocol uses to identify the application that is communicating in the native machine and transfer data accurately.
Identify applications by port numbers
1.2 Communication identification by IP address, port number, and protocol number
- It is not enough to identify a particular communication by the target port number alone.
Identify communication by port number, IP address, and protocol number
- ① and ② are communicating on two computers. They both have the same destination port number, 80. This can be distinguished by the source port number.
- The destination port numbers of ③ and ① are the same as the source port numbers, but their source IP addresses are different.
- In addition, when the IP address and port number are all the same, we can also distinguish by protocol number (TCP and UDP).
1.3 Determining port numbers
- Standard port number: this method is also called static method. It means that each application has its own designated port number. This is not to say that you can use any port number at will. Widely used application protocols such as HTTP, FTP, and TELNET use fixed port numbers. These port numbers are called well-known port numbers and are distributed at 0
1023; In addition to the well-known port numbers, a number of port numbers are officially registered at 102449151, but these port numbers can be used for any communication purpose. - Sequential allocation: it is necessary for the server to determine the listening port number, but it is not necessary for the receiving client to determine the port number. In this way, the client application does not have to set the port number itself, but assigns it to the operating system. The dynamically allocated port number ranges from 49152 to 65535.
1.4 Port Numbers and Protocols
- The port number is determined by the transport layer protocol it uses. Therefore, different transport layer protocols can use the same port number.
- In addition, the well-known port numbers are independent of the transport layer protocol. As long as the ports are consistent, the same application will be assigned for processing.
2. UDP
- UDP does not provide complex control mechanisms and uses IP to provide connectionless communication services.
- And it is a mechanism for sending data from an application to the network as it is received. Even in the case of network congestion, UDP cannot perform traffic control to avoid network congestion.
- In addition, UDP is not responsible for retransmission of packets lost during transmission.
- There is no ability to correct even when the arrival order of packets is out of order.
- If the above details are needed, they have to be handled by UDP applications.
- UDP is used in the following aspects: 1. Communication with a small amount of packets (such as DNS and SNMP). 2. Video, audio and other multimedia communication (instant messaging); 3. Application communication on specific networks, such as LAN; 4. Broadcast communications (broadcast, multicast).
3. TCP
- TCP is quite different from UDP. It fully realizes various control functions in data transmission, including retransmission control in packet loss and sequence control in subcontracting out of order. None of this is available in UDP.
- In addition, TCP, as a connection-oriented protocol, sends data only after confirming the existence of the communication peer, thus controlling the waste of communication traffic.
- According to these mechanisms of TCP, high reliability communication (mainly through checksum, sequence number, acknowledgement reply, retransmission control, connection management and window control) can also be achieved over IP, a connectionless network.
3.1 Three-way Handshake (key point)
- TCP provides connection-oriented communication transport. Connection-oriented refers to the preparation work between the two ends before data communication begins.
- The three-way handshake means that the client and server send three packets to confirm the establishment of a TCP connection. In socket programming, this process is triggered by the client executing connect.
Here’s a flow chart for the three-way handshake:
Three-way handshake
- First handshake: The client sets the SYN flag bit to 1, randomly generates a value seq=J, and sends the packet to the server. The client enters the SYN_SENT state and waits for the confirmation from the server.
- Second handshake: When the server receives the packet, the flag bit SYN=1 knows that the client requests to establish a connection. The server sets the flag bit SYN and ACK to 1, ACK =J+1, randomly generates a value seq=K, and sends the packet to the client to confirm the connection request. The server enters the SYN_RCVD state.
- Third handshake: After receiving the confirmation, the client checks whether the ACK is J+1 and ACK is 1. If yes, the client sets the flag ACK bit to 1, ACK =K+1, and sends the packet to the server. The server checks whether the ACK is K+1 and ACK is 1. The client and server enter the ESTABLISHED state and complete the three-way handshake. Data can then be transferred between the client and server.
3.2 Four wave hands (key points)
- To terminate a TCP connection, the client and server need to send a total of four packets to confirm the disconnection. In socket programming, this process is triggered by either the client or the server executing a close.
- A TCP connection is full-duplex. Therefore, each direction must be closed separately. After completing the data transmission task, one party sends a FIN to terminate the connection in this direction. However, data can still be sent on this TCP connection until a FIN is also sent in that direction. The party that closes first performs an active shutdown, while the other party performs a passive shutdown.
Here’s a flow chart for four waves:
Four times to wave
- The interrupt end can be either a client or a server.
- First wave: The client sends a FIN=M to close the data transfer from the client to the server and the client enters the FIN_WAIT_1 state. This means “I have no more data to send to you from the client”, but if you have data to send from the server, there is no need to close the connection and continue to send data.
- Second wave: After receiving the FIN, the server sends ack=M+1 to tell the client that I have received your request, but I am not ready yet. Please continue to wait for my message. In this case, the client enters the FIN_WAIT_2 state and waits for the FIN packet from the server.
- Third wave: When the server confirms that data has been sent, it sends a FIN=N packet to the client to tell the client that all data has been sent and that it is ready to close the connection. The server enters the LAST_ACK state.
- Fourth wave: After receiving the FIN=N packet, the client knows that the connection can be closed. However, the client still does not trust the network, fearing that the Server does not know to close the network. Therefore, the client sends ack=N+1 and enters the TIME_WAIT state. When the server receives an ACK, it knows it is ready to disconnect. If the client waits for 2MSL and still does not receive a reply, then the server is shut down normally, then the client can also close the connection. Four handshakes were completed.
The above is the situation where one party takes the initiative to close and the other party takes the initiative to close. In practice, it will also initiate the initiative to close at the same time.
The specific process is as follows:
At the same time to wave
3.3 Improve reliability by serial number and acknowledgement reply
- In TCP, when data from the sender reaches the receiving host, the receiving host returns a notification that the message has been received. This message is called an acknowledgement reply (ACK). After sending data, the sender waits for the peer to confirm the reply. If there is an acknowledgement reply, data has been successfully delivered to the peer end. Otherwise, the possibility of data loss is high.
- If no acknowledgement is received within a certain period of time, the sender considers that the data has been lost and resends the data. Thus, even if packet loss occurs, data can still reach the peer end and reliable transmission can be achieved.
- Failure to receive an acknowledgement does not necessarily mean that data is lost. It is also possible that the data has already been received by the other party, but the acknowledgement returned was lost en route. In this case, the sender mistakenly thinks that the data has not reached the destination and resends the data.
- In addition, there may be other reasons for the delay in the arrival of acknowledgements, and it is not uncommon for acknowledgements to arrive after the source host has retransmitted data. In this case, the source host only needs to retransmit data according to the mechanism.
- It is not desirable for the target host to receive the same data repeatedly. In order to provide reliable transmission to upper-layer applications, the target host must discard duplicate packets. For this we introduced serial numbers.
- The serial number is the sequential number assigned to each byte (8-bit byte) of the sent data. The receiving end queries the sequence number and data length in the TCP header of the received data and sends back the sequence number to be received as an acknowledgement. Through the sequence number and acknowledgement number, TCP can identify whether data has been received and determine whether data needs to be received, thus achieving reliable transmission.
Serial number and confirmation reply
3.4 Determination of retransmission timeout
- ** The retransmission timeout is the specific amount of time that you wait for a confirmation reply to arrive before retransmitting data. ** If no acknowledgement is received after this time, the sender will resend the data. Ideally, find a minimum time within which the confirmation reply is guaranteed to return.
- TCP requires high performance communication regardless of network environment and must maintain this feature regardless of changes in network congestion. To do this, it calculates the round trip time and its deviation each time it sends a packet. Add this round trip time and the deviation time, and the retransmission timeout is a value slightly greater than the sum.
- On BSD Unix and Windows systems, timeouts are controlled in units of 0.5 seconds, so retransmission timeouts are integer multiples of 0.5 seconds. Initially, however, the default value for its retransmission timeout is generally set to about 6 seconds.
- If no acknowledgement is received after the data is retransmitted, the data is sent again. In this case, the waiting time for confirmation will increase by two times and four times exponentially.
- In addition, the data will not be retransmitted indefinitely and repeatedly. If no acknowledgement is returned after a certain number of retransmissions, the system determines that the network or the peer host is abnormal and forcibly closes the connection. Notify the application of abnormal communication and forcibly terminate.
3.5 Sending data in segments
- While establishing a TCP connection, you can also determine the unit in which packets are sent, which we can also call “maximum message length” (MSS). Ideally, the maximum message length is exactly the maximum length of data in the IP that will not be sharded.
- When TCP transmits a large amount of data, the data is divided into MSS size and sent. Retransmission is also done in MSS units.
- The MSS is calculated between hosts during the three-way handshake. When the hosts at both ends send a request to establish a connection, they write the MSS option in the TCP header to tell each other the size of MSS that their interfaces can accommodate. It then selects a smaller value between the two to put into use.
3.6 Use window control to improve speed
- The UNIT of TCP is 1 segment, and each segment is sent for an acknowledgement. The disadvantage of this transmission mode is that the longer the round trip time of the packet, the lower the communication performance.
- To solve this problem, TCP introduced the concept of Windows. Acknowledgments will be made in larger units instead of each segment, and the forwarding time will be greatly reduced. That is, the sending host does not have to wait for an acknowledgement after sending a segment, but continues to send. As shown below:
- Window control
- The window size is the maximum value at which data can continue to be sent without waiting for a confirmation reply. In the figure above, the window size is 4 segments. This mechanism enables simultaneous acknowledgement of multiple segments using large buffers.
3.7 Sliding window control
The sliding window
- The data in the window above can be sent without receiving an acknowledgement. However, the sender is still responsible for retransmission if some of the data is lost before the acknowledgement of the entire window arrives. To do this, the sending host needs to set up a cache to hold the data to be retransmitted until it receives an acknowledgement from them.
- The part outside the sliding window includes data that has not been sent and data that has been confirmed to have been received by the peer end. When the data is sent and the acknowledgement is received as expected, the data can be removed from the cache without being resent.
- Upon receipt of an acknowledgement, slide the window to the position of the serial number in the acknowledgement acknowledgement. This allows multiple segments to be sent sequentially simultaneously to improve communication performance. This mechanism is also known as sliding window control.
3.8 Retransmission control in window control
In the use of window control, packet loss is generally divided into two situations:
- ① Confirm the case that the reply is not returned. In this case, the data has reached the peer end and does not need to be retransmitted, as shown in the following figure:
Some acknowledgements are missing
- ② The loss of a packet segment. If the receiving host receives data other than the serial number it is supposed to receive, it will return an acknowledgement of the data received so far. As shown in the following figure, when a packet segment is lost, the sender will always receive the acknowledgement with the serial number 1001. Therefore, when the window is large and the packet segment is lost, the acknowledgement with the same serial number will be repeatedly returned. If the sending host receives the same acknowledgement for three consecutive times, it resends the corresponding data. This mechanism is more efficient than the time-out management mentioned earlier and is also known as high-speed retransmission control.
High speed retransmission control
IP protocol in the network layer
- IP (IPv4, IPv6) corresponds to layer 3, the network layer, in the OSI reference model. The main function of the network layer is to “realize the communication between terminal nodes”. This communication between terminal nodes is also called point-to-point communication.
- The data link layer, the next layer of the network, is mainly used for packet transfer between nodes connected to the same data link. Once across multiple data links, the network layer is needed. The network layer can span different data links, and data packets can be transmitted between nodes at both ends even on different data links.
- IP is roughly divided into three functional modules, which are IP addressing, routing (forwarding up to the end node), and IP subcontracting and packet grouping.
1. The IP address
1.1 Overview of IP Addresses
- In computer communication, in order to identify the communication peer, it is necessary to have an identification code similar to an address. A MAC address in a data link is an identifier used to identify different computers on the same link.
- As the IP of the network layer, also has this kind of address information, commonly called IP address. IP addresses are 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.
- The IP address of a host remains the same regardless of which data link it is connected to.
- An IP address (IPv4 address) is a 32-bit positive integer. IP addresses are processed in binary mode inside the computer. However, since we are not used to binary, we grouped the 32-bit IP addresses into four 8-bit groups, each group beginning with “. And convert each group of numbers to a decimal number. As follows:
1.2 An IP address consists of a network identifier and a host identifier
- As shown below, the network identity is configured with a different value for each segment of the data link. Network identifiers must ensure that the addresses of each connected segment do not duplicate each other. Hosts connected to the same segment must have the same network address. The Host ID of an IP address cannot appear repeatedly on the same network segment. Therefore, you can set the network address and host address to ensure that the IP addresses of each host do not overlap each other in the connected network. That is, the IP address is unique.
The host ID of the IP address
- As shown in the figure below, when IP packets are forwarded to a router on the way, they are routed using the network identifier of the destination IP address. This is because the host in the network segment can be identified as soon as the host id is seen without seeing the host ID.
Network identifier of an IP address
1.3 IP Address Classification
- IP addresses are classified into four levels: CLASS A, B, C, and D. It distinguishes the network and host identities of IP addresses based on the first to fourth bit columns in the IP address.
- ** Class A IP addresses start with 0. ** bits 1 through 8 are its network identifier. In decimal notation, 0.0.0.0 to 127.0.0.0 are class A network addresses. The last 24 bits of A class A address correspond to the host identifier. Therefore, a network segment can contain a maximum of 16,777,214 host addresses.
- ** Class B IP addresses are the first two “10” addresses. ** bits 1 through 16 are its network identifier. In decimal notation, 128.0.0.0 to 191.255.0.0 are class B network addresses. The last 16 bits of a class B address correspond to the host identifier. Therefore, a network segment can contain a maximum of 65,534 host addresses.
- ** A Class C IP address is an address whose first three digits are 110. ** bits 1 through 24 are its network identifier. In decimal notation, 192.0.0.0 to 223.255.255.0 are network addresses of class C. The last eight bits of a class C address correspond to the host identifier. Therefore, a network segment can contain a maximum of 254 host addresses.
- ** A Class D IP address is an address whose first four digits are 1110. ** bits 1 through 32 are its network identifier. In decimal notation, 224.0.0.0 to 239.255.255.255 are network addresses of class D. Class D addresses have no host identity and are often used for multicast.
- There is one thing to note about host identification when assigning IP addresses. That is, when you use bits to represent the host address, all the bits cannot be 0 or 1. All zeros are used only when the corresponding network address or IP address cannot be known. Hosts with all 1s are usually broadcast addresses. Therefore, in the allocation process, these two cases should be removed. This is why class C addresses can have a maximum of 254 (28-2 = 254) host addresses per network segment.
1.4 Broadcast Address
- Broadcast addresses are used to send packets between hosts connected to each other on the same link. Set all of the host addresses in the IP address to 1 to form a broadcast address.
- There are two types of broadcasting: local broadcasting and direct broadcasting. Broadcasts within a local network are called local broadcasts; Broadcasting between different networks is called direct broadcasting.
1.5 IP multicast
- Multicast is used to send packets to all hosts within a particular group. Since it uses IP addresses directly, there is no reliable transport.
- In contrast to broadcast, multicast can both penetrate the router and send packets only to those groups that are needed. See the picture below:
- IP multicast
- Multicast uses class D addresses. Therefore, if the number of digits from the first digit to the fourth digit is 1110, it can be considered as a multicast address. The remaining 28 bits can become multicast group numbers.
- In addition, for multicast, all hosts (other than routers and terminal hosts) must belong to group 224.0.0.1, and all routers must belong to group 224.0.0.2.
1.6 Subnet Mask
- The network identifier and host identifier of an IP address are no longer limited by the type of address. Instead, an identifier called A “subnet mask” divides the subnet network address into smaller networks than class A, CLASS B, and class C. In this way, the host addresses in class A, CLASS B, and class C are used as subnet addresses to divide the original network into multiple physical networks.
- A subnet mask in binary form is also a 32 – bit number. The bits of the network ID of the CORRESPONDING IP address are all 1, and the bits of the host ID of the corresponding IP address are all 0. Thus, an IP address can no longer be limited by its own category, but can use such a subnet mask to locate its own network identity length freely. Of course, the subnet mask must be the first successive “1” of the IP address.
- There are currently two representations of a subnet mask. In the first case, the IP address and subnet mask address are represented in two lines respectively. If the first 26 bits of 172.20.100.52 are network addresses, the following is an example:
- The second way is to append the number of network addresses to each IP address separated by slashes (/), as follows:
2. The routing
- The address used to send data packets is an IP address at the network layer. However, the IP address alone is not enough to send the data packet to the destination address of the peer end. In the process of data transmission, information similar to “specify router or host” is needed to send the data packet to the destination address. The routing control table holds this information.
- The routing control table can be formed in two ways: manually set by the administrator, or refreshed automatically when a router exchanges information with other routers. The former is also called static routing control and the latter is called dynamic routing control.
- The IP protocol always assumes that the routing table is correct. However, IP itself does not define the protocol for making routing control tables. 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 network address part of an IP address is used for route control.
- The routing control table records the network address and the address that should be sent to the router next.
- When sending an IP packet, you must first determine the destination address in the IP packet header, then find the record with the same network address in the routing control table, and forward the IP packet to the corresponding next router according to the record. If multiple records of the same network address exist in the routing control table, select the most consistent network address.
Routing control table and IP packet are sent
3. IP subcontracting and packet grouping
- The maximum transmission unit (MTU) of each data link is different because each type of data link is used for a different purpose. Different mtus can be loaded for different purposes.
- Any host must process IP fragments accordingly. Fragmentation is processed only when large packets cannot be sent out at a time on the network.
- IP datagrams that have been sharded can only be reassembled by the target host. Routers do sharding but they don’t reassemble.
3.1 Discovering path MTU
- Sharding also has its drawbacks. Such as router processing load increase and so on. Therefore, IP packet fragmentation is not expected to be processed by routers as long as it is allowed.
- In order to cope with the shortage of sharding mechanism, “path MTU discovery” technology came into being. The path MTU refers to the maximum MTU size that does not need to be sharded from the sending host to the receiving host. It is the minimum MTU of all data links in the path.
- By discovering path MTU, you can avoid fragment processing on intermediate routers and send larger packets over TCP.
4. IPv6
- IPv6 (IP Version 6) is a standardized Internet protocol to solve the problem of IPv4 address exhaustion. An IPv4 address contains four 8-bit bytes, that is, 32 bits. IPv6 addresses are four times as long as 128 bits, usually written as eight 16-bit bytes.
4.1 features of IPv6
- Expansion of IP knowledge and aggregation of routing control tables.
- Performance improvement. The header length is fixed (40 bytes) and the header check code is no longer used. Simplify the head structure and reduce the burden of the router. The router no longer performs fragment processing.
- Support plug and play function. You can automatically assign IP addresses even if there is no DHCP server.
- Authentication and encryption are enabled. Network security functions for forged IP addresses and functions to prevent wiretapping.
- Multicast and Mobile IP become extended functions.
4.2 How to Mark aN IPv6 ADDRESS
- Generally, 128-bit IP addresses are divided into groups of 16 bits, and each group is marked by a colon (:).
- You can also omit consecutive zeros and separate them with two colons (” : : “). However, you can only have two consecutive colons in an IP address once.
4.3 Structure of IPv6 Addresses
- IPv6 is similar to IPv4. The first few bits of an IP address identify the type of an IP address.
- In Internet communication, a global unicast address is used. It is the only address on the Internet that does not require a formal IP address assignment.
4.4 Global unicast Address
- A global unicast address is a unique address in the world. It is the most commonly used IPv6 address in Internet communication and inter-domain communication.
- The format is shown in the following figure. The format used in IPv6 networks is n = 48, m = 16, and 128-N-m = 64. That is, the first 64 bits are the network id and the last 64 bits are the host ID.
Global unicast address
4.5 Link-local unicast Address
- Link-local unicast addresses are unique addresses in the same data link. It is used to communicate on the same link without going through the router. Generally, the interface ID stores the MAC address of the 64-bit version.
Link-local unicast address
4.6 Unique Local Address
- A unique local address is an address used when no Internet communication is going on.
- Unique local addresses, while not connected to the Internet, randomly generate a unique global ID whenever possible.
- L is usually set to 1
- The value of the global ID is determined randomly
- Subnet ID indicates the subnet address of the domain
- The interface ID is the ID of the interface
Unique local address
4.7 IPv6 Segmentation processing
- IPv6 sharding is performed only on the sending host, and the router does not participate in the sharding.
- In IPv6, the minimum MTU is 1280 bytes. Therefore, in embedded systems, devices with limited system resources do not need to perform path MTU discovery, but directly send IP packets in 1280 bytes.
4.8 IP Header (Omitted)
5. IP protocol related technology
- IP is intended to get the packet to the destination host, but IP alone cannot communicate in this process. There must also be the ability to resolve host names and MAC addresses, as well as the ability to handle exceptions during packet delivery.
5.1 the DNS
- We don’t use an IP address to visit a website, but a string of Roman characters and dots. Common users do not use IP addresses when using TCP/IP for communication. This function is supported by the Domain Name System (DNS) function. DNS can automatically convert that string to a specific IP address.
- This DNS works not only for IPv4, but also for IPv6.
5.2 the ARP
- Once the IP address is determined, IP datagrams can be sent to this destination address. However, at the underlying data link layer, it is necessary to know the MAC address of each IP address for actual communication.
- ARP is a protocol for solving address problems. Using the target IP address as a cue, it is used to locate the MAC address corresponding to the next network device that should receive data subcontracting. However, ARP is only applicable to IPv4, not IPv6. In IPv6, ICMPv6 can be used instead of ARP to send neighbor exploration messages.
- RARP is a protocol that inverts ARP to locate IP addresses from MAC addresses.
5.3 the ICMP
- The main functions of ICMP include checking whether an IP packet is successfully delivered to the target address, notifying the specific reason why an IP packet is discarded during delivery, and improving network Settings.
- IPv4 supports ICMP only as a secondary function. In other words, in the era of IPv4, IP communication can be implemented even without ICMP. However, in IPv6, the role of ICMP is expanded, and without ICMPv6, IPv6 cannot communicate properly.
5.4 the DHCP
- Setting IP addresses for each host would be tedious. In particular, when using devices such as laptops, laptops and tablets, the IP address must be reset every time you move to a new place.
- Therefore, to automatically set IP addresses and assign IP addresses in a unified manner, Dynamic Host Configuration Protocol (DHCP) is developed. With DHCP, computers can communicate TCP/IP as long as they are connected to the network. In other words, DHCP makes plug and play possible.
- DHCP is available not only in IPv4 but also in IPv6.
5.5 NAT
- Network Address Translator (NAT) is a technology that uses private IP addresses on the local Network and global IP addresses when connecting to the Internet.
- In addition to translating IP addresses, Network Address Ports Translator (NAPT) technology can also translate TCP and UDP port numbers, enabling communication with multiple hosts using one global IP Address.
- NAT (NAPT) is a technology developed for IPv4, which is running out of addresses. However, NAT is also used in IPv6 to improve network security, and NAT-PT is often used in communication between IPv4 and IPv6.
5.6 the IP tunnel
Two IPv6 networks sandwiched between IPv4 networks
- In the network environment shown in the figure above, network A and network B cannot communicate directly. To ensure normal communication between them, the IP tunnel function must be adopted.
- An IP tunnel can combine IPv6 packets sent from network A into one piece of data, add an IPv4 header to it and forward it to network C.
- Generally, the TCP or UDP header is followed by the IP header. However, in today’s applications, “after the IP header is still IP header” or “after the IP header is IPv6 header” and so on are increasing day by day. This communication method is called “IP tunnel”, in which the network layer head is appended to the network layer head.