当前位置:网站首页>UDP reliable transport protocol (quic)

UDP reliable transport protocol (quic)

2022-07-06 03:33:00 Four in the domain

UDP And TCP contrast

 Insert picture description here
 Insert picture description here TCP Sticky subcontracting may occur
UDP impossible , And a frame of data must be read at one time , Otherwise, the unread part will be lost

Reliability mechanism

ACK Mechanism

That is, the response mechanism , Every time you receive a package, you will give it back ack, Let the sender know that the other party has received

Retransmission mechanism

ARQ Three modes of agreement
(1) Stop equation ARQ : wait for ACK, The opposite party was not received within the specified event ACK, Then retransmit the frame
 Insert picture description here

(2) Back off n frame ARQ : Don't wait for the opposite ACK, Each package has a lifecycle , I didn't receive it before the end of my life ACK, Then go back to the package and re contract ( The packet after the error frame has been sent , Still need to resend
 Insert picture description here

(3) Selective retransmission ARQ : Don't wait for the opposite ACK, Each package has a lifecycle , I didn't receive it before the end of my life ACK, There is no need to go back to the package and re contract , Just resend the package
 Insert picture description here

Flow control

Control the sending rate of the sender , To prevent the recipient from reading data in time , Cause the packet to be discarded after the cache is full
(1) The recipient informs the sender of the remaining cache space , So that the sender can control the sending rate
(2) If the sender stops sending because the other party's cache is full , Then the recipient needs to notify the sender to start sending
4. Congestion control
(1) Slow start : After network congestion , Try sending from a few packets , Gradually send packets exponentially , Until the number of packets returns to the normal number ( Because the bandwidth is getting larger , The scheme has been abandoned )
(2) Fast recovery : After network congestion , Try sending from half the packets , Increase gradually

Serial number mechanism

Rearrangement mechanism

Window mechanism

UDP Reliability design

UDP Window flow control

KCP( For real-time reasons )

  1. RTO Double
    TCP The timeout is calculated as RTO Time keeps doubling
    KCP The medium super time is calculated as RTO Time is multiplied by 1.5( Empirical value , The test shows that this value is better )

  2. Retransmission mechanism
    TCP Use fallback N frame ARQ Mechanism ( All retransmission )
    KCP Use selective retransmission ARQ Mechanism

  3. The fast retransmission
    Packet skipping occurs ( The packets received by the receiver are discontinuous , Several tundish are missing ), Don't consider... At this time RTO, Optimize the transmission efficiency in case of packet loss

  4. ACK Delay
    TCP In order to make better use of broadband , Delay to send ACK, such RRT Time is large
    KCP You can set whether to delay

  5. ACK、UNA
    5.1 explain UNA: such as UNA 3, Means to inform sender, package 0、1、2 Have received , This is the time sender The swap will be released 0、1、2, If subsequent retransmission is required , These three packets will not enter the retransmission queue ,
    5.2 KCP yes ACK+UNA Mechanism
    5.3 TCP It's one of two

  6. No surrender, no flow control
    TCP Use The law of fair concession ( Sending window size determinants : Send cache size , The remaining cache size at the receiving end , Packet loss concession , Slow start ),
    KCP You can configure skipping Packet loss concession as well as Slow start , Make timeliness more powerful

  7. Code path :https://github.com/skywind3000/kcp
    Above for KCP Those who don't clear the explanation can go github Learn from , Again readme The optimized performance part is explained in detail in .
     Insert picture description here

 Insert picture description here 8. KCP The code architecture
 Insert picture description here

QUIC

sketch

  1. Fast UDP network connections
  2. Google The proposed experimental network transmission protocol
  3. be located OSI Network model transport layer
  4. User mode is based on UDP Implemented transport layer
  5. To solve TCP The defects of the agreement will eventually replace TCP agreement , Reduce data transmission , Reduce connection setup latency , Speed up Web page transmission
  6. Document connection :https://quicwg.org/base-drafts/rfc9000.html

advantage

  1. Flexible congestion control mechanism ( Self actualization , You can also decide whether to use )
  2. No queue head blocking ( Every stream Separate from each other , Do not affect each other )
  3. Easy data migration ( After switching the network environment , No need to reconnect , Continue the previous connection channel and continue to transmit data )
  4. Baotou needs authentication , Data encryption in the package , Safety is better than TLS go beyond
  5. FEC Forward correction

shortcoming

  1. Putting it into the kernel has a great impact , All systems should be updated
  2. Router 、 A firewall 、 There are many intermediate devices that need to be changed

Message format

among Connection ID Is the connection number , It can reduce the number of three handshakes and four waves
 Insert picture description here  Insert picture description here Frame Type:

  1. bit01: stream ID length
  2. bit234: offset length
  3. bit5 : Yes no Data Length Field
  4. bit6: Indicates that the stream On the channel Whether sending data has ended , Whether it is half closed
  5. bit7: Identify whether the frame is stream frame

Stream ID One UDP There can be multiple Stream flow , The integrity of messages in each flow is independent of each other , In order to reduce abnormal times , Number of frames fallback

Establish low latency

 Insert picture description here  Insert picture description here  Insert picture description here

原网站

版权声明
本文为[Four in the domain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132318162965.html