Byte beat the back-end network protocol research and development intern interview subject learning (update)

According to the job requirements mainly back-end WEB development technology agreements, infrastructure, storage, caching, security

  • Why TCP handshake process is four times

Three-way handshake to establish a connection, the client sends syn packets to the server, the server receives syn packets, validate customer syn packets and sends himself a syn packet, the client confirmed syn packets from the server after receiving the connection establishment.

Retransmission: retransmission timeout mechanism is used to ensure the reliability of the TCP transport. Each time a packet transmission, transmission of data packets has seq number, the receiving terminal receives the data, confirmation will reply ack, seq denotes a number of data has been received. The sender after sending a certain seq pack, wait for some time, if no reply is received corresponding ack, it will assume packet loss will retransmit the packet.

Fast retransmit: accept data packets party found to have lost. Ack packets will be sent to tell the sender retransmission of lost packets. If continuous transmission packet receive the same reference numerals ack end, fast retransmit client is triggered. Compare timeout retransmission and fast retransmission, retransmission timeout can be found at the sending end is Shadeng timeout, then trigger a retransmission; and it is fast retransmit receiving end of the initiative to tell the sender did not receive the data, and then triggers the sending end retransmits

Flow control: the receiving end tell the sender how much he still can accept data buffer (considering only the receiving end and the sending end)

Congestion Control: slow start, congestion avoidance, congestion, fast recovery (considering the entire network status)

Four waving Disconnect: first: take the initiative to close sends a FIN, for closing the active side to the closed side of the passive data transfer, that is, take the initiative to close the square to tell passive close side: I have not give you send data (of course, the data sent out before the fin pack, without receiving a corresponding acknowledgment message ack, still actively closed side retransmits the data), but this time the active close side may further accept data. Second: the passive shutdown has received the FIN packet, it sends an ACK to each other, for the receipt of the acknowledgment number No. + (the same SYN, FIN a occupy a sequence number). Third: passive shutdown sends a FIN, for closing the passive side to take the initiative to close the closed side of the data transfer, that is, to tell the initiative to close the party, I also send the data over, will not give you send the data. Fourth: The initiative has received close FIN, ACK to send a passive closed party, numbered receipt confirmation number +1 This completes the four wave.

SYN flag set up a new connection, FIN sign a release connection, RST resets the connection

Three-way handshake is used to prevent the "expired connection request segment" segment is not lost, but a long stay in a node.

Fourth wave: As the connection is full duplex. Therefore, each direction must be shut down separately

Why is a three-way handshake, waving four times: in the handshake because the server in listen state, after the establishment of syn packets connected to receive the ack and syn placed in a packet is sent to the other party, and when the connection is closed, to close to the other side of the FIN message, the other party no longer represents only send data but also receive data, it may not own all the data are sent to each other, so one's own can close immediately, some data can be sent to the other party,

And then send a FIN packet to the other side to agree to close the connection now, therefore, own FIN and ACK generally transmitted separately.

Published 160 original articles · won praise 43 · views 80000 +

Guess you like

Origin blog.csdn.net/weixin_43590389/article/details/103737941