java improve the network

1. The three-way handshake and four wave

1. The three-way handshake to establish a connection

1. Pre-knowledge

  • ACK Acknowledge Character acknowledgment character
  • SYN synchronize the synchronous signal, the connection signal emitted
  • FIN finish end signal (not sure, roughly meaning of it, later amended)

2. concept

The first handshake: a client sends syn packets (seq = x) to the server, and enters SYN_SEND state, waiting for the server to confirm; second handshake: server receives syn packets, must confirm the customer SYN (ack = x + 1) , while themselves sends a SYN packet (seq = y), i.e., SYN + ACK packet, then the server enters a state SYN_RECV; third handshake: the client receives the SYN + ACK packet to the server, the server sends an acknowledgment packet ACK ( ack = y + 1), this packet is sent, the client and server into the ESTABLISHED state, complete the three-way handshake.

Bag handshake does not include the transfer of data, after three-way handshake is completed, the client and server before the official start transferring data. Ideally, TCP connection, once established, before any party in the communication of the two parties take the initiative to close the connection, TCP connection will be kept down.

2. Disconnect the four-way handshake

concept

The first wave: Active close sends a FIN, for closing the active side to the closed side of the passive data transfer, that is, take the initiative to close the square to tell passive close side: I've made will not give you the data (of course, the fin before the packet data sent out, without receiving a corresponding acknowledgment message ack, still actively closed side retransmits the data), but this time the active close side may further accept data.

Second wave: passive shutdown has received the FIN packet, sends an ACK to each other, for the receipt of the acknowledgment number No. + (the same SYN, FIN a occupy a sequence number).

Third Wave: Passive closed sends a FIN, for closing the passive side to take the initiative to close the closed side of the data transfer, that is, to tell the initiative to close the party, I also send the data over, will not give you send the data.

The fourth wave: the initiative has received close after FIN, ACK to send a passive closed party, numbered receipt confirmation number +1 This completes the four wave.

2. OSI seven layer protocol

Reference https://baijiahao.baidu.com/s?id=1623342279899809678&wfr=spider&for=pc
7- application layer, 6 presentation layer, session layer, 5-, 4-transporting layer, 3 the network layer, data link 2- layer, the physical layer 1-

Historical Evolution

  • How communication between two hardware requires the physical layer, the physical line, in units of bits.
  • Development of the times, with the wireless communication, different media needs to ensure the accuracy of data transmission, the data link layer
  • Large files need to ensure accuracy of the data, the data packet is encapsulated, the transport layer
  • Terminal more and more, how to quickly find each other, network layer, routers, IP, TCP / IP protocol
  • Bad user experience, it is desirable to automatically send and receive packets, automatic addressing, session layer, establishing communication between the management application and the
  • Different operating systems, different grammar, presentation layer, to solve communication problems between different systems grammar
  • You could happily write applications implementation requirements, application layer

Guess you like

Origin blog.csdn.net/wjl31802/article/details/91961687
Recommended