A wonderful encounter on tcp / ip a (three-way handshake fourth wave)

  Based on the three-way handshake tcp / ip, the fourth wave is not very understanding, so I spent a little time query related knowledge, and a summary of their knowledge, and give yourself the next memory management thinking.

  •  Three-way handshake

  ①  first handshake

  Client sends a request ( SYN : Synchronization ), and select an initialization sequence number ( SEQ : Sequence )

  syn=1;seq=x

  The client status changes ( SYN-Sent : synchronization_sent )

  ②  second handshake

  Server responds: the listen ----> syncrcvd (synchronizationrecieved);

  We received a request from the listener into a  state becomes established

  syn = 1 ACK = 1

  ack = x + 1 (q confirmation number )

  Send sequence number seq = y

  ③  third handshake

  The client receives the sender's server TCP validation requests created,

  State becomes established

  Acknowledge receipt of the request, the server returns the information

  ACK = 1 ack = y + 1 (q confirmation number )

  Send sequence number seq = x + 1

 

  •  Four waving

  ①  first wave

   The client process to release messages, send messages FIN = 1;

   Sequence number seq = u;

   State is FIN-WAIT-1

  ②  second wave

   Server receives packets ACK = 1 confirmation number ack = u + 1

   Send a message to the client sequence number SEQ = V ;

   State CLOSE_WAIT

  ③  Third Wave

   The server continues to send packets FIN = 1;

   Acknowledge receipt of the message again ACK = 1 confirmation number ack = u + 1

   Send a message to the client sequence number seq = w;

   The final confirmation state Last_ACK;

  ④  Fourth Wave

   The client receives the information server

  Acknowledge receipt of ACK = 1 confirmation number ack = w + 1;

  seq=u+1;

  State to CLOSED

  

  

  


 

  The above is based on the tcp / ip three-way handshake fourth wave of the interpretation process, but due to the official explanation too, does not seem easy to understand, and even hard to remember, even confusing relationship between the two.

  

  因此,我脑补了这样一段情节帮助理解记忆,我现在把客户端当作一个羞涩的男孩,服务端当作一个矜持的女孩

  现在规定两者进行对话,每次说一句话,记作seq并且记录其特有的编号,ACK表示确认收到对方的消息,并且后面需要跟上ack(认可对方的语句并在其特有标号后+1)

 

  于是故事是这样的,一个羞涩的男孩邂逅了一个矜持的女孩,他认可她(syn:synchronization作为标记),他尝试这给女方对话,说出了他的第一句话(seq=x);

  女方收到了男方的消息,并且也认可了男孩,先确认(ACK,ack=x+1),女孩给男孩回了一句(seq=y),此时男孩欣喜若狂也很礼貌的做了回应(ACK,ack=y+1),在他原来沟通的基础上

  继续沟通(seq=x+1),就这样,两人的初步认识了,也开始了交流(信息传输过程)。

 

  但是,相遇总是短暂的,马上到了分离的时分,作为男方,虽然不舍但是很绅士提出要分开的意思(fina=1)并发送了消息,女孩一如既往的确认消息并回复,但是因为出于矜持,她用只有自己能听到

  声音说了很多想对男孩话(发送语句从v变w不连续的原因),终于她向男孩说出了,时间不早了,这将是她们这次的最后一次谈话(fina=1)并再也不发声了,男孩收到消息后沉默了数秒并确认消息并道别。

  望着对方渐行渐远的背影,他们结束了这段对话,分离是为了下一次更好的邂逅。

 

  具体脑补只能根据自己理解到这种程度,请轻喷,如有错误之处,请指正。

  三次握手四次挥手两者的状态(情绪)如下

  

  •  三次握手:双方状态

客户端状态

 syn-sent---------------------------------------->established

服务端状态

                    listen---------->syncrcvd------------------------->established

 

  • 四次挥手:双方状态 

客户端状态

established--->fin-wait-1------------------->fin-wait-2----------------->time_wait------------------------------>closed

服务端状态

established------------------>close-wait---------------------->fin-ack------------------------->closed

 

Guess you like

Origin www.cnblogs.com/daoyouzhanzhu/p/11300127.html