JAVA internship job search-network programming

Common network models

Application layer

Transport layer: TCP, UDP

Network layer: IP

data link layer

Physical layer

Problem 1: TCP protocol and UDP protocol

TCP: 1. Before using the TCP protocol, a TCP connection must be established to form a transmission data channel; 2. The "three-way handshake" method is used before transmission, which is reliable; 3. A large amount of data can be transmitted in the connection; 4. After the transmission is completed, the connection needs to be released, which is inefficient

UDP: 1. Encapsulate data, source, and destination into data packets without establishing a connection; 2. Each data packet cannot exceed 64k; 3. Can be broadcast and sent without confirmation; 4. No need to release resources after sending, efficiency high.

Question 2: TCP three-way handshake and four waved hands

TCP three-way handshake

The first handshake: the client sends a syn = x packet to the server, syn: synchronization sequence number

The second handshake: the server accepts the syn packet, generates an acknowledgment packet ack = x + 1, and sends its own syn = y packet, so the server sends the syn + ack packet, and the server status is SYN_RECV

The third handshake: the client receives syn + ack and sends an acknowledgement packet ack = y + 1. At this point, the connection is established successfully, and the client and server are in ESTABLISHED state

Four wave of TCP

The first wave of hands: the client sends FIN, which is used to close the data transmission from the client to the server, and then wait for the server's confirmation. The termination flag bit FIN = 1 and the sequence number seq = u.

The second wave: when the server receives this FIN, it sends an ACK, confirming that the ack is incremented by one.

The third wave: the server closed the server-to-client connection and sent a FIN to the client.

The fourth wave: after receiving the FIN, the client sends back an ACK message to confirm, and sets the confirmation sequence number seq to the received sequence number plus one. The first party to perform the shutdown will perform an active shutdown, while the other party will perform a passive shutdown.

Published 111 original articles · Like 60 · 70,000 + views

Guess you like

Origin blog.csdn.net/Haidaiya/article/details/105577066