Hello, this is a more literal challenge. This is the 5th day of my participation in the August More Text Challenge

Here are some of the most common questions interviewers ask about HTTP connections:

  1. Describe the process of establishing an HTTP connection

  2. You were talking about three handshakes. Why three handshakes? Not two

  3. What is a SYN attack

  4. What about disconnecting? How many times does it take

  5. Why four times


Here are the answers to each question

Http3 The process of the handshake and the role of each handshake

Three-way handshake: When establishing a TCP connection, the client and server need to send three packets

Main purpose: Verify that the client and server receive and send messages properly

  • Purpose of each handshake:

    • First handshake: The client sends a SYN packet and the server receives it. This indicates that the sending capability of the client and receiving capability of the server are normal

    • Second handshake: The server responds to the client by sending an ACK packet, which is received by the client. Note: There is no problem with the sending and receiving capabilities of the server, and there is no problem with the sending and receiving capabilities of the client

    • Third handshake: The client responds to the server and sends a packet. The server receives the packet. Note: After receiving this message, the server confirms that there is no problem with the receiving and sending ability of the client

  • The handshake process is shown below

  • Why do we need three handshakes? Can’t we do two

    • The three-way handshake is used to prevent inconsistencies between the two parties and waste resources when invalid connection request packets are suddenly transmitted to the server
  • Can you carry data during a three-way handshake

    • The third handshake can carry data, but the first and second handshakes cannot carry data
  • What is a SYN attack

    The server allocates resources during the secondary handshake; Client resource allocation is made when the third handshake is completed

    All servers are vulnerable to SYN flood attacks. In this attack, the Client forges a large number of nonexistent IP addresses and sends SYN packets to the Server. The Server replies with an acknowledgement packet and waits for the Client to confirm the attack. Because the Server needs to send SYN packets repeatedly until the timeout, these forged SYN packets occupy the half-connection queue for a long time. Normal SYN requests are discarded because the queue is full, causing network congestion and even system breakdown

4 times to wave

  • The waving process is shown below:

  • Why does TCP wave four times

    1. Because TCP is full duplex communication
    2. Close connection, when FIN message server received only on behalf of the client won’t send data message again, but the client can still receive data packet, and the server at this time there may be data message needs to be sent, so can only reply an ACK packet first, tell the client, “you FIN I received a message”, when the client after processing the data message, FIN packets are sent to the active party to ensure data communication. Therefore, they cannot be sent together. So you need four waves.