Computer Network Interview Essay Summary: Summarizing the Core Knowledge Points (1)
[Copy link]
1. Differences between TCP and UDP
TCP is connection-oriented, UDP is connectionless;
TCP can only communicate one-to-one, while UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communications;
TCP is byte stream oriented, UDP is message oriented;
TCP is a reliable transmission, using flow control and congestion control; UDP is an unreliable transmission
The minimum TCP header is 20 bytes and the maximum is 60 bytes; the UDP header is only 8 bytes.
2. ISO seven-layer model and related protocols
Physical layer: establish, maintain, and disconnect physical connections.
Data link layer: Establishes data links between adjacent nodes based on the bit stream service provided by the physical layer.
Network layer: performs logical addressing and implements path selection between different networks. Protocols include ICMP, IGMP, IP, etc.
Transport layer: defines the protocol port number for transmitting data, as well as flow control and error checking. The protocols include TCP and UDP.
Session layer: establishes, manages, and terminates sessions, referring to ongoing sessions between the local host and the remote host.
Presentation layer: ensures that information sent by the application layer of one system can be read by the application layer of another system.
Application layer: An interface between network services and end users. Common protocols include: HTTP, FTP, SMTP, and DNS.
TCP/IP four-layer model
-
Network Interface Layer
-
Internet Layer
-
Transport Layer
-
Application Layer
Five-layer architecture
-
Physical Layer
-
data link layer
-
Network layer: IP Internet Protocol, ARP Address Translation Protocol, RIP Routing Information Protocol
-
Transport layer: TCP transmission control protocol, UDP user datagram protocol
-
Application layer: HTTP Hypertext Transfer Protocol, FTP Text Transfer Protocol, DNS Domain Name System
3. How to understand that HTTP protocol is stateless
When the browser first sends a request to the server, the server responds;
If the same browser makes a second request to the server, it will still respond. However, the server does not know that you are the same browser as before.
In short, the server will not remember who you are, so it is a stateless protocol.
4. Briefly describe the process from entering the URL in the browser address bar to displaying the homepage
-
DNS resolution, find the IP address corresponding to the domain name.
-
Establish a TCP connection with the server through a three-way handshake.
-
Send an HTTP request to the server.
-
The server processes the request and returns the web page content.
-
The browser parses and renders the page.
-
TCP four-way handshake, the connection ends.
5. What are the differences between HTTP/1.0, 1.1, and 2.0?
HTTP/1.0
By default, a short connection is used, and a TCP connection needs to be established for each request. It can set the Connection: keep-alive field to force a long connection.
HTTP/1.1
-
By default, a long connection is used, that is, the TCP connection is not closed by default and can be reused by multiple requests.
-
Block transfer encoding means that the server sends one block of data each time it generates one block, replacing the "cache mode" with the "stream mode".
-
Pipeline mechanism, that is, in the same TCP connection, the client can send multiple requests at the same time.
HTTP/2.0
-
Binary protocol. The header information of version 1.1 is text (ASCII encoding), and the data body can be text or binary. In 2.0, both the header information and the data body are binary.
-
Fully multiplexed, in one connection, both the client and the server can send multiple requests or responses at the same time, and they do not have to correspond one to one in sequence.
-
Header compression: HTTP protocol does not carry state, and each request must carry all information. HTTP/2.0 introduces a header information compression mechanism, which is compressed using gzip or compress before being sent.
-
Server push allows the server to actively send resources to the client without request.
6. What are the differences between POST and GET?
7.How does HTTP implement a persistent connection? When will it time out?
What is HTTP persistent connection?
-
HTTP is divided into long connections and short connections, which is essentially referring to the long and short connections of TCP. TCP connection is a two-way channel that can be maintained for a period of time without being closed, so TCP connection has the real long connection and short connection.
-
TCP long connection can reuse a TCP connection to initiate multiple HTTP requests, which can reduce resource consumption. For example, if an HTML request is a short connection, you may also need to request subsequent JS/CSS.
How to set up a persistent connection?
By setting the Connection field in the request header and response header to keep-alive, the HTTP/1.0 protocol supports it, but it is turned off by default. Starting from HTTP/1.1, the connections are all long connections by default.
When will the timeout occur?
-
HTTP usually has an httpd daemon process, in which you can set a keep-alive timeout. When the TCP connection is idle for more than this time, it will be closed. You can also set the timeout in the HTTP header.
-
TCP keep-alive contains three parameters, which can be set in the net.ipv4 of the system kernel. When TCP is connected and tcp_keepalive_time is idle, a detection packet will be generated. If no ACK is received from the other party, it will be sent again every tcp_keepalive_intvl until tcp_keepalive_probes is sent, and the connection will be discarded.
tcp_keepalive_intvl = 15 tcp_keepalive_probes = 5 tcp_keepalive_time = 1800
|