Transport layer protocol (essential practical information for rookies)
1. There are two protocols in the transport layer:
TCP: Transmission Control Protocol, secure but inefficient.
UDP: User Datagram Protocol, efficient but insecure.
2. TCP protocol characteristics:
3. TCP message segment:
(1) Serial number: The sender numbers each byte to facilitate correct recombination at the receiver, 32 bits.
(2) Confirmation number: used to confirm the information of the sending end, 32 bits.
(3) Header length: indicates the length of the data segment header, 4 bits.
(4) URG: emergency pointer valid bit, when it is 1, the emergency pointer is on, when it is 0, it is closed, and it does not pass through the cache.
(5) ACK: Acknowledgement sequence number bit, used to confirm the data of the sender when it is 1.
(6) PSH: Start receiving and transmitting application layer. When it is 1, it is turned on, when it is 0, it is turned off, and it passes through cache.
(7) RST: When it is 1, it means that the other party is required to re-establish the connection.
(8) SYN: synchronization sequence number bit, this bit is 1 when TCP needs to establish a connection.
(9) FIN: Set this bit to 1 when TCP disconnects.
(10) Window size: used to indicate the number of locally acceptable data segments, the window size is variable. (Flow control mechanism)
Checksum: Error control, used to verify data integrity, 16 bits.
(12) Emergency pointer: a positive offset, used with URG, 16 bits.
TCP's three-way handshake:
(1) PC1 (client) sends SYN message request to PC2 (server);
(2) PC2 (server) responds to PC1 (client) ACK message acknowledgement and simultaneously sends SYN message request;
(3) PC1 (client) responds to PC2 (server) ACK message acknowledgement.
TCP's four waves:
(1) PC1 (client) sends FIN request and ACK message acknowledgement to PC2 (server);
(2) PC2 (server) receives ACK message acknowledgement and disconnects;
(3) At this time, PC2 (server) can also transmit data to PC1 (client), becoming TCP semi-closed;
(4) PC2 (server) sends FIN request and ACK message acknowledgement to PC1 (client);
(5) PC1 (client) responds to PC2 ACK message acknowledgement and disconnects;
Common TCP port numbers:
7. UDP protocol and its message format:
8, UDP commonly used port number: