1. What is your understanding of the TCP/IP four-layer model and the OSI seven-layer model?In order to enhance versatility and compatibility, computer networks are designed as hierarchical structures, with each layer following certain rules.
Therefore, there is an abstract network communication reference model such as OSI, which allows computer network systems to be connected to each other according to this standard.
TCP/IP is a four-layer structure, which is equivalent to a simplification of the OSI model.
To sum up, the physical layer connects computers through physical means, the data link layer groups the bit stream data, the network layer establishes host-to-host communication, the transport layer establishes port-to-port communication, and the application layer is ultimately responsible for establishing the connection, converting the data format, and finally presenting it to the user. 2. What is the process of TCP 3-way handshake?The server needs to listen to the port before establishing a connection, so the initial state is LISTEN.
3. Why 3 times? 2 or 4 times?Because TCP is a duplex transmission mode, it does not distinguish between the client and the server, and the establishment of a connection is a two-way process. If there are only two times, a two-way connection cannot be established. It can be seen from the fact that the SYN and ACK replied by the server when establishing the connection are combined into one time, it does not need four times. Why wave four times? Because the ACK and FIN of wave cannot be sent at the same time, because the deadline for data sending is different. 4. What about the process of four waves?
5. Why do we have to wait for 2MSL to shut down?
6. How does TCP ensure the reliability of the transmission process?Checksum: The sender calculates the checksum before sending the data, and the receiver does the same after receiving the data. If they are inconsistent, then the transmission is incorrect. Confirmation response, sequence number: When TCP is transmitted, the data is numbered, and each time the receiver returns ACK, there is a confirmation sequence number. Timeout retransmission: If the sender does not receive ACK after sending data for a period of time, it will resend the data. Connection management: three-way handshake and four-way wave process. Flow control: The TCP protocol header contains a 16-bit window size. The receiver will fill in its own immediate window when returning ACK, and the sender will control the sending speed according to the size of the window in the message. Congestion control: When data is first sent, the congestion window is 1. Each time an ACK is received, the congestion window is increased by 1. The smaller value of the congestion window and the received window is used as the actual sending window. If a timeout retransmission occurs, the congestion window is reset to 1. The purpose of this is to ensure the efficiency and reliability of the transmission process. 7. What is the process of a browser requesting a URL?
8. Do you know how HTTPS works?
9. What are the implementation methods of load balancing?DNS: This is the simplest load balancing method, generally used to achieve geographical load balancing. Users in different regions can return different IP addresses through DNS resolution. This type of load balancing is simple, but its scalability is too poor, and the control lies with the domain name service provider. Http redirection: load balancing is achieved by modifying the Location field in the Http response header, using Http 302 redirection. This method affects performance and increases request time. Reverse proxy: A mode that acts on the application layer, also known as layer-7 load balancing, such as the common Nginx, which generally has a performance of 10,000. This method is simple to deploy, low-cost, and easy to expand. IP: This mode acts on the network layer and the transport layer, also known as layer 4 load balancing, which achieves the effect of load balancing by modifying the IP address and port of the data packet. Common ones include LVS (Linux Virtual Server), which usually supports 100,000 concurrent connections. According to the type, it can also be divided into DNS load balancing, hardware load balancing, and software load balancing. Among them, hardware load balancing is expensive, but has the best performance, reaching the million level. Software load balancing includes Nginx and LVS. 10. What are the differences between BIO/NIO/AIO?BIO: Synchronous blocking IO, for each client connection, the server will correspond to a processing thread, and connections that are not assigned to a processing thread will be blocked or rejected. It is equivalent to one thread for each connection. NIO: Synchronous non-blocking IO, based on the Reactor model, the client communicates with the channel, the channel can perform read and write operations, and the multiplexer selector is used to poll the channels registered on it, and then perform IO operations. In this way, when performing IO operations, only one thread can be used to process, that is, one thread per request. AIO: Asynchronous non-blocking IO, which goes a step further than NIO. The operating system handles the request completely and then notifies the server to start a thread for processing. Therefore, one thread is effectively requested. 11. So how do you understand synchronization and blocking?First of all, you can think of an IO operation as consisting of two parts:
The difference between synchronization and asynchrony lies in the second one, the actual IO read and write operations. If the operating system completes it for you and then notifies you, it is asynchronous, otherwise it is called synchronization. The difference between blocking and non-blocking is that, first, an IO request is initiated. For NIO, after an IO operation request is initiated through a channel, it actually returns, so it is non-blocking. 12. What is your understanding of the Reactor model?The Reactor model consists of two components:
It includes several implementations: Single-threaded ReactorIn this mode, the reactor and handler are in the same thread. If a handler is blocked, all other handlers will be unable to execute and the performance of multiple cores cannot be fully utilized. Single Reactor MultithreadingSince decode, compute, and encode operations are not IO operations, the idea of the multi-threaded Reactor is to give full play to the characteristics of multi-core and separate non-IO operations. However, a single Reactor is responsible for all event monitoring and response work. If there are too many connections, there may still be performance issues. Multi-Reactor Multi-ThreadIn order to solve the performance problem of a single Reactor, a multi-Reactor model was created, where the mainReactor establishes the connection and multiple subReactors are responsible for data reading and writing. |
<<: Protocol-Oriented Programming and Cocoa (Part 2)
>>: Quick Start with Linkerd v2 Service Mesh
Software-defined WAN (SD-WAN), as the name implie...
Overview The rapid development of the Internet ha...
Author: Wang Rui, unit: Hebei Mobile Labs Guide A...
On December 7, the second SICC Service Innovation...
[[357747]] There has been a lot of news about HTT...
Port Security Technology Background The enterpris...
AkkoCloud is a Chinese hosting company founded in...
HTTP3 is the latest version of the HTTP protocol....
HostingViet, a local host provider in Vietnam, wa...
Since the outbreak of the novel coronavirus pneum...
With the continuous emergence of high-definition ...
China has made some achievements in 5G developmen...
Recently, it was learned that an Android hotspot ...
[51CTO.com original article] Huawei's 16th Gl...