This is the sixth day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

DNS

MDN Definition: The domain name System (DNS) is a hierarchical and decentralized naming system for Internet resources. DNS maintains a list of domain names and corresponding resources such as IP addresses.

An example: accessjuejin.cn

SequenceDiagram User ->> Browser: juejin. Cn Browser ->> Operating system: "Mobile, Unicom, Telecom" -> Operating system :IP is 1.2.3.4 Operating system ->> Browser :IP is 1.2.3.4 Browser ->>1.2.3.4: Establishing a TCP connection

In this process, the browser has the browser cache, and the operating system has the operating system cache. If each can retrieve the required information from its cache, the process can be interrupted. But the ISP must have known the IP address of Juejin.cn. We sometimes set a host, which is the equivalent of manually adding a cache to the operating system. When the browser visits again, the corresponding IP address can be accessed from the operating system cache.

Three-way handshake

Transmission Control Protocol (TCP) is a connection-oriented and reliable Transmission layer communication Protocol based on byte stream.

An example: A and B make A phone call

A-)B: Dial B--)A: Hello A-)B: Hello A-)B: Hello A-)B: It's like this...

A calls B, and B calls back “hello”, and A calls back “hello”. The first three steps are called “three handshakes”.

Do you think A is A little redundant to say “hello” again? A can talk about the matter directly. For the sake of preciseness, this is still needed.

Three-way handshake during TCP connection establishment

SequenceDiagram A-)B: SYN(x) x=100 "Synchronous 100" B--)A: ACK(x+1) SYN(y) y=900 "aware 101 synchronous 900" A-)B: ACK(y+1) "aware 901" A-)B: HTTP content
  • SYN is short for synchronize, where x is any positive integer starting from 0, such as 100
  • ACK stands for acknowledge, and y is any positive integer starting from 0, such as 900

Here’s why we need ACK of y plus 1 from A to B, in general, to prevent errors from happening. It can be known from the above two steps that A can send messages to B, and B can receive messages and send messages to A, but it is not clear whether A can receive messages. If A does not wait for B’s message and then interrupts the communication, B cannot determine whether to continue the communication without knowing whether A can receive the message.

Four times to wave

An example: A and B get off the phone

SequenceDiagram A-)B: I'm done B--)A: Oh B--)A: But I have one more thing to say, I love you B--)A: I'm done too A-)B: Oh

Question: This is not five sentences? Why four times? Because B’s “I love you” to A is not necessary.

Four waves during TCP connection disconnection

SequenceDiagram A-)B: FIN(x) x=500 "End 500" B--)A: ACK(x+1) "know 501" B--)A:...... "Additional content, may not be" B--)A: FIN(Y) "End 999" A-)B: ACK(Y +1) "Noted 1000"
  • FIN is short for FINISH. X is any positive integer starting from 1, for example, 500
  • ACK stands for acknowledge, and y is any positive integer starting with 1, such as 999

Why can’t ACK and FIN of B->A merge? Because B might have something else to transfer.

The whole process of TCP

Problem sets

  • What is the difference between TCP and UDP? “ACF”

    • A. TCP is stateless whereas UDP is stateless
    • B. TCP is stateless and UDP is stateful
    • C. TCP is reliable, but UDP is unreliable
    • D. TCP is not reliable, UDP is reliable (not lost and not repeated)
    • E. TCP has higher transmission efficiency and UDP has lower transmission efficiency
    • F. TCP has low transmission efficiency and UDP has high transmission efficiency
  • Why can’t TCP’s three-way handshake be reduced to two? “B”

    • A. To look good
    • B. Ensure that client A can receive data from server B
  • Why can’t TCP’s four waves merge the middle two steps into one? “A”

    • A. Because there is often other data that needs to be sent between two steps
    • [B] because it’s not symmetrical when it’s combined

One last word

If this article is helpful to you, or inspired, help pay attention to it, your support is the biggest motivation I insist on writing, thank you for your support.