The crow feeds back: "Compendium of Materia Medica · Bird department" contained: "Kind wu: this bird was born, mother feeding sixty days, long back feeding sixty days." When the young crow grows up, the old crow can't fly and find food by itself, and the young crow will instead find food to feed its mother.Copy the code

By using this allusion, I hope to express that when we discuss relevant knowledge with the interviewer, we can let him get more understanding from you, so as to achieve the effect of feedback.

I hope this article has been helpful.

1. Five-layer protocol

In computer network, the architecture of five-layer protocol is as follows:

Transport layer is one of the key layers in the whole network architecture.

The network layer provides communication logic between hosts, while the transport layer provides end-to-end logical communication between application processes.

2. Reuse and reuse

The transport layer serves the application layer.

A very important function of transport layer is reuse and reuse.

The transport layer is equivalent to an office. All application processes of the application layer can be transmitted to the network layer (reuse) through the transport layer.

The transport layer receives data from the network layer and delivers it separately to the specified application process (reuse).

Different processes on different hosts use protocol port numbers to identify each other.

3. User datagram protocol UDP

Some features of UDP:

  1. UDP is connectionless, that is, no connection is required before sending data.
  2. UDP does its best to deliver, but reliable delivery is not guaranteed.
  3. UDP is packet oriented.
  4. UDP has no congestion control.
  5. UDP supports one-to-one, one-to-many, many-to-one, and many-to-many interactive communications.
  6. UDP header has low overhead.

Summary is: fast and accurate, I don’t care if you receive.

A UDP packet header contains only four fields: source port, destination port, packet length, and check and.

4. Transmission control protocol TCP

Some features of TCP:

  1. TCP is connection-oriented. Before using TCP, a connection must be established.
  2. TCP provides reliably delivered services. No error, no loss, no repetition, in order to arrive.
  3. TCP is byte stream oriented.
  4. TCP has congestion control.
  5. TCP can only be one-to-one.
  6. TCP provides full duplex communication.

All features of TCP are designed to ensure reliability.

5. Retransmission timed out

B detects an error when receiving M1 and discards M1, or M1 is lost during transmission. In both cases, B doesn’t send any information.

As long as A has not received confirmation after A period of time, the packet that was just sent is considered lost, because the packet that was sent before is retransmitted. This is called timeout retransmission.

Timeout retransmission is implemented by setting a timeout timer every time a packet is sent. Destroy the timer if it has not timed out, otherwise regroup.

In this case, A does nothing.

6. A sliding window in bytes

TCP’s sliding window is in bytes. The receiver will send its own window value in the window field to the other party, ensuring that the sending window of A is not larger than the receiving window of B.

The front edge of the send window is always moving forward. The following two situations will cause the send window to stop sliding:

  1. A The send window does not receive A new acknowledgement.
  2. B Receiving window The receiving window shrinks.

7. The TCP connection is established

The process of establishing a TCP connection is called a process. The handshake requires the exchange of three TCP packet segments between the client and server.

Why three times? Not twice?

In this case, the first request segment M1 sent by USER A is delayed in the network and is not received by user B. A Timeout retransmission is triggered if no acknowledgement is received.

A sends the request packet segment M2 again. After that, it is normal. A and B establish A connection to complete data transmission and then disconnect.

At this point, the stranded request segment M1 is sent to B. If A connection is established after only two handshakes are required, B sends the request segment to A to establish the connection.

User A discards the delayed packet and does not establish A connection. As a result, a lot of B’s resources are wasted.

8. The TCP connection is released

TCP disconnection requires a four-way handshake because of its full-duplex nature. That is, client A and server B can both send and receive packets.

It is worth noting that AFTER receiving the connection-release message segment from B, A sends the acknowledgement message segment. Instead of shutting down, A enters the time-wait state.

The waiting time is 2MSL, which is called the Maximum Segment Lifetime. RFC793 recommends 2 minutes.

If A does not receive the retransmission segment sent by B in 2MSL, B has received the close signal sent by A. 2MSL is the maximum time for receiving B’s retransmission message.

9. Keepalive Timer

Assume that a TCP connection has been established between the client and the server, but the client hangs up due to an exception. If the server sends 10 probe packets at an interval of 75 seconds and the client does not respond, the connection is closed.

10. Interview questions

  1. Talk about the five-tier model of computer networks
  2. Talk about reuse and reuse of the transport layer
  3. Differences between TCP and UDP
  4. Talk about TCP’s three-way handshake
  5. Talk about TCP four waves (2MSL)
  6. Why IS TCP reliable?
  7. Can TCP establish a connection with two handshakes? Why (can build, but waste resources, as above)

Ps: If you want to “computer network 7th edition” can leave a message /