The RTMP protocol is based on TCP, dividing application layer messages into chunks to send via TCP. Besides increasing the chunk size to a large number, such as 60000, to avoid fragmentation, one can also optimize the packet sending method by combining many small packets into one transmission to the client, avoiding separate sending of each small packet, as each round-trip with TCP can be quite cumbersome.
Let’s look at an unoptimized example, a sequence of RTMP from a well-known CDN, which took a total of 39 TCP packets to start transmitting data packets. The initial stages comprise the tedious RTMP handshake and interaction:
/>
SRS has optimized for RTMP by combining some small packets, which can reduce the number of packets by about 10. See the image below:
/>
SRS is not the most efficient; there’s room for further improvement by reducing some packets even more. Minimizing TCP interactions, data packets can be sent promptly. The optimization result for BMS is shown below:
Completing interactions with the fewest TCP packets, both SRS and BMS show the best transmission performance under the same network speed.
Note: For accurate Wireshark parsing, both SRS and BMS chunk sizes are set to 128, though their default chunk sizes are 60000, which, despite incorrect Wireshark parsing, does not affect playback.