TCP three-way handshake and four waved router (three) forward the principle of

The fourth layer is a transport layer of the International Standards Organization Open Systems proposed Interconnection (OSI) reference model. This layer protocol between processes on the host network endpoint provides a reliable and effective messaging services. Its function is closely dependent on the network layer virtual circuit or datagram service. Transport layer defines end to end between the host application connectivity. End of the transport layer exists only in an open system, a layer 3 interposed between the lower layer 3 and higher layer communications satellite system, but a very important one, because it is the source to the destination of the data transfer control from low to high of the last layer.
Services transport layer generally through the transport connection establishment phase, the data transfer phase, a transmission connection release phase three phase is not complete until a full service process. In the data transfer phase is divided into general data transmission and speeding up data transfer in two forms. The most common transport layer protocol are two transmission control protocol TCP (Transmission Control Protocol) and User Datagram Protocol UDP (User Datagram Protocol). The transport layer provides a logical connection is established, the transport layer address, data transmission, the transmission connection release, flow control, congestion control, multiplexing and demultiplexing, crash recovery services.
This article focuses on the transport layer protocol to establish TCP connections (three-way handshake) and off (four wave), and the data router forwarding principle (packaging process).
1, the process is called TCP three-way handshake to establish a connection, we can understand the process of TCP three-way handshake by the following figure:
TCP three-way handshake and four waved router (three) forward the principle of
we can see from the figure, PC1 to establish a communication link with the PC2, go through three steps, this three the steps we called three-way handshake. After this three-way handshake PC1 and PC2 can really communicate, transmit data.
First, we must first understand the more important in the TCP packet format in a few flags, ①, ACK: acknowledgment bit (bit acknowledgment number, when the bit is 1, the data used to confirm the sender). ②, SYN: establishment request flag (bit sync number, TCP needs to establish a connection the value is set to 1) is connected. ③, FIN: request flag OFF (when the TCP connection is disconnected position 1). Here we understand these three bits.
When PC1 and PC2 wants to establish a connection, can be seen from the figure PC1 first sends a SYN packet, which is set to 1, the request to establish a connection with the PC2, PC2 this time the request is received, by looking at the SYN packet position PC1 want to know to establish a connection, PC2 PC1 in response to the request, and sends a connection request (two PC establish communication is two-way, when a request to establish a connection to a PC, another PC will also request to establish a connection), PC2 send SYN + ACK packets, this position is the same one, received PC1 PC2 PC2 acknowledgment confirmation information responded to the request position, and then returns an acknowledgment, ACK message transmission, position 1. After the three-way handshake process, PC1 and PC2 connection is successfully established.

2, TCP disconnected four waving, we can understand the process of TCP four waved by the following figure:
TCP three-way handshake and four waved router (three) forward the principle of
figure above we can see that the process of PC1 and PC2 disconnected fact and above us about the TCP three-way handshake much the same, but the middle one more step 3, here is what we want to understand the concept of TCP half-closed, we can understand the concept of TCP half-close visit the website by closing this process, and to illustrate TCP disconnect fourth wave the process of.
Here we PC2 seen as a server, when we browse the Web, is a two-way transmission of data, PC1 initiated the request, the server responds to the request and sends the data to provide PC1 browse view, when the PC1 close the browser, first sends FIN / ACK packet, bit is 1, confirmation close the connection, the server receives the request, and then sends an ACK packet, position 1, to confirm the request, this time PC1 closing the browser window, but the server has not been disconnected from the PC1, will continue to send data PC1, PC1 off only one-way connection, which is half TCP closed state, when disconnected PC1, PC1 server repeats operation, transmission FIN / ACK packet, a location request to confirm disconnection, PC1 receives the server request, and transmits an ACK packet, position 1, to confirm the request, the server disconnects this time PC1, through these four steps, the server PC1 (PC2) is disconnected, this we are talking about is the fourth wave TCP disconnected.

3、路由器的数据转发原理(封装过程),通过下图来讲述路由器的数据转发原理:
TCP three-way handshake and four waved router (three) forward the principle of
路由器转发封装过程我们也称之为路由器的重封装过程,如上图所示,主机A要把数据发送给主机B要经过两个路由的转发来完成,在这个转发过程中是经过三个不同网段的转发最终到达主机B,在同一个段中传输时就是数据链路层(二层)的工作原理,数据链路层是以数据帧的格式通过封装源MAC地址与目标MAC地址进行转发,如上图,主机A发送数据到主机B,要经过三个不同的网段也就是要经过三次同一个网段内二层转发来完成。
首先主机A封装源IP地址(192.168.1.2/24)与目标IP地址(192.168.2.2/24),源MAC地址(…11-11),目标MAC地址(…22-22),经过E0端口发送到路由A中,完成第一次二层转发(数据链路层的转发),路由A接收到数据帧,通过解封MAC地址,查看主机A发过来的目标IP地址,同时在路由表中查找目标IP网段,当查找到这个网段后,知道应该从E1接口转发出去,然后路由A重新封装MAC地址,源IP地址与目标IP地址不变,这个时候封装的源MAC地址为…33-33,目标MAC地址为:…44-44,通过E1接口发送给路由B,完成第二个二层转发,路由B接受到数据帧后与路由A同样操做,解封MAC地址,查看目标IP地址,同时在路由表中查找目标IP网段,找到目标IP网段接口E0,然后重新封装MAC地址,源MAC地址为…55-55,目标MAC地址为…66-66,源IP地址与目标IP地址不变,通过E0接口转发到主机B,完成第三次二层转发,这个时候主机B接受到主机A发过来的数据帧,通过解封MAC地址,查看源IP与目标IP地址,确定是否是发给自己的数据。
通过上面所述的过程通过三次重新封装MAC地址,源IP地址与目标IP地址不变,完成数据的转发,这就是路由器的重封装过程,也就是路由器的数据转发原理(封装过程)。

Guess you like

Origin blog.51cto.com/14473285/2427273