The message sent on the TCP / IP level, receiving process

Copy the contents of this article in the "graphic TCP / IP" in the fifth edition of the second section of the fifth chapter, speaking quite detailed.

Suppose A to B to send e-mail, says: "Good morning." Viewed in the TCP / IP communication, e-mail is sent from one computer to another computer A B. We passed this example to explain the process of TCP / IP communications.
■ ① application processing
Start a new e-mail application, fill in the recipient's mailbox, and then entered by keyboard mail content, "Good morning", click on the "send" button you can start TCP / IP communications a.
First, the application will encode process. For example, Japanese email using ISO-2022-JP or UTF-8 encoding. The encoding function corresponding to the OSI presentation layer.
After encoding conversion, not necessarily the actual e-mail is sent immediately, because some e-mail software has a function to send multiple messages at the same time, there may be only collectively receive new mail user clicks the "receiver" button after the function. When establishing a communication connection such as when sending data
Management capabilities, from some broad sense, belongs to the OSI reference model functions in the session layer.
Send e-mail application in the moment to establish a TCP connection to take advantage of the TCP connection to send data. It is the process of transmission data is first applied to the next layer of TCP, do the actual transfer process.

■ ② TCP processing module
The indication TCP application (which corresponds to an indication of the connection session layer of the OSI reference model.), Responsible for establishing a connection, data transmission and disconnection. TCP provides a smooth transmission data sent from the application layer to the reliable transmission of the peer.
To achieve this function TCP, a TCP header requires additional application-layer data at the front end. TCP header includes a source port number and destination port number (to identify the transmission with the host application on the receiving host), serial number (which part of the packet is used to transmit data), and a checksum
(Check Sum, the method used to test whether the read data is performed normally.) (Used to determine whether data is damaged). Then attach the TCP packet header and then sent to the IP.

■ ③ IP processing module
The TCP IP transmission over TCP header and TCP data together as their own data, and front-end TCP header plus the IP header of his own. Thus, IP packet IP header followed by the TCP header, the header data is then applied and the data itself. 
IP header contains the IP address of a receiving end, and the sender IP address. IP header followed there behind the data used to determine the information of TCP or UDP.
After generating the IP packet, the routing control table refer to decide to accept or host routing the IP packet. Subsequently, the IP packet will be sent to the driver or a router connected to the host network interface to transmit real data.
If not already know the MAC address of the receiving end, you can use ARP lookup. Just know the MAC address of the terminal, it may be the MAC address and IP address to the Ethernet driver, data transmission.


Routing control table: network destination addresses stored routing information and how to reach that can be reached.
ARP can resolve the physical address (MAC address) from an IP address of the protocol data packet.

■ processing ④ a network interface (Ethernet driver) of
From the IP transmission over IP packets, but it is the data for the Ethernet driver. To the Ethernet header and transmission processing this additional data.
Ethernet header contains the MAC address of the receiving end, the protocol type of Ethernet MAC address and a flag of the Ethernet data sender. It will be transmitted to the receiving end according to the Ethernet physical layer packets generated by the above information. 
FCS calculation of the transmission processing by the hardware, adding to the last packet. The object set FCS is to determine whether the packet is destroyed due to noise.


When the packet flow, from front to back and so is attached Ethernet packet header, IP packet headers, TCP packet header (or UDP packet headers) and the application of its own packet header and data. 
Finally, the packet is added to the end of an Ethernet packet (the packet header attached to the front end of the packet, and trailer is added to the rear end refers to the portion of the package.).
Each packet header will include at least two information: a transmitting end and a receiving end is the address, protocol type on the other layer.
After each protocol layering, must end identification packet transmission and information receiving terminal. Will use Ethernet MAC address, IP will use IP addresses, TCP / UDP port number will be used as an address to identify both ends hosts. 
Even in the application, information such as e-mail address is also an address mark. Address information of each packet are layered upon each via, corresponding to the protocol attached to the inside portion of the packet header.
In addition, each hierarchical packet header also contains a recognition site, which is used to identify the upper layer protocol type information. For example, the Ethernet header of the Ethernet packet type, IP protocol type and port number of TCP / UDP ports in two acts so protocol type identified.
Is the header information of the application, sometimes containing a data type for identifying a tag.

Process the received packet is transmitted during reverse flow.
■ process ⑤ network interface (Ethernet driver) of
After the host receives Ethernet packets, first find the MAC address from the Ethernet packet header to determine whether to send their packages. If it is not sent to their own data packet is discarded (NIC products can be set to many if not sent his bag nor forsake data. 
This can be used to monitor network traffic. ).
If the received packet happens to be sent to their own, to find an Ethernet packet header type field to determine the type of data transmitted over Ethernet protocol. In this example, the data type is clearly IP packet, and then the thus processed data to the IP subroutine,
 If not the case, but other IP protocols such as ARP and ARP data to put the processing. In summary, if a packet type field Ethernet header contains a protocol unrecognized type, the data is discarded.

■ ⑥ IP processing module
After the IP module receives an IP packet header and a data portion of the rear portion, a similar process is also made. If it is determined the IP address of the packet header come in its own IP address match, you can receive data from and look for a layer of protocol. 
If the upper layer is a TCP IP packets will partially pass TCP header after treatment; If the UDP packet then the IP header part of the back pass UDP processing. 
For the next there is a router, the address is often not the receiving end of his address, at this time, it needs to control the routing table, and then forwards the data at a later investigation host or router should be served.

■ ⑦ TCP processing module
In TCP module will calculate whether the first checksum, the data is determined to be destroyed. Then check whether the data in accordance with the received sequence number. Finally, check the port number, determine the specific application.
After the data has been received, the receiving end sends an "acknowledgment receipt" to the sender. If the receipt information failed to reach the sender, so the sender would think the receiver is not receiving the data has been sent repeatedly.
After the data is completely received, it will be passed by the application program identified by a port number.

■ ⑧ processing applications
The receiver application will directly receive data sent by the transmission. Mail can be informed by parsing the data recipient address is acetic address.
If B is not on the host B's mail box, then back to the host B side transmits a "no such recipient address" error message.
But in this case, happens to have B's inbox on the host B, so the host B and the recipient B can receive the body of the email. Messages are saved to the machine's hard disk.
 If you can save the normal, the receiving side returns a "normal process" receipt to the sender. On the contrary, once the disk is full, the message could not be saved and other issues, will be sent a receipt "unhandled exception" to the sender.
Thereby, the user B can use e-mail client on the host B, received and read by electronic mail sent from the user A on Host A - "Good morning."

Guess you like

Origin www.cnblogs.com/wl-sjy/p/12625111.html