Advantages and disadvantages of SRT compared to TCP protocol

        The mainstream streaming media protocols, such as HTTP, HLS, and RTMP are TCP protocols, while RTSP can be based on both TCP and UDP protocols for data transmission.

        Judging from the trend, most of the new streaming media protocols choose UDP as the underlying transport protocol. The main reason is related to the characteristics of the streaming media service itself and the characteristics of TCP. In terms of live broadcast, the most common business of streaming media, users need fast streaming, low latency, and no lag. In the case of a weak network, they can accept the loss of part of the picture, but hope to recover quickly.

1. Limitations of the TCP protocol    

        First, the TCP protocol handshake takes a long time. The TCP protocol requires 3 handshakes to establish a link, and 4 handshakes are required to pass TLS encryption. In terms of connection establishment, the TCP protocol has too many interactive processes and is not suitable for fast outflow.

        Second, window blocking leads to serious time-consuming. The TCP protocol is a highly reliable and orderly protocol, so if a data packet with a lower sequence number is lost, even if the packet with a higher sequence number has been received, it cannot be used until the retransmission with a lower sequence number is received, causing the current window to be blocked at the original Ground (TCP queue head blocking), if the retransmitted data packets are also lost, the waiting time to trigger another retransmission will be doubled (the retransmission strategy is mild), and this mechanism will affect the data transmission efficiency, which requires high real-time performance streaming business, is unacceptable.

        Finally, weak network conditions performed poorly. The slow start and congestion avoidance algorithms of the TCP protocol will greatly reduce its own bandwidth occupation, thereby protecting the stability of the entire communication link. Therefore, once a weak network is encountered under this strategy, it will appear that the live broadcast screen freezes, and there is basically no ability to fight against weak networks.

2. Advantages and disadvantages of SRT protocol

        The SRT protocol solves the problems of the TCP protocol in streaming media services through simple handshake, fixed delay, ARQ (Automatic Repeat Request), FEC (Forward Error Correction), ACK, NACK and other strategies.

2.1. How does SRT solve the long time-consuming handshake?

        SRT can quickly establish an SRT link through two handshakes and parameter exchange (total time consumption: 2RTT). Compared with the handshake time of the TCP-based streaming media protocol RTMP 3RTT, the total time consumption is reduced by 1 RTT.

2.2. How does SRT achieve reliable transmission?

        After the SRT handshake ends, media data and control instructions can be sent. The media data structure is as follows:

picture

  • Data packet serial number: The initial value of the data packet serial number is determined during the handshake, and each time a data packet is sent, the data packet serial number will be increased by 1;
  • Message serial number: The message serial number starts from 0, and each time a data packet is sent, the message serial number will be increased by 1. The functions of the first four flag bits of the message serial number are shown in Figure 3;
  • Timestamp: based on the establishment time, the unit is microseconds;
  • Destination port socket ID: It can be used to distinguish different SRT streams during multiplexing.

ACK control command

picture

NAK control command

picture

        The SRT sender can specify which data packets have been sent through the data packet sequence number and message sequence number ;

        The SRT sender knows which data has been successfully received through the ACK control command sent by the receiver;

If packet loss occurs, the SRT sender can determine which data needs to be retransmitted through the NAK control command         sent by the receiver .

        Through the above methods, SRT realizes reliable transmission.

2.3. How does SRT solve the window blocking problem?

        From the implementation of 2.2, the SRT sender must have a send buffer, and the SRT receiver also needs a receive buffer to realize the mechanism of data retransmission after packet loss. The SRT protocol uniformly specifies the size of the sending buffer and receiving buffer by setting a fixed delay.

        The sending buffer is used to save data packets that may need to be resent. Once the data packet receives an acknowledgment (ACK), the data packet will be cleared out of the sending buffer (this is similar to TCP). Once the sending buffer If a data packet has not received an acknowledgment, the data packet will also be cleared out of the sending buffer after the fixed delay time . In this way, SRT solves the problem of TCP queue head blocking.

        Based on the above principles, it can be seen that SRT is not a completely reliable transmission protocol, and its reliability is between the UDP protocol and the TCP protocol.

2.4. How does SRT solve poor network performance?

        From the content of the ACK control command , it can be found that the ACK contains many network parameters, such as RTT time and so on. Through parameters such as RTT time and link bandwidth, SRT can estimate the entire network status, thereby realizing adaptive adjustment.

        SRT will still maintain a large sending rate in the case of a poor network. Therefore, in a weak network environment, SRT will occupy more network bandwidth to ensure fluency.

        It is worth noting: If the network is full of protocols similar to the SRT sending strategy, no one's data may eventually be sent out. Therefore, the characteristics of the SRT and TCP protocols can be considered comprehensively in the selection of services, and important services can be guaranteed first.

2.5. Defects of SRT

        Although the SRT protocol has many advantages, there are some disadvantages that cannot be ignored. Firstly, the SRT protocol occupies a high bandwidth in a weak network environment; secondly, the transmission strategy of the SRT protocol is aggressive, which will affect other users on the same network; finally, because the underlying layer of SRT uses UDP, the firewall is not friendly to UDP.

        Therefore, the SRT protocol is more suitable for point-to-point high-quality, low-latency and reliable transmission, but not suitable for content distribution to a large number of users.

Guess you like

Origin blog.csdn.net/weixin_35804181/article/details/131769793