Computer networks and computer operating systems are the two “brothers” that all development roles need to be sworn enemies, whether you are Java, C++ or testing. For back-end development of children’s shoes, the importance of the computer network is no less than the language foundation, after all, usually development and network often deal with, such as: catch a bag and so on. So the preparation of this piece of knowledge or to hold a heart of awe, do not let go of any of the problems. Here is my learning process:
2. Take notes: there are a lot of knowledge points in the computer network, so take notes when you need to read for easy review. And when taking notes, you can go to Baidu on this knowledge point to see if there is a point you miss, and then to supplement. By the way, why do I keep emphasizing note-taking? Advantage 1: taking notes is the first time you review the knowledge points in the book, deepen memory; Advantage 2: and if you are published in the public relations community to ensure the maximum accuracy, you need to go to see this knowledge point, check whether they have understanding bias and omission, so as to complete the knowledge point of deep digging; Benefit 3: you are not likely to re-read a book when it is time to review the interview, so notes are very important, their own notes, review quickly, and it is best to have some of their own different from the understanding of the book.
3. Read your resume: Check out the interview to see what interviewers are asking about computer networks. You may know a lot of questions, but you won’t be able to answer them because you don’t know how the interviewer is asking you. Have you prepared the questions you will be asked? And for the computer network and computer operating system will be different because of the company and job focus, look at the interview will find that there is still a little rule, but this is not absolute, and finally to see your interviewer preferences.
1. What is your understanding of the five-layer network protocol architecture?
When we study computer networks, we usually take the middle ground, which is to neutralize the advantages of OSI and TCP/IP, and adopt an architecture with only five protocols, which is concise and can explain the concepts clearly.
-
1. The application layer
-
2. The transport layer
-
3. The network layer
Two computers communicating in a computer network may pass through many data links and may also pass through many communication subnets. The task of the network layer is to select the appropriate internetwork routing and switching nodes to ensure the timely transmission of data. When sending data, the network layer encapsulates the packet segments or user datagrams generated by the transport layer into packets and packets for transmission. In the TCP/IP architecture, packets are also called IP datagrams, or datagrams for short, because the network layer uses the IP protocol.
-
4. Data link layer
-
5. The physical
The units of data transmitted at the physical layer are bits. The role of the physical layer is to realize the transparent transmission of bitstreams between adjacent computer nodes, shielding the differences between specific transmission media and physical devices as much as possible. The data link layer above it does not have to consider what the specific transmission medium of the network is. “Transparently transmitted bitstream” means that the bitstream transmitted by the actual circuit does not change, and the circuit appears to be invisible to the transmitted bitstream.
2. What are the network protocols corresponding to each layer?
There are many protocols involved in the computer five-layer network system, and the following are commonly used to list them:
3. How does ARP work?
The ARP protocol at the network layer maps IP addresses to physical addresses. First, each host creates an ARP list in its ARP buffer to represent the mapping between IP addresses and MAC addresses. When the source host needs to send a packet to the destination host, it checks whether the MAC address corresponding to the IP address exists in the ARP list. If yes, the source host directly sends the packet to the MAC address. If no, the device sends an ARP broadcast packet to the local network segment to query the MAC address of the destination host.
The ARP request packet contains the IP address of the source host, hardware address, and destination host. After receiving the ARP request, all hosts on the network check whether the destination IP address in the packet is the same as their own IP address. If not, ignore the packet; If the MAC address and IP address of the sender are the same, the host adds the MAC address and IP address of the sender to its OWN ARP list. If the IP address already exists in the ARP table, the host overwrites the IP address and sends an ARP response packet to the source host to inform the source host that it is the MAC address to be searched for. After receiving the ARP response packet, the source host adds the IP address and MAC address of the destination host to its OWN ARP list and uses this information to start data transmission. If the source host does not receive ARP response packets, ARP query fails.
4. What is your understanding of IP address classification?
An IP address is a unified address format provided by the IP protocol. It assigns a logical address to each network and each host on the Internet to shield physical address differences. The IP address addressing scheme divides the IP address space into five classes: A, B, C, D, and E. A, B, and C are basic classes, and D and E are special addresses for multicast and reserved use.
Each IP address contains two IDS, namely, the network ID and the host ID. All hosts on a physical network use the same network ID. A host on the network (including workstations, servers, and routers) has a corresponding host ID. Class A to E addresses have the following characteristics:
5. What are the main features of TCP?
6. What are the main features of UDP?
7, TCP and UDP?
8. What are the common application layer protocols corresponding to TCP and UDP?
-
1. Application layer protocol corresponding to TCP
-
2. UDP indicates the application-layer protocol
9, detail TCP three handshake process?
-
1. Three handshakes
The process of establishing a TCP connection is called handshake. Three TCP segments are exchanged between the client and the server.
10. Why not shake hands twice?
11. Why not four handshakes?
Some people may say that AFTER sending the third handshake message, A has entered the connection state without receiving the request from B. What if the confirmation packet of A is lost or retained?
We need to understand that there is no such thing as a completely reliable communication protocol. After three handshakes, the client and server can confirm the previous communication status and both receive the confirmation message. So even increasing the number of handshakes does not guarantee the reliability of subsequent communication, so it is not necessary.
12. Why does the Server return a SYN from the Client?
The SYN is sent back by the receiver to tell the sender that I have received the SYN.
SYN is a handshake signal used by TCP/IP to establish a connection. In the establishment of a normal TCP network connection between the client and the server, the client first sends a SYN message, the server uses the SYN-ACK response to indicate receipt of the message, and the client Acknowledgement Acknowledgement. Acknowledgment character, a transmission control character sent from a receiving station to a sending station in a data communication transmission. In this way, a reliable TCP connection can be established between the client and server, and data can be transferred between the client and server.
If SYN is passed, why ACK?
The communication between the two parties must be correct. A SYN is passed, proving that the channel from sender to receiver is ok, but the channel from receiver to sender needs an ACK signal for verification.
14, detail TCP four wave process?
After the transmission, both parties can release the connection. Now both A and B are in ESTABLISHED state.
First wave: the application process of A sends A connection release packet segment to its TCP, stops sending data, and closes the TCP connection. A sets the stop control bit FIN at the head of the connection release packet segment to 1, and its serial number seq = U (equal to the serial number of the last byte of the previously transmitted data plus 1). Then A enters the fin-WaIT-1 state and waits for B’s confirmation. Note that TCP specifies that a FIN packet segment consumes a sequence number even if it does not carry data.
Second wave: After receiving the connection release segment, B sends an acknowledgement with ack = U + 1 and the sequence number of the segment is V (equal to the sequence number of the last byte of the data previously transmitted by B plus 1), and then B enters close-wait state. The TCP server process notifies the higher-level application process, and the connection from A to B is released. The TCP connection is half-closed, that is, A has no data to send, but IF B sends data, A still receives it. That is, the connection from B to A is not closed, and may remain so for some time. After receiving the acknowledgement from USER B, user A enters the FIN-WaIT-2 state and waits for the connection release packet segment sent by user B.
Third wave: If B has no more data to send to A, its application notifies TCP to release the connection. In this case, the FIN segment sent by USER B must be set to 1. Suppose B has sequence number W (in the half-closed state, B may send some more data). B must also repeat the confirmation number ack = u + 1 that was sent last time. In this case, B enters the last-ack state and waits for A’s confirmation.
Fourth wave: USER A must acknowledge the connection release packet sent by user B. Set the ACK number to 1, ACK = W + 1, and its sequence number seq = U + 1 (The FIN segment that is sent before consumes one sequence number). Then enter the time-wait state. Note that the TCP connection has not yet been released. A can enter the CLOSED state only after 2MSL (MSL: maximum packet segment life), which is set by the timer, and then revoke the transport control block to end the TCP connection. Of course, if B enters the CLOSED state as soon as it receives A’s confirmation, and then cancellations the transmission control block. Therefore, when releasing the TCP connection, B ends the TCP connection earlier than A.
15, Why must time-wait WAIT 2MSL?
16, why the second with the third can not merge, the second and third time between the waiting is what?
After the server performs the second wave, at this time prove that the client will not request any data to the server, but the server may also is to give the client sends data (which may be the last time the client requested resource has not been sent), so this time the server will wait for finish before transmission of data transmission to complete before send off the request.
17, the role of the timer?
In addition to the time-wait timer, TCP also has a Keepalive timer. Imagine a scenario where the client has actively established a TCP connection with the server. But then the client’s host suddenly failed. Obviously, the server can no longer receive data from the client. Therefore, something should be done to keep the server from waiting in vain. This is where the survival timer comes in.
Every time the server receives data from the customer, it resets the keepalive timer, usually for two hours. If no data is received from the client within two hours, the server sends a probe segment, then every 75 seconds. If there is no response from the client after 10 consecutive probe segments are sent, the server assumes that the client is faulty and closes the connection.
18. How does TCP ensure reliable transmission?
19. What is your understanding of the agreement to stop waiting?
20. What is your understanding of ARQ agreement?
-
Automatic retransmission request ARQ protocol
Timeout retransmission in the stop-wait protocol means that the packet that has been sent before is retransmitted if no confirmation is received within a period of time (the packet that has been sent before is considered lost). Therefore, a timeout timer should be set after each packet is sent, and the retransmission time should be longer than the average round trip time of packet transmission. This type of automatic retransmission is often called automatic retransmission request ARQ.
-
Continuous ARQ protocol
Continuous ARQ protocol can improve channel utilization. The sender maintains a send window in which packets can be sent consecutively without waiting for confirmation. The receiver generally uses cumulative acknowledgements, sending acknowledgements to the last packet arriving in sequence, indicating that all packets up to that point have been correctly received.
21. What do you know about sliding Windows?
TCP uses sliding Windows to implement flow control mechanisms. Sliding window is a flow control technique. In the early days of network communication, communication parties directly sent data regardless of network congestion. Because everyone did not know the network congestion, at the same time to send data, resulting in the middle node blocking switch, no one can send data, so there is a sliding window mechanism to solve this problem.
TCP uses a sliding window for transmission control. The size of the sliding window means how much buffer the receiver can use to receive data. The sender can use the size of the sliding window to determine how many bytes of data to send. When the sliding window is 0, the sender can no longer send datagrams, except in two cases where urgent data can be sent, for example, allowing the user to terminate a running process on the remote machine. Alternatively, the sender can send a 1-byte datagram to inform the receiver to redeclare the next byte it wishes to receive and the size of the sender’s sliding window.
Talk about your understanding of flow control?
TCP uses sliding Windows for flow control. Traffic control is to control the sending rate of the sender and ensure that the receiver can receive data in time. The window field in the acknowledgement packet sent by the receiver can be used to control the size of the sender window, thus affecting the sending rate of the sender. If the window field is set to 0, the sender cannot send data.
What is your understanding of TCP congestion control? What algorithms are used?
Congestion control is different from flow control in that the former is a global process, while the latter is the control of point-to-point traffic. At some point, if the demand for a resource in the network exceeds the available portion of the resource, the performance of the network deteriorates. This condition is called congestion.
Congestion control is designed to prevent too much data from being injected into the network so that routers or links in the network do not become overloaded. Congestion control must be done on the premise that the network can withstand the existing network load. Congestion control is a global process that involves all hosts, all routers, and all factors associated with reducing network traffic performance. In contrast, traffic control is often a point-to-point traffic control, an end-to-end problem. The purpose of flow control is to suppress the rate at which the sender sends data so that the receiver can receive it in time.
For congestion control, the TCP sender maintains a congestion window (CWND) state variable. The size of the congestion control window depends on the congestion level of the network and changes dynamically. The sender makes its send window the smaller of the congestion window and the receiver’s accept window.
TCP congestion control adopts four algorithms: slow start, congestion avoidance, fast retransmission and fast recovery. At the network layer, routers can also adopt appropriate packet discarding policies (such as active queue management AQM) to reduce network congestion.
-
Slow start:
The idea behind the slow-start algorithm is that when the host starts sending data, if a large number of bytes of data are immediately injected into the network, it may cause network congestion because network compliance is not yet known. Experience shows that the better method is to first detect, that is, gradually increase the sending window from small to large, that is, gradually increase the value of congestion window from small to large. The initial value of CWND is 1, and the CWND is doubled after each transmission cycle.
-
Congestion avoidance:
The idea of congestion avoidance algorithm is to make the congestion window CWND increase slowly, that is, every round trip time RTT increases the CWND of the sender by 1.
-
Fast retransmission and fast recovery:
In TCP/IP, Fast Retransmit and Recovery (FRR) is a congestion control algorithm that can quickly recover lost packets.
Without FRR, TCP will use a timer to suspend the transmission if the packet is lost. During this pause, no new or duplicated packets are sent. With FRR, if the receiver receives a piece of data out of order, it immediately sends a repeat acknowledgement to the transmitter. If the transmitter receives three duplicate acknowledgements, it assumes that the data segments indicated by the acknowledgements are missing and immediately retransmits those missing data segments.
With FRR, there is no delay due to the pause required on retransmission. Fast retransmission and Fast Recovery (FRR) work most effectively when a single packet is lost. It does not work very effectively when multiple data packets are lost over a short period of time.
What is sticky bag?
When learning Java NIO, you may find that if the client continuously sends packets to the server, the data received by the server will have two packets stuck together.
Based on the above two points, packet sticking or unpacking is possible only when TCP is used to transmit data. A packet contains the information of two packets sent by the sender, which is called sticky packet.
The receiver receives two packets, but the two packets are either incomplete or there is an extra one, which is called unpacking and sticky packets. The problem of unpacking and sticky packets makes it very difficult for the receiving end to process because it cannot distinguish a complete packet.
How is TCP sticky packet generated?
-
The sender generated sticky packets
-
Sticky packets are generated on the receiver
When the receiver uses TCP protocol to receive data, the process is as follows: the data to the receiver is transferred from the bottom of the network model to the transport layer. The TCP protocol of the transport layer is to put it into the receiving buffer, and then the application layer takes the initiative to obtain it (C language uses recV, read and other functions). The problem is that the data reading function we call in the program can’t take the data out of the buffer in time, and the next data comes and part of it is put into the end of the buffer, and when we read the data, it is a sticky packet. (Data loading speed > data loading speed of the application layer)
How to solve the problem of unpacking and sticking the package?
Subcontracting mechanism generally has two general solutions:
27. Do you know anything about HTTP status codes?
-
1 xx information
-
2 xx success
-
3 xx redirection
-
4XX Client error
-
5XX Server error
28. What do THE HTTP status codes 301 and 302 represent? What’s the difference?
301,302 are the codes of the HTTP state, which represent the transfer of a URL.
-
The difference between:
29, What is the difference between forward and redirect?
Forward and Redirect represent two request forwarding modes: direct and indirect.
-
Here’s a colloquial example:
What are HTTP methods?
The first line of the request packet sent by the client contains the method field.
What is the difference between GET and POST?
GET and POST are essentially HTTP requests, but their roles are defined and adapted to their respective scenarios.
Essential difference: GET is only one HTTP request, POST first sends the request header and then the request body, actually two requests.
32, enter the URL address in the browser to display the homepage process?
1. DNS resolution: The browser queries the DNS to obtain the IP address corresponding to the domain name. The process includes searching the DNS cache of the browser, searching the DNS cache of the operating system, reading the local Host file, and querying the IP address from the local DNS server. If the domain name to be queried is included in the resources in the local configuration zone, the resolution result is returned to the client to complete domain name resolution (the resolution is authoritative). If the domain name to be queried is not resolved by the local DNS server, but the SERVER has cached the IP address mapping, invoke the IP address mapping to complete domain name resolution (the resolution is not authoritative). If the local DNS server does not cache the URL mapping, recursive or iterative queries are initiated according to its Settings.
2. TCP connection: After obtaining the IP address corresponding to the domain name, the browser sends a request to the server for establishing a connection and initiates a three-way handshake.
3. Send an HTTP request: After a TCP connection is established, the browser sends an HTTP request to the server.
4. The server processes the request and returns an HTTP packet: The server receives the request, maps the path parameters to a specific request processor, and returns the processing result and corresponding view to the browser.
5. The browser parses and renders the page: the browser parses and renders the view. If it encounters references to static resources such as JS files, CSS files and images, repeat the above steps and request these resources from the server. The browser renders the page according to the resources and data it requests, and finally presents a complete page to the user.
6. The connection ends.
DNS resolution process?
What do you know about domain name caching?
To improve the EFFICIENCY of DNS query, lighten the load on the server and reduce the number of DNS query packets on the Internet, domain name servers widely use cache to store the records of the recently queried domain names and where to obtain domain name mapping information.
Because the name-to-address binding does not change very often, to keep the content in the cache correct, the DNS server should set a timer for each item and process items that take longer than a reasonable amount of time (for example, two days per item). When a DNS server is asked to query an item of information after it has been removed from the cache, it must revert to the DNS binding information authorized to manage the item. When the permission server answers a query request, the response specifies the valid time value of the binding. Increasing this value reduces network overhead, and decreasing this value improves the accuracy of domain name resolution.
Caching is not only required in the local domain name server, but also in the host. Many hosts download their entire database of names and addresses from the local server at startup, maintain a cache of their most recently used domain names, and use DNS only when names cannot be found in the cache. The host that maintains the local DNS database should periodically check the DNS server for new mapping information, and the host must remove invalid entries from the cache. Since domain name changes are infrequent, most nodes can maintain database consistency with little effort.
What is your understanding of HTTP long and short connections? Which scenarios do they apply to?
Short connections are used by default in HTTP/1.0. That is, each time the client and server perform an HTTP operation, a connection is established and broken at the end of the task. When the client browser accesses an HTML or other type of Web page that contains other Web resources (such as JavaScript files, image files, CSS files, etc.), the browser re-establishes an HTTP session each time it encounters such a Web resource.
From HTTP/1.1 onwards, long connections are used by default to preserve the connection feature. HTTP with long connections adds this line of code to the response header
Connection:keep-aliveCopy the code
In the case of a long connection, when a web page is opened, the TCP connection between the client and the server for the transmission of HTTP data is not closed. When the client accesses the server again, it continues to use the established connection.
Keep-alive does not hold a connection forever, but has a hold time that can be set in different server software such as Apache. To implement persistent connections, both clients and servers must support persistent connections.
What are the major changes between HTTP 1.0 and 1.1 and 1.2?
-
Key changes to HTTP1.1:
-
Key changes to HTTP2.0:
How does HTTPS work?
-
3.1 Verifying the validity of the certificate;
-
3.2 If the certificate is authenticated, the browser will generate a series of random numbers and encrypt them with the public key in the certificate.
-
3.3 The handshake message is calculated using the hash algorithm, encrypted with the generated key, and then sent to the server together.
-
4.1 Use the private key to parse the password, use the password to parse the handshake message, and verify whether the hash value is the same as that sent by the browser.
-
4.2 Encrypting Messages with keys
What is the difference between HTTP and HTTPS?
39. Advantages and disadvantages of HTTPS?
-
Advantages:
-
Disadvantages:
What is a digital signature?
What is a digital certificate?
In symmetric encryption, both parties use public keys for decryption. Although digital signatures can ensure that data is not replaced, the data is encrypted by the public key, and if the public key is also replaced, the data can still be forged because the user does not know that the public key provided by the other party is actually fake. Therefore, to ensure that the public key of the sender is genuine, the CA certificate authority issues a certificate that is guaranteed to be genuine. When the user requests the server, the server issues the certificate to the user. The certificate is recorded by the built-in certificate of the system.
What is symmetric encryption and asymmetric encryption?
Symmetric key encryption means that encryption and decryption use the same key. The biggest problem in this mode is key transmission, that is, how to securely send the key to the other party.
Asymmetric encryption refers to the use of a pair of asymmetric keys, that is, a public key and a private key. The public key can be distributed freely, but the private key is known only to itself. The party that sends the ciphertext uses the other party’s public key for encryption. After receiving the encrypted information, the other party uses its own private key to decrypt the encrypted information.
Asymmetric encryption is secure because it does not need to send a private key for decryption. But it’s very slow compared to symmetric encryption, so we still have to use symmetric encryption to send messages, but symmetric encryption uses keys that we can send through asymmetric encryption.