Network protocol stack 10: overall block diagram before the connect () function

Source: Internet
Author: User

 

The execution process of the connect function is composed of data encapsulated or unblocked by each protocol layer step by step, data Space added when skb_buff is allocated to the struct space. Data is encapsulated in the order of MAC, IP, and TCP, instead of in the TCP/IP/MAC order, the system will call the ip_send () function in connect to return MAC data. At this time, it is possible that the remote address is unknown (whether there is a record for the local route). Before the data is about to be sent, the system will call the ARP Protocol to parse the address and fill in the corresponding fields, if no ARP sending result is returned, the ICMP protocol is called and an error is reported. After creating the MAC header, move the pointer to the IP address header and fill it with the IP address. Some of the IP data in the pointer are ready when the socket is created. Copy the IP address, the TCP header is filled at the end of the connect function.

Data transmitted from the transport layer (TCP) to the network layer (TP) is not directly accessible when a function can be called directly. data must be arranged in the specified queue at the network layer first, that is, the data is first inserted to the end of the waiting queue waiting for downstream transmission to the link layer (IP), and the data uploaded to the link layer is extracted from the header of the waiting queue. Therefore, if the data from the transport layer to the network layer is greater than the data from the network layer to the link layer, the data will be temporarily stranded in the queue.

After the data is uploaded to the link layer, the system determines whether the data is greater than the specified maximum transfer data. If the data is greater than the maximum transfer data, the data is sliced and then the system calls the multipart function to transmit the data.

Data from the link layer to the NIC is divided into three Queues with descending priority to distinguish the data priority from the link layer, the general principle is to first send the data in the queue with the highest priority to send the secondary data. Therefore, the data at the link layer also needs to be arranged according to the specified priority, the purpose of these arrangements is to make fair use of resources, and there will be no first come phenomenon.

The connect function will send all network protocol stacks until the data is sent to the network by the network adapter, and then sleep waiting for the confirmation signal sent back from the distance, and then send a signal to the remote end that receives the confirmation signal, this completes the establishment of a link. After that, all the data of this socket can be transmitted on this link.

Note that the link is successfully established, not only the link remains the same, but the two ends of the link are confirmed, like from your home to the airport in your city, you may be able to take a lot of buses, rent a car, or take the subway, or make a boat. Sometimes, in order to catch up, there may also be multiple bus transfers (each transfer may be different), that is, there may be many routes from your home to the airport. Each time you arrive at the airport, there may be different routes,, your home and the airport remain unchanged, regardless of the process.

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.