SRT as we know it is an open source video streaming protocol developed by Haivision and Wowza. Many will see it as a replacement for RTMP in the near future. Because RTMP is less secure and has higher latency, it supports higher quality, stability, sub-second latency, and strong codec support compared to SRT. SRT is considered by many industry experts to be the new protocol for video streaming. What exactly is SRT?
What is SRT?
Secure and Reliable Transmission (SRT) is an open source data transfer protocol. SRT uses the User Datagram Protocol (UDP) and is designed to send high-quality video over the public Internet, making it the best choice for audio and video streaming.
SRT secure and reliable transfer protocol is used in Wireshare and FFMpeg.
What are the applications of SRT?
SRT protocol is mainly used in live broadcasting, multi-stream, video coding, gateway and other fields. Technically, it provides reliable transport similar to transmission Control Protocol (TCP). However, UDP is used as the underlying transport layer.
SRT also supports low latency (120 ms by default) for packet recovery and encryption using advanced Encryption Standard (AES).
In short, with SRT, end-to-end stream security, video elasticity, and real-time dynamic endpoint adjustment based on network conditions are possible.
High quality video transmission
SRT can be streamed more easily over Internet Protocol (IP) at low end latency. So far, there have been few protocol preferences for low-latency streaming.
This is because streaming over the public Internet can cause obstacles such as packet loss and jitter. SRT provides a solution to this problem.
In addition, the protocol includes protection against packet loss, jitter and bandwidth fluctuation. This means that if the network condition is unstable, your flow may stop. But it recovers from this loss almost immediately, and your audience will barely notice any problems while watching.
Other features that will benefit live streaming include:
1. Time-stamped packet transmission to achieve better delay control through source time transmission 2. Control the speed of sender 3
How does SRT better protect your video stream
If you use the SRT protocol to stream video, you will definitely benefit from its advantages. The protocol protects your video stream and ensures that all data is encrypted as it is sent. It also eliminates the burden of special Internet connections because the protocol guarantees the quality of the video content you deliver.
SRT is known for providing encryption that ensures secure transmission of even the highest level products. SRT can enable the end-to-end AES 128/256 bit encryption algorithm, which is ideal for anything that needs to be protected. SRT protects your video content from distribution by preventing video jitter and packet loss even during bandwidth fluctuations caused by unreliable WiFi or cellular connections.
SRT packets
Now we are going to do a further analysis of the SRT protocol.
According to the red box F in the figure above:
F=0 ; Data Packet
Data (content to transmit)
Filtering packet (FEC)
F=1; Control Packet
HANDSHAKE
KEEPALIVE
ACK
NAK (Loss Report)
SHUTDOWN
ACKACK
SRT Protocol handshake process
As the initiator of the connection, the caller knows the public IP address of the device that is configured in Listener mode and the UDP port that it listens to. The Listener listens to incoming SRT requests, needs to know which UDP port is used, and listens on this port all the time.
Caller-Listener Handshake
As the caller initiates a point-to-point SRT connection, the Listener listens for the request to initiate an SRT session.
Rendezvous Handshake
Rendezvous the two ends negotiate to establish a connection and do not use such a connection.
SRT has obvious advantages in fast connection. The connection can be established after two successful handshakes. After understanding the handshake process, SRT protocol parsing is followed.
SRT protocol parsing and packet identification
Next, we parse the SRT protocol.
* */ static void Dissect_SRT_control_packet (U_char *data_info,int PayloadLen) {int offset = 0; offset += 4; if (data_info[0] == 0x80 && data_info[1] == 0x02)/*UMSG_ACK*/ { int ack_number = ntohl(*(uint32_t*)(data_info + offset)); printf("ACK Number: %d\n",ack_number); offset += 4; /*Time Stamp*/ int time_stamp = ntohl(*(uint32_t*)(data_info + offset)); printf("Time Stamp: %d\n",time_stamp); offset += 4; /*Destination Socket ID*/ int dst_sock_id = ntohl(*(uint32_t*)(data_info + offset)); printf("Destination Socket ID: %d\n",dst_sock_id); offset += 4; /*ACKD_RCVLASTACK*/ int ack_rcv = ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_RCVLASTACK: %d \n",ack_rcv); offset += 4; /*ACKD_RTT*/ int ack_rtt = ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_RTT: %d us \n",ack_rtt); offset += 4; /*ACKD_RTTVAR*/ int ack_rttvar = ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_RTTVAR: %d us \n",ack_rttvar); offset += 4; /*ACKD_BUFFERLEFT*/ int ack_buffer= ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_BUFFERLEFT: %d pkts \n",ack_buffer); offset += 4; /*ACKD_RCVSPEED*/ int ack_rcvspeed= ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_RCVSPEED: %d pkts/s \n",ack_rcvspeed); offset += 4; /*ACKD_BANDWIDTH*/ int ack_banwidth= ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_BANDWIDTH: %d pkts/s \n",ack_banwidth); offset += 4; /*ACKD_RCVRATE*/ int ack_rcvate= ntohl(*(uint32_t*)(data_info + offset)); printf("ACKD_RCVRATE: %d pkts/s \n",ack_rcvate); } else if (data_info[0] == 0x80 && data_info[1] == 0x00)/*UMSG_HANDSHAKE*/ { char ipbuf[IP_BUFFER_SIZE]; const int final_length = PayloadLen; int baselen = 64; offset += 12; const int version = ntohl(*(uint32_t*)(data_info + offset)); /* Contains Handshake version (currently 4 or 5) */ printf("Handshake version:%d\n",version); offset += 2; /*Encryption Field*/ offset += 2; /*Extended Field*/ offset += 4; /*Initial Sequence Number*/ int srt_handshake_isn= ntohl(*(uint32_t*)(data_info + offset)); printf("Initial Sequence Number: %d\n",srt_handshake_isn); offset += 4; /*MTU*/ int srt_handshake_mtu= ntohl(*(uint32_t*)(data_info + offset)); printf("MTU: %d \n",srt_handshake_mtu); offset += 4; /*Flow Window*/ int srt_handshake_flow_window= ntohl(*(uint32_t*)(data_info + offset)); printf("Flow Window: %d\n",srt_handshake_flow_window); offset += 4; /*Hanshake Type*/ int srt_handshake_reqtype= ntohl(*(uint32_t*)(data_info + offset)); printf("Hanshake Type: %d\n",srt_handshake_reqtype); offset += 4; /*Socket ID*/ int srt_handshake_id= ntohl(*(uint32_t*)(data_info + offset)); printf("Socket ID: %d\n",srt_handshake_id); offset += 4; /*SYN Cookie*/ int srt_handshake_cookie= ntohl(*(uint32_t*)(data_info + offset)); printf("SYN Cookie: %d\n",srt_handshake_cookie); offset += 4; /*Peer IP Address*/ srt_format_ip_address(ipbuf, sizeof ipbuf,strdup((const char*)(data_info+offset))); printf("Peer IP Address: %s\n",ipbuf); If (final_length > baselen) {/* Extract the SRT handshake extension block and increment baselen accordingly. */ int begin = baselen; for (;;) { const uint16_t blockid = ntohs(*(uint16_t*)(data_info + begin)); begin += 2; const uint16_t blocklen = ntohs(*(uint16_t*)(data_info + begin)); // Shift to the payload begin += 2; switch (blockid) { case SRT_CMD_HSREQ: case SRT_CMD_HSRSP: if (blocklen == 3) { //uint32_t version = 0; const int vmajor = (data_info[begin+1]) & 0xff; const int vminor = (data_info[begin+2]) & 0xff; const int vpatch = data_info[begin+3] & 0xff; printf("SRT HS Extension type:%d \n",blockid); printf("SRT HS Extension size:%d \n",blocklen); printf("SRT Version(%d.%d.%d)\n", vmajor, vminor, vpatch); } else { } break; case SRT_CMD_KMREQ: case SRT_CMD_KMRSP: // Rely on the extracted blocklen //srt_format_kmx(tree, tvb, begin, blocklen*4); break; case SRT_CMD_SID: break; case SRT_CMD_CONJESTCTRL: break; default: printf( "Ext Type value is %u\n",blockid); break; } /* Move the index pointer past the block and repeat. */ begin += blocklen * 4; /* OK, once one block is done, interrupt the loop. */ if (begin >= final_length) break; } baselen = begin; } } else { } } static void dissect_srt(u_char *data_info,int PayloadLen) { /* Other misc. local variables. */ bool is_control = 0; /* There must be at least 24 captured bytes to check */ if (PayloadLen < 24) return; printf("SrtHdr 0x%.2X,0x%.2X,0x%.2X,0x%.2X\n",data_info[0],data_info[1],data_info[2],data_info[3]); if ((data_info[0] == 0x80 && data_info[1] == 0x00 && data_info[2] == 0x00 && data_info[3] == 0x00) || (data_info[0] == 0x80 && data_info[1] == 0x02 && data_info[2] == 0x00 && data_info[3] == 0x00)/*UMSG_ACK*/ || (data_info[0] == 0x80 && data_info[1] == 0x06 && data_info[2] == 0x00 && data_info[3] == 0x00)/*UMSG_ACKACK*/ ) { is_control = true; } if (is_control) { dissect_srt_control_packet(data_info,PayloadLen); } else { /*srt data type*/ } }Copy the code
Compile and run:
Here the SRT protocol is identified and the fields are parsed.
Compare the features of the RTMP and SRT protocols
RTMP is a real-time messaging protocol that maintains persistent, stable connections and allows low latency communication. Another disadvantage of the RTMP protocol is that it can be interrupted due to low bandwidth until your stream may not start at all. To add to the list of disadvantages, some tight firewalls may not allow RTMP connections due to low security of delivering video. Although, we have to say that this rarely happens.
The RTMP protocol currently uses H.264 video codecs and AAC audio codecs, which are rather antiquated and do not provide the best quality.
Finally, to summarize the advantages and disadvantages of RTMP:
Advantages: multicast support, low buffering, wide platform support.
Disadvantages: Older codecs, slightly less security, relatively high latency.
SRT is a secure and reliable transport protocol. SRT is an open source video streaming protocol developed by Haivision and Wowza. It is widely regarded as an alternative to RTMP in the near future. Sharing the same advantages, SRT is taking the next step to make the dream of stable live streaming with sub-second latency a reality. It allows you to broadcast your content via suboptimal webcast. However, one big drawback is that the playback option is not available.
SRT protects your live video from jitter, bandwidth fluctuations, and packet loss. In addition, SRT is similar to FTL and WebRTC in terms of sub-second latency, enabling near-real-time communication.
It also states that the protocol is codec-neutral, meaning that it supports any modern video and audio codecs.
Having said that, the advantages and disadvantages of SRT are:
Pros: High quality, stability, sub-second latency, powerful codec support.
Cons: Weak platform support, no playback.
conclusion
If you use the SRT protocol to stream video, you will definitely benefit from its advantages. The protocol protects your video stream and ensures that all data is encrypted as it is sent. It also eliminates the burden of special Internet connections because the protocol guarantees the quality of the video content you deliver.