A, TCP features
- Connection-oriented, reliable transport layer protocol based on the byte stream.
- The application layer is divided into segments, and the target node transmits the TCP layer send.
- It has a number of data packets, the other received the acknowledgment ACK is transmitted, retransmission is not received.
- Use efficacy and efficiency if the experimental data to error during transmission.
Two, TCP packet information
Packet header contains information include:
- Source port, destination port
- Marking process (socket): IP address + protocol + port number
The TCP flags mark:
- URC: urgent, urgent pointer is effective when 1;
- ACK: acknowledgment sequence number flag;
- PSH: push sign, do not enter the data cache, directly to the application;
- RST: Reset the connection flag;
- SYN: synchronization sequence number, the process for establishing a connection;
- FIN: finish flags to release the connection.
Three, TCP three-way handshake
Flow chart below (painted by Yo - Recommended tools: online at ProcessOn):
TCP three-way handshake flow chart Details:
- When connection is established, the client sends a SYN packet (seq = x) to the server, and enter SYN-SEND state, the server waits for acknowledgment.
- Server receives a SYN packet, the client must confirm SYN (ack = x + 1), at the same time, they would send a SYN packet (seq = y), i.e., SYN + ACK packet and the SYN-RECV state into the server.
- 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 the server into ESTABKISHED state. Start data transmission.
Four, TCP's four wave
TCP flow chart four times and waved Details:
- After the client sends a FIN, for closing the data transfer service to the client, client enters FIN-WAIT-1 state.
- After receiving the FIN service, transmits an ACK to the Client, the acknowledgment number of the received seq + 1 (the same SYN, FIN a occupy a sequence number), service into the CLOSED-WAIT.
- sending a service FIN, for closing the data transfer service to the client, service into the LAST-ACK state.
- After the client receives the FIN, client enters TIME-WAIT state, then sends an ACK to-Service, the acknowledgment number of the received sequence number +1. service enter CLOSED state, completed four times and waved.
Five, TCP sliding window
Role: ① to ensure the reliability of TCP;
② ensure that the flow control characteristics of TCP (transmission data sequence).
Six, UDP characteristics
- For non-connection
- Does not maintain a connection state, supports simultaneous transmission of multiple clients want the same message
- Only the packet header 8 bytes, an additional small opening
- Restricted to only certain data generation rate, the transmission rate and performance of the machine
- Do our best to interact, does not guarantee reliable delivery, does not maintain a connection status table
- Oriented message, the message does the application submitted by the split and merge
Seven difference, TCP and UDP
- For connection / connectionless
- Reliable / Unreliable
- Packet order / disorder
- speed
- Middleweight