# Secure Reliable Transport

Secure Reliable Transport (SRT) is an open source video transport protocol that utilises the UDP transport protocol. The SRT Protocol specification is available as an Internet Draft from the IETF.

## Overview

SRT provides connection and control, reliable transmission similar to TCP; however, it does so at the application layer, using UDP protocol as an underlying transport layer. It supports packet recovery while maintaining low latency (default: 120 ms). SRT also supports encryption using AES.
The protocol was derived from the UDT project, which was designed for fast file transmission. It provided the reliability mechanism by utilizing similar methods for connection, sequence numbers, acknowledgements and re-transmission of lost packets. It utilizes selective and immediate (NAK-based) re-transmission.
SRT added several features on top of that in order to support live streaming mode:
* Controlled latency, with source time transmission (timestamp-based packet delivery)
* Relaxed sender speed control
* Conditional "too late" packet dropping (prevents head-of-line blocking caused by a lost packet that wasn't recovered on time)
* Eager packet re-transmission (periodic NAK-report)

## Packet header

SRT packets are created at the application layer and handed to the transport layer for delivery. Each unit of SRT media or control data created by an application begins with the SRT packet header.
SRT packet header :
| Offsets | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | F | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type |
| 4 | 32 | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type | Field meaning depends on the packet type |
| 8 | 64 | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp |
| 12 | 96 | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID |
| ... | ... | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) | Packet Contents (depends on the packet type) |

### Data packet

SRT data packet header :
| Offsets | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | 0 | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number | Packet Sequence Number |
| 4 | 32 | PP | PP | O | KK | KK | R | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number | Message Number |
| 8 | 64 | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp |
| 12 | 96 | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID |
| ... | ... | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data | Data |
The fields in the header are as follows:
* Packet Sequence Number (31 bits)
* PP (2 bits): Packet Position Flag
* O (1 bit): Order Flag
* KK (2 bits): Key-based Encryption Flag
* R (1 bit): Retransmitted Packet Flag
* Message Number (26 bits)
* Data (variable length)

### Control packet

SRT control packet header :
| Offsets | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | 1 | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Control Type | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype | Subtype |
| 4 | 32 | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information | Type-specific Information |
| 8 | 64 | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp | Timestamp |
| 12 | 96 | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID | Destination Socket ID |
| ... | ... | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) | Control Information Field (CIF) |
The fields in the header are as follows:
* Control Type (15 bits): Control Packet Type
* Subtype (16 bits)
* Type-specific Information (32 bits)
* Control Information Field (variable length)

## History

Secure Reliable Transport is an open source video transport protocol developed originally by Haivision. According to SRT Alliance, an organisation that promotes the technology, it optimises streaming performance. This helps minimise effects of jitter and bandwidth changes, while error-correction mechanisms help minimise packet loss. SRT supports end-to-end encryption with AES. When performing retransmissions, SRT only attempts to retransmit packets for a limited amount of time based on the latency as configured by the application.
According to Marc Cymontkowski, the architect of SRT, in addition to sending MPEG transport streams over the public internet, it is also being used for IoT connectivity, metadata exchange, as a communication protocol, as well as for uncompressed data delivery.
The reference implementation of the protocol was originally published under the Lesser General Public License version 2.1, but was relicensed under the Mozilla Public License on 22 March 2018.
SRT is supported in the free software multimedia frameworks GStreamer, FFmpeg, OBS Studio and in VLC free software media player.
The UDP-based Data Transfer Protocol (UDT) project has been a base for the SRT project. The SRT C API is largely based in design on the UDT API
SRT was designed for low-latency live video transmission.
Haivision released the SRT protocol and reference implementation as open source at the 2017 NAB Show.
In March 2020, an individual Internet-Draft, draft-sharabayko-mops-srt, was submitted for consideration to the Media OPerationS (MOPS) working group of the Internet Engineering Task Force.

## SRT Alliance

SRT Alliance is an organisation whose members develop, use and promote the Secure Reliable Transport protocol and software based on it. The founding members of the alliance are Haivision and Wowza Streaming Engine.

## Implementations

There are two available implementations, the open-source SRT library from Haivision written in C and GoSRT, a version written in pure Go

### Haivision C Library

The C language API is mainly based on the previous UDT API, with further changes as new features are added. The API is very similar to the one of TCP.
SRT offers actually three working modes, of which the first two were derived from UDT:
* File-stream mode: like TCP
* File-message mode: similar to SCTP protocol – sending blocks of data with clearly defined boundaries
* Live mode: the data should be sent in small packets (usually up to 1316 bytes, if the transmitted stream is MPEG-TS) with already appropriate time intervals between them. The same single packets with the same time intervals between them are then delivered at the receiver side.
The SRT library also offers these features:
* Encryption using a pre-shared key. Encryption support was originally provided by OpenSSL, now also alternatively, Nettle (GNU TLS) or mbedTLS can be used.
* SRT Access Control (aka "StreamID") can be used by applications to identify resources and use user-password access method while using the same service port number for multiple purposes.
* The optional Forward Error Correction mechanism.
Further and more detailed documentation can be found in the Source code documentation.