Network basics (3): communication process

  The process of two computers communicating through the TCP/IP protocol is as follows: The
       Insert picture description here
  above figure corresponds to the situation that two computers are in the same network segment. If the two computers are in different network segments, then the data will go from one computer to the other. The computer must pass through one or more routers in the process of transmission, as shown in the following figure: The
       Insert picture description here
  link layer has Ethernet, token ring and other standards, and the link layer is responsible for the driver of the network card device and the frame synchronization (that is, what is detected from the network cable) The signal is counted as the start of a new frame), collision detection (automatically resend if a collision is detected), data error checking, etc. A switch is a network device that works at the link layer and can forward data frames between different link layer networks (such as between 10M Ethernet and 100M Ethernet, between Ethernet and Token Ring). The frame formats of different link layers are different, and the switch must remove the incoming data packet from the link layer header and re-encapsulate it before forwarding. The IP protocol at the
  network layer is the foundation of the Internet. Hosts on the Internet are identified by IP addresses. There are a large number of routers on the Inter-net that are responsible for selecting the appropriate path to forward data packets based on the IP address. Data packets often go through more than a dozen routers from the source host on the Internet to the destination host. A router is a network device that works on the third layer, and it also has the function of a switch. It can forward data packets between different link layer interfaces. Therefore, the router needs to remove the incoming data packets from the network layer and the link layer. The first part and repackaged. The IP protocol does not guarantee the reliability of transmission. Data packets may be lost during transmission. Reliability can be supported by upper-layer protocols or applications.
  The network layer is responsible for point-to-point (ptop, point-to-point) transmission (here, "point" refers to a host or router), and the transport layer is responsible for end-to-end (etoe, end-to-end) transmission (here "End" refers to the source host and the destination host). The transport layer can choose TCP or UDP protocol.
  TCPIt is a connection-oriented and reliable protocol. It is a bit like making a phone call. After the two parties have picked up the phone to communicate with each other, the connection is established, and then they can speak. What is said here is guaranteed to be heard, and it is listened in the order of speaking. Arrived, hang up after speaking to disconnect. That is to say, the two parties of TCP transmission need to establish a connection first, and then the reliability of data transmission and reception is guaranteed by the TCP protocol, and the lost data packets are automatically retransmitted. The upper application program always receives a reliable data stream, and the connection is closed after the communication.
  UDP is a connectionless transmission protocol that does not guarantee reliability. It is a bit like sending a letter. The letter is written and placed in the mailbox. It cannot guarantee that the letter will not be lost during the postal process, nor can it guarantee the order of the letter. Applications that use the UDP protocol need to perform tasks such as retransmission of lost packets and message sequencing by themselves.
After the destination host receives the data packet, how does it pass through the various layers of the protocol stack and finally reach the application program? The process is shown in the following figure: the
       Insert picture description here
  Ethernet driver first determines whether the payload of the data frame (payload refers to the actual data transmitted except the protocol header) is IP, ARP or RARP according to the "upper layer protocol" field in the Ethernet header The datagram of the protocol is then handed over to the corresponding protocol for processing. If it is an IP datagram, the IP protocol then determines whether the payload of the datagram is TCP, UDP, ICMP or IGMP according to the "upper layer protocol" field in the IP header, and then hands it over to the corresponding protocol for processing. If it is a TCP segment or a UDP segment, the TCP or UDP protocol then determines which user process the application layer data should be delivered to according to the "port number" field in the TCP header or UDP header. The IP address is the address that identifies different hosts in the network, and the port number is the address that identifies different processes on the same host. The IP address and port number together identify the only process in the network.
Although IP, ARP, and RARP datagrams all need Ethernet drivers to encapsulate into frames, they are functionally divided. ARP and RARP belong to the link layer, and IP belongs to the network layer. Although ICMP, IGMP, TCP, and UDP data all need IP protocol to encapsulate into datagrams, but from the functional division, ICMP, IGMP and IP belong to the network layer., TCP and UDP belong to the transport layer .

Guess you like

Origin blog.csdn.net/qq_40329851/article/details/114718000