TCP / IP interpretation

TCP / IP:
the narrow sense refers to the two protocols TCP and IP. In the OSI model, TCP protocol in the transport layer, IP protocol in the network layer. In most cases, TCP / IP protocol is closely related to a broadly defined TCP or IP, ie TCP / IP protocol suite, also known as Internet Protocol group, even as its Internet development and formulation, can be directly called Internet Protocol.

TCP / IP units:
seven Jieke said protocol data unit packet, application layer message is a dedicated unit, and above the network layer packet data units of a dedicated, special data link layer unit is a frame, TCP data segment stream dedicated unit , IP data flow unit is dedicated sheet.

Data transfer in the network:
data arrival of Ethernet, the header from the upper layer to the underlying layers of the packaging. In the process of Ethernet into the goal, the removal of the head of each layer from the bottom to the top. That "package envelope" and "dismantle the envelope." Packet header information that is targeted mailing, data that is mailed to the content of the target. A layer packet header and data will be the next level of data.

Data link layer MAC address, identifying the same link different hosts; IP network layer IP address, to identify the different Internet hosts; program transport layer address, i.e. port, identifying different programs in the same host.

TCP slow, can be opened; UDP fast, unreliable.
TCP provides a sequence control, retransmission control, flow control, congestion control.
TCP connection-oriented, will be sent to confirm the presence of the data communication terminal, which can control the flow of waste.

By the source IP address, destination IP address, source port number, destination port number, a protocol number identifying the communication. Different transport layer protocol can use the same port number. TCP header includes a source port number, destination port number. IP header includes a source IP address, destination IP address, protocol number.

Three-way handshake:
the client requests to establish a connection with the server;
the server to the client confirmation response;
the client to confirm the server response.

Fourth wave:
one end of the other end of the notification they want to close the connection.
Notice that one end of the other end when I have to close the connection. There may be no data transmission is completed, it will end Hold on.
The other end of that period of notice that they have no data to send, you can close the connection.
That end to the other end of the confirmation response.

SYN (synchronization flag): from Synchronize Sequence Numbers, synchronous serial number. SYN = 1, indicates occurrence or a connection request receiving connection occurs.
Only when A by B SYN packet sent, before establishing a connection, in addition no other. So, if your firewall drop all SYN packets sent out of the network interface, then you will not take the initiative to establish a connection with any external host.

ACK (acknowledge flag): from Acknowledgement, confirmed. ACK = 1 occurs or expressed request acknowledgment receipt confirmation occurs.

FIN (end flag): from the Finish, to complete.

SYN, ACK, FIN for the flag, seq, ack variable.
Recommended TCP header format Comments: https: //blog.csdn.net/xiongping_/article/details/47746953

After the TCP connection is established, a data transmission segment, the segment header for the sequence number and the data length. When the acknowledgment by the reply, indicating successful transmission section; header by the sequence number and the data length of the received data to obtain a new sequence number, indicating the starting point of the next transmission period. If you can not get the acknowledgment timeout and serial number on the retransmission. If the segment has been repeated to give up. The maximum length of each segment to segment size (MSS). Ideally, the maximum segment size will not be exactly IP fragment handling the maximum data length.

TCP window control:
for acknowledgment after transmitting a plurality of segments.
Window size refers without waiting for the acknowledgment and may continue to transmit the maximum data.

Each time the contract will calculate the round trip time and offset time. The round-trip time and the offset time are added, the retransmission timeout is the value to be slightly larger than this sum. In the BSD Unix and Windows systems, timeout control in units of 0.5 sec., The retransmission timeout are multiples of 0.5 seconds.

Its initial retransmission timeout default value is generally set to 6 seconds. After the data is retransmitted if the acknowledgment is not received, the transmission is performed again. At this time, waiting for an acknowledgment response time will be extended to 2-fold, 4-fold exponential function.

Retransmitted data will not be unlimited. After a certain number of retransmissions, if still no acknowledgment returned it will be determined that the peer host or network abnormality occurs, forcibly close the connection. And notifies the application communication abnormality forcibly terminated.

Reference: https://blog.csdn.net/haoranhaoshi/article/details/94384209

Guess you like

Origin blog.csdn.net/haoranhaoshi/article/details/94384283