“This article has participated in the call for good writing activities, click to view: the back end, the big front end double track submission, 20,000 yuan prize pool waiting for you to challenge!”

preface

TCP in the study of network knowledge is often asked knowledge points, but also programmers will learn knowledge points, today Xiao Yang with the most straightforward expression to bring you to know, like friends remember little attention ha.

What is the TCP

It’s a connection-oriented, reliable, IP-based transport layer protocol. A TCP connection must be established by three handshakes and broken by four handshakes. A TCP connection must be established by three handshakes and broken by four handshakes

Three-way handshake

What about three handshakes? A picture of Zhang SAN visiting Li Si’s restaurant is introduced to you:

From the picture above, we have a general idea of what it means. With a bit of terminology introduction:

  • First handshake: The client initiates a request and sends a SYN packet to the server to establish a request
  • Second handshake: After receiving a request from the client, the server sends a packet (SYN/ACK) to the client, indicating that it has received the request and needs to be confirmed
  • Third handshake: The client sends a request (ACK packet) to the server to confirm the connection

Why do you need three

You think as a zhang SAN door to find Li Si Cha rice, which step can save? Ask and answer, the last affirmation is to give somebody else reply, otherwise somebody else still think you joke, you say right

Four times to wave

So what does four waves look like?

With the above picture, we also know what it means. After eating a lot of food, Zhang SAN wants to escape. With a bit of terminology introduction:

  • First: Zhang SAN after a meal operation to eat, he sent a (FIN packet) thinking of bucket run
  • Second: Li Si received the message, found that there is a famous finale dish has not been served, want to let him taste, so he sent an (ACK packet), told him to wait
  • Third: a moment of food, Zhang SAN also ate, satisfied, sent a (FIN packet) tell Zhang SAN, today’s dishes are finished, the meal is over, to go can go
  • Fourth: After zhang SAN received the message, he returned a (ACK packet), indicating that he received it, and then ran away

Why do I need four

From the above scene, the request that Zhang SAN wants to leave does not mean that the other party has finished dealing with it, so they reply politely first to show that they know you have sent the request. After Li Si’s arrangements are all ready, they take the initiative to tell Zhang SAN that Zhang SAN also left after knowing.

Welcome to our discussion below. If there are any mistakes in this blog, please comment, thank you very much!

Make progress together, learn and share

If you think it’s written well, click a “like” and add a follow! Keep updating!! Pay attention, don’t get lost, Xiao Yang take you to the highway

We have sorted out hundreds of all kinds of technical e-books and learning materials, the latest interview questions, note the public number [write code xiao Yang] reply [information] no routine to receive