TCP and UDP on that point thing

First, what is UDP

UDP, User Datagram Protocol. It is a transport layer network protocol. Its main features are:
1. No connection. I.e. no connection before sending data entering into the reception, the cost can be reduced.
2. for the message. UDP applications to pay down the message, do not merge, it will not split, but coupled with the UDP header after delivery to the network layer, which is the first to deliver a complete packet
3.UDP do our best to provide delivery, does not guarantee reliable delivery
4.UDP no congestion control, so when the network is congested, does not reduce the transmission rate can be applied to some real-time applications
5.UDP support one to one, one to many, many to many, many-interactive communication
header overhead 6.UDP small, only 8 bytes (source port, destination port, length, checksum)
Here Insert Picture Description

Second, what is TCP

TCP, Transmission Control Protocol. Another network transmission protocol layer. Its main features are:
the connection 1. oriented. That is using the TCP protocol, you need to establish a TCP connection, the transfer is complete, you need to release the connection.
2. byte stream oriented. I.e., cross-TCP application packets down, and delivered to the lower layer is not disposable, but the receiver according to the sliding window, the size of the data block into the corresponding byte stream, TCP header plus the delivery to the lower .
3.TCP provide reliable delivery of the data that is transmitted through the TCP, is not lost, error-free, the complex is not sufficient, and sequentially arrive
4.TCP provides full-duplex communication. (Only the connection before talking full-duplex or half-duplex, so that no such definitions UDP)
5.TCP has a sliding window, and can perform congestion control
6.TCP each supports only one connection point (the point socket word)
header 7.TCP least 20 bytes
Here Insert Picture Description

Speaking of TCP, TCP would have to mention the essence - the sliding window
sliding window is bytes. Each window can be transmitted according to the number of bytes received adjustment, wherein the number of bytes changed, i.e. to change the size of the sliding window. In addition, every time the sender before sending new data, data needs to receive confirmation once before, a long time if not receive confirmation that triggered the timeout retransmission mechanism, according to confirmation number to resend the data, only after receipt of confirmation, window to slide backwards. This ensures reliable delivery. Also, the sender and receiver must have a caching mechanism, the receiver also have a cumulative acknowledgment function, improve efficiency confirmed. Can be achieved by a sliding window flow control.
Here Insert Picture Description

TCP congestion control method of
the slow start, congestion avoidance, fast retransmit, and fast recovery
1. Slow Start: that is, each receives a packet acknowledgment segment, the congestion window is incremented, i.e. each time after a transport wheel, the congestion window it doubled.
2. Congestion Avoidance: after every transmission of a round, the congestion window is incremented.
3. Fast retransmission: after receiving the required data in the receiver must send an immediate acknowledgment
4. Fast Recovery:

  1. Upon receipt of the third duplicate ACK, the ssthresh is set to half the current congestion window cwnd. Retransmission of lost segments. Set cwnd to ssthresh plus 3 times the segment size.
  2. Each time it receives another duplicate ACK, cwnd increases the size of a segment, and transmits a packet (if allowed to send a new cwnd).
  3. When the next new data acknowledgment ACK arrives, set cwnd to ssthresh (the value set in step 1). This acknowledgment ACK should be retransmitted in step 1 within a round trip time after performing the retransmission. Moreover, this should also be ACK acknowledges all the intermediate packets between the packet loss and a duplicate ACK segment is received.

TCP connections are required and the release of "three-way handshake" and "four wave", with particular reference to the following detailed procedures:
https://blog.csdn.net/weixin_43896829/article/details/103431436

Third, the difference between the two (summary)

1.UDP is connectionless, TCP is a connection-oriented
2.UDP oriented packets, TCP byte stream and
3.UDP provide best effort delivery, TCP provides reliable delivery
4.UDP header of 8 bytes, TCP header of at least 20 bytes
5.TCP has a sliding window flow control can be performed and congestion avoidance

Published 24 original articles · won praise 0 · Views 589

Guess you like

Origin blog.csdn.net/weixin_43896829/article/details/104886650