An overview of the

This chapter mainly summarizes and analyzes the classic interview questions in the development interview.

The problem

1) What is the difference between TCP/UDP?

  • TCP is connection-oriented, whereas UDP is connection-oriented, that is, no connection is required before data is sent.
  • TCP provides a reliable service that UDP cannot guarantee.
  • TCP byte stream oriented and UDP packet oriented.
  • TCP data transmission is slow, and UDP data transmission is fast.
  • The size of TCP transmission is not limited, and that of UDP single transmission is limited (64K).

2) Please tell us what you know about ports and corresponding services

port service
21 FTP file Transfer Protocol
22 SSH
25 SMTP (Simple Mail Transfer Protocol)
53 DNS Domain name server
80 HTTP Hypertext transfer protocol
443 HTTPS
3306 Default port of the MySQL service
110 POP3 mail protocol

3) What about TCP’s three-way handshake? (key)

First handshake: The client establishes a connection and sends a request packet to the server for confirmation.

Second handshake: After receiving the request packet from the client, the server acknowledges the ACK field +1, that is, X+1, and sends the SYN field to the client.

Third handshake: The client receives the SYN_ACK packet, sets the ACK to Y +1, and sends the packet to the server again. As a result, both the client and the server enter the ESTABLISHED state and complete the three-way handshake.

4) What happens if the third handshake fails? Why four waves and not three, or five

If the server fails to receive an unacknowledged packet for the third time, the server resends the packet due to timeout. If the server still does not receive an acknowledged packet or receives a data packet, the server directly sends a reset packet to end the connection.

The reason why a request is needed at the end of the four waves is that: the client unilaterally sends no data and thinks it can be finished, but the server does not necessarily have no data to send, so the server should divide the confident message and its own initiation into two steps.

5) What happens when you type the url into the browser and execute it?

More details: juejin.cn/post/694178…

6) How to convert IP to MAC address, MAC address to IP address?

ARP and RARP.

A quick explanation:

  • Each host has an ARP buffer, which contains an ARP relation list, mainly the mapping between IP and MAC addresses.
  • When the source host needs to send data, first checks its own ARP list whether there is corresponding to the MAC address of the host if there is direct send the data, if not, just send ARP packets to this period of all of the host, the packet format for: the source host IP address source host MAC address the IP address of the target host.
  • After receiving the ARP packet, all the devices on the local network check whether they are requested by the other party. If they are not, they ignore it. If they are, they write the data into their own ARP list.
  • After receiving the response, the source host writes the IP address and MAC address of the destination host into the ARP list and uses the data to send data. If the source host does not receive an ARP reply, ARP query fails.

Here is the need for popular ARP spoofing:

ARP spoofing ARP spoofing (also known as ARP poisoning (ARP viruses in the network) or ARP attack, is an attack technology for RESOLVING ARP in Ethernet address poisoning. It can deceive the gateway MAC address of PC visitors in the LAN. The visitor’s PC mistakenly thinks that the changed MAC address of the attacker is the GATEWAY MAC address, and the network fails. Such an attack allows an attacker to access or even tamper with data packets on a LAN, and can render certain or all computers on the network disconnected.

Simply put, packets destined for the gateway are intercepted by machines masquerading as network administrators.

7) Talk about the OSI seven-tier model and the TCP/IP four-tier model

Details: juejin.cn/post/694178…

8) What requests are included in the HTTP protocol?

— — — — — — — — — — — — important — — — — — — — — — — — —

  • GET: A simple request for a server resource
  • POST: Used to send a request containing user-submitted data

— — — — — — — — — — — — and — — — — — — — — — — — –

  • HEAD: Similar to a GET request, but with no concrete content in the response returned, used to retrieve the header
  • PUT: a version of the legendary request document
  • DELETE: makes a request to DELETE the specified document
  • TRACE: Sends a copy of the request to TRACE its processing
  • OPTIONS: Returns all available methods to check which methods are supported by the server
  • CONNECT: proxy-based request for SSL tunnels

9) What is the difference between Get and Post?

From the original point of view:

  • According to the HTTP specification, GET is used for information retrieval and should be secure and idempotent
  • According to the HTTP specification, a POST request represents a request that may modify a resource on the server

On the face of it:

  • GET request data is appended to the URL, and POST data is placed in the HTTP package body
  • POST is more secure than GET

The resources

Why is TCP three handshakes, why not two or four && TCP four handshakes

TCP three handshakes (what if the third fails), four waves (why did he have one more)

Computer Network (a must for every developer)