Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

TCP and UDP

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

IP provides continuous point-to-point connection, and the target host can be found through the IP address. But there are many applications on the target host, which application does the server use to respond to the client? Determined by port number. 1. TCP:transmission control protocol-- Transmission Control Protocol

Reliable, connection-oriented protocols, like dialing phone numbers and communicating with peers, need to establish a connection, send data, and disconnect. Most of the network is TCP, and the important data transmission is also TCP.

Encapsulation format of 1.TCP

Destination port number: indicates which application to access, for example, port 80 represents http

Source port number: identify your own application

Serial number: the upper data is divided into many segments, the number of segments

Confirmation number: after receiving the data segment, the receiver should tell the sender that it has been received.

Window size: the receiver tells the sender how many segments can be sent at a time

two。 Three-way handshake: the process of establishing a connection in TCP

(1) sender A sends SYN=1 data segment to receiver B SYN:synchronize for synchronization

(2) the data segment that B responds to SYN=1,ACK=1 confirms to An ACK:acknowledge.

(3) A sends the ACK=1 data segment to B

3. Disconnect four times: after TCP sends the data, there are four steps to disconnect.

(1) Host A sends the data segment of FIN=1 to the other party B FIN:final finally

(2) the other party B responds to the data segment of ACK=1 to A

(3) B also sends data segments of FIN=1 to A.

(4) A responds to the data segment of ACK=1 to B

4.TCP flow control mechanism: (1) sliding window-the size of the window is variable, the receiver can tell the sender to send several windows, if he can not receive it, he can also tell the sender to change the number of sending windows at any time.

(2) congestion control-colloquially speaking, there is a desired reception value and the actual reception value, for example, you want to transmit 10 windows, but when the actual link bandwidth is narrow, the transmission becomes 5.

(3) method: a sender sends data with a number, and the receiver's confirmation number is the sending number plus 1. For example, send 100 and the receiver acknowledges 101.

B: if the sender sends 100,101,102, and the receiver receives all of them, the cumulative confirmation will be adopted. Confirm 103, which means 100-102 are all received. If the sender receives 103 confirmation, it thinks that all the data before 103 has been received.

C: send who confirms who: if the sender sends 100, 101, 102, the receiver receives 100 and 102, the receiver cannot confirm 103, because once 103 is confirmed, it means all received, so it has to confirm 101.

Error Control of 5.TCP

(1) checksum: in fact, it is a checksum tool. Each file will have a fixed checkcode calculated by the checksum tool. If there is a change in the file, even a small punctuation, the checkcode will vary greatly, which is used to check whether the data is damaged or lost.

(2) confirmation: the receiver explicitly informs the sender that the data has been received, which is the same as the above transmission method.

(3) timeout: if the sender does not receive an acknowledgement for a long time, it will be sent again.

Four timers of 6.TCP

(1) retransmission timer: related to the timeout above

(2) stick to the timer: prevent the problem of zero window deadlock. Example: when An is sending data to B, B says not to send it first, but when B is busy and asks A to send three data, it is lost. It appears that A has not received it and B is waiting for A to send data. So sender A will periodically send B a message saying that it is still waiting, and B will send it again.

(3) keep alive timer: prevent long idle time between two TCP connections. If the server finds that the client has no data transmission within a certain period of time, it will terminate the connection, otherwise it will occupy resources in vain.

(4) time waiting timer: used for four disconnections. Host A requests disconnection and B response can be disconnected. A received the message, it will be a while before it is really broken.

Application of 7.TCP

II. UDP:user datagram protoco-- user Datagram Protocol

Unreliable, non-connection-oriented services are like sending qq messages, which can be sent without being connected first, but do not know if they are received or not. Simple domain name resolution belongs to UDP services.

1. Encapsulation format

Application of 2.UDP

Flow Control and error Control of 3.UDP

UDP has no flow control mechanism.

Only checksums provide error control-upper layer protocols are required to provide error control: for example, TFTP protocol

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report