Internet related interview questions

Why is HTTP not secure

  • becauseHTTPThe protocol uses plaintext transmission and the communication process is completely open, so once a third party is targeted, the other party can easily monitor and modify the packets passing through, resulting in information leakage or even malicious tampering
  • HTTPThe protocol has no authentication mechanism between the user and the site, and the user may be attacked when browsing the site using a browserDNSThis can lead to users’ browsers being redirected to fake websites, where important information such as account passwords can be illegally stolen.

Common protocols at each layer of the TCP/IP four-layer model

  • The application layerHTTP FTP DNS WebSocket
  • The transport layerTCP UDP
  • The network layerIP ICMP(Internet Control Message Protocol, Internet Control Message Protocol) isIPProtocol supplement used to detect the network connection status, for examplepingThe application isICMPUse of protocols.
  • Data link layerARPThe function is to turnIPAddress resolution intoMACAddress)RARP(Reverse Address Resolve Protocol) is the inverse address resolution protocol

GET and POST

  • getRequest parameters as?Splice toURLbehindpostRequest parameters inBodyinternal
  • geT Displays the parameter length2048A character,postThere is generally no such restriction
  • getThe request is not secure,postRequest is safer
  • getDoes not affect the changes on the server side, there is security,postwill
  • getIf I do it multiple times I get the same result, idempotent,postNot necessarily
  • getRequests are cached on the server by default,postNo default cache

Why does TCP need three handshakes

  • If only two handshakes are required to establish a connection, the client does not change much and still needs to get a reply from the server before enteringESTABLISHEDState, which the server enters upon receiving a connection requestESTABLISHEDState. If the network is congested and the connection request sent by the client fails to reach the server, the client times out and resends the request. If the server receives the request correctly and confirms the response, the two sides communicate and release the connection after the communication is complete. At this point, if the failed connection request reaches the server, since there are only two handshakes, the server will enter upon receipt of the requestESTABLISHEDStatus, waiting for data to be sent or actively sending data. However, the client has already enteredCLOSEDState, the server will wait forever, wasting server connection resources.

TCP congestion control

  • Slow start exponential growth
  • Congestion avoids linear growth to the top and turns the value into a restart slow start
  • Quick retransmission received3The duplicate confirmation packets are retransmitted immediately
  • Fast recovery does not start over from a slow start, but immediately starts to go congestion to avoid the linear phase

TCP sliding window

  • TCP sliding window technology adjusts data transmission between two hosts by dynamically changing the window size. Each TCP/IP host supports full-duplex data transmission, so TCP has two sliding Windows: one for receiving data and one for sending data. TCP uses the affirmative confirmation technique, where the confirmation number refers to the serial number of the next expected packet. Suppose the sender device sends data three packets at a time, that is, a window size of 3. The sender sends three data packets with serial numbers 1, 2, and 3. The receiver device successfully receives the data packet, which is confirmed by serial number 4. The sender device receives the acknowledgement and continues to send data at window size 3. When the receiving device requires to reduce or increase network traffic, you can reduce or increase the window size. In this example, the window size is reduced to 2, and two packets are sent each time. When the receiver device requests a window size of 0, it indicates that the receiver has received all data or that the receiver application does not have time to read the data and asks to pause the transmission. The sender receives an acknowledgement with window number 0 and stops data transmission in this direction.

  • Advantages of sliding window protocol:

    • Allows the sender to send multiple packets in succession before stopping and waiting for confirmation. Because the sender does not have to acknowledge every delivery, the protocol speeds up the transmission of data.
    • When the receiving window slides forward (and an acknowledgement is sent at the same time), the sending window also slides forward synchronously. The Windows at the receiving and receiving ends slide forward continuously according to the preceding rules, and the window size can be dynamically adjusted

Why is UDP unreliable

  • No guaranteed message delivery: no confirmation, no retransmission, no timeout
  • No guarantee of delivery order: no package number is set, no rearrangement, and no queue blocking occurs
  • Do not track connection status: You do not need to establish a connection or restart the state machine
  • No congestion control required: No built-in client or network feedback mechanism

Which udP-based application layer protocols are available

  • DNS,TFTP(Simple File Transfer Protocol),RIP(Routing Protocol),DHCP,BOOTP(isDHCPPredecessor),IGMP(InternetGroup Management Protocol)

DNS must be based on UDP

  • Not necessarily
  • DNSUsed for area transferTCPProtocol, used at other timesUDPAgreement,

What happens from entering the URL to presenting the page

  • 1. Enter the address
  • 2, browser search domain nameIPaddress
  • 3, the browser towebThe server sends aHTTPrequest
  • The server’s permanent redirection response
  • 5. The browser tracks the redirected address
  • 6. The server processes the request
  • 7. The server returns oneHTTPThe response
  • 8. Browser displayHTML
  • 9. The browser sends the request to get embedded inHTMLResources (such as images, audio, video,CSS,JSEtc.)

The Socket and WebSocket

  • SocketIt’s not really a protocol, it’s a convenienceTCPorUDPThe abstract layer is a set of interfaces between the application layer and the transmission control layer.SocketIs the application layer andTCP/IPAn intermediate software abstraction layer for protocol family communication, which is a set of interfaces. In the design pattern,SocketIn fact, it is a facade model, it is complicatedTCP/IPThe protocol family is hidden inSocketAfter the interface, for the user, a simple set of interfaces is all, letSocketTo organize data to conform to specified protocols. When two hosts communicate with each other, you must passSocketThe connection,SocketThe use ofTCP/IPAgreement to establishTCPThe connection.TCPThe connection is more dependent on the underlyingIPAgreement,IPProtocol connections depend on lower levels such as the link layer.WebSocketIs a typical application layer protocol.SocketIs the Transmission control layer protocol,WebSocketIt is an application-layer protocol.