About HTTP connections and request resources

Time:2020-1-21
  • HTTP

    • TLS, about security
    • Three handshakes and four waves
  • Browser input URL to page rendering, after the process,

    • DNS resolves IP address
    • Request resources
    • HTTP triple handshake
    • Web page rendering
  • The three handshake

    • SYN
      The client selects a random sequence number x and sends a syn packet, which may include other TCP
      Flags and options.
    • SYN ACK
      The server adds 1 to x, selects its own random serial number y, and appends its own flag and option
      And return the response.
    • ACK
      The client adds 1 to X and Y and sends the last ACK packet during the handshake.
  • The four wave.

    • The TCP client sends a fin, which is used to turn off the data transmission from the client to the server.
    • The server receives the fin and sends back an ACK. The confirmation serial number is the received serial number plus 1. Like syn, a fin takes up a sequence number.
    • The server closes the client’s connection and sends a fin to the client.
    • The client sends back ACK message for confirmation, and sets the confirmation serial number to receive serial number plus 1.
  • TLS

    • TLS protocol provides three basic services

      • Encryption: viaAsymmetric key encryption

          1. Zhang San and Li Si generate their own public key and private key respectively;
          2. Zhang San and Li Si hide their private keys respectively;
          3. Zhang San discloses his public key to Li Si, and Li Si also discloses his public key to Zhang San;
          4. Zhang San sends a new message to Li Si and signs it with his private key;
          5. Li Si uses Zhang San’s public key to verify the signature of the received message.
      • Identity verification
      • Data integrity
  • The three handshake

    • The client sends a request syn to the server, with random serial number x in the request, and sends a syn packet
    • The server receives the request, adds 1 to the random sequence number x, and sends a random sequence y and X to the client
    • The client receives X and y, y plus 1, and then sends an ACK packet to the server
  • The four wave.

    • TCP sends a fin to the server
    • After receiving fin, the server returns an ACK
    • The server closes the client’s connection and sends a fin to the client
    • Confirmation of ACK message sent back by client
  • Why does it take three connections and four to close

    • For the three handshakes to build a link,It is mainly to initialize the initial value of sequence number. The two sides of communication should inform each other of their own initialization sequence number (abbreviated as isn: initial sequence number) – so it’s called syn, full name synchronized sequence numbers. That’s X and Y in the picture above. This number should be used as the serial number of future data communication to ensure that the data received by the application layer will not be out of order due to the transmission problems on the network (TCP will use this serial number to splice data).
    • For four waves,In fact, you look twice carefully. Because TCP is full duplex, both sender and receiver need fin and ACK. However, one side is passive, so it seems to be the so-called four waves. If both sides are disconnected at the same time, it will enter the closing state, and then arrive at the time ﹣ wait state.

Reference resources

  • Those things about TCP (I)