RTP/RTCP protocol details

Source: Internet
Author: User
I. RTP protocol Overview

RTP provides end-to-end transmission services for interactive audio, video, and other real-time data. In
On an IP network, the RTP protocol is generally run on UDP. If the network that supports it can provide multicast
Yes, RTP can also send data to multiple target users through multicast.

RTP includes two closely related sub-protocols:

Real-time transmission protocol (RTP): Used to transmit real-time data.

Real-time Control Protocol (RTCP): Used to monitor the service quality of the network and transmit information in the attendee session.

 

The following are some definitions of RTP.
• RTP session: a connection between users of the RTP transmission service is called an RTP session. For each session participant, a session is composed of a pair of transport layer addresses (that is, a network layer address plus
Two Port addresses: one port is used for sending/receiving RTP packets, and the other port is RTCP
The identifier used to send/receive packets. In the IP multicast mode, the destination transport layer of each participant
The address pairs can be the same. In unicast mode, the address pairs of each participant are different because
The Network Layer addresses are not the same. In multimedia sessions, each media signal is transmitted by a different RTP session
And has its own RTCP group. Each RTP session is composed of different port pairs and/or different multicast addresses.
Yes.

• RTP media type: a set of all Net Load types transmitted by an RTP session. RTP Application
This document specifies the relationship between the RTP media type and the RTP net load type.

• RTP Net Load: data transmitted by RTP, such as audio Sampling Signals and compressed video data. Net Load
The format and its interpretation are defined by the application layer.

• RTP group: it consists of RTP Header and net load data. Usually a data of the lower-Layer Transfer Protocol
A packet (such as a UDP packet) contains only one RTP group. If you use a certain encapsulation method, you can also package
Contains multiple RTP groups.

• Synchronous source SSRC (Synchronization source): source stream of the RTP packet, which is used in the RTP Header
A 32-bit long synchronization source identifier, which is irrelevant to the network address. This field is used to identify signal synchronization.
Source, the value should be randomly selected to ensure that the SSRC IDs of any two synchronization sources in the RTP session are not consistent
.

• Source CSRC (Contributing source): the source ID, 32 bits. The RTP group header can contain up to 15 CSRC identifiers. The number of headers is specified by the CC field. If the score is
The number of source is greater than 15, and only five of them can be identified. The CSRC identifier is inserted by the mixer. Its value is
The SSRC identifier of each signal that forms a composite signal. It is used to identify the source of each signal.

• Mixer and Translator: This is between the RTP receiver and the sender
Two functional modules are introduced. The mixer receives RTP blocks from one or more senders and sends them
Are combined into a new RTP group to continue forwarding. This combination block will have a new ssrc id.
Because these blocks from different sources can be non-synchronous, the mixer changes the temporary structure of the data stream. In contrast to the mixer, the converter only changes the contents of the group blocks and does not combine the data streams. The mixer and translator ensure that users with different communication conditions can smoothly complete data exchange. An important application of the mixer is to change the compression encoding of data received from a high-bandwidth network between a high-bandwidth network and a low-bandwidth network, converts audio and video streams into low-bitrate data and sends it to a low-bandwidth network. The translator is used between networks of different protocols and between firewalls, because UDP is blocked through the firewall.

 

Ii. RTP (real-time transmission protocol)

 

Real Time Protocol (RTP) provides end-to-end data transmission servers with Real-Time features
Service, which can be used to transmit sound and motion image data. This data transfer service contains
Identifier, sequence count, timestamp, and transfer monitoring. Generally, RTP protocol elements are installed using UDP protocol elements.
And use UDP multiplexing and validation to achieve RTP multiplexing.

It must be noted that RTP does not provide any mechanism to ensure the timely delivery of data, nor any quality assurance mechanism. Therefore, to ensure the quality of service, it is necessary for lower-layer networks to provide assurance. Required
Note that RTP does not guarantee that data packets are transmitted by serial number, even though the lower-layer network can ensure reliable transmission
The data packet is transmitted by serial number. The serial number contained in RTP can be used by the receiver for deduplication.
The packet sequence can also be used for packet locating.

In RTP sessions, multiplexing is provided by the destination transfer address (network address and port number,
A transport address defines an RTP session. For example, in a meeting, the audio and video streams are transmitted using different RTP sessions (generally the same destination network address and different port numbers, instead of using PT (load type) or SSRC for distinguishing to achieve multiplexing transfer in a single RTP session.

Shows the structure of RTP packets with fixed headers:
The meanings of fields in the RTP Header are as follows:
Version (V): 2 bits, indicating the RTP version number.

Fill (P): 1 bit. If "1" is set, it indicates that the user data is filled with a last bit.
The last byte is the fill bit count, which indicates the total number of fill bits added. In either case
Needs to be filled. First, some encryption algorithms require a fixed block size; second, a low-layer protocol data packet
Load multiple RTP groups.

Extension (X): 1 bit. If "1" is set, the RTP Header is followed by an extension header.

CSRC count (CC): 4 bits, indicating the CSRC identifier after the fixed-length RTP Header
Quantity.

Mark (M): 1 bit, which is defined in the application documentation. For example, for video streams,
It indicates the end of a frame, and for audio, it indicates the start of a conversation.

Load type (PT): Seven bits that indicate the load type that carries data in the user data field.

SN: 2 bytes. Each RTP packet sent increases by 1. This serial number is connected
The recipient can detect lost data packets and sort the incoming data packets.

Time stamp (TS): 4 bytes, which indicates the first byte of the user data segment in the RTP Packet
Sample Time. The Time Representation of the timestamp should be linearly monotonically incrementing to Achieve Synchronous implementation and jitter
Computing.

Synchronization source identifier (SSRC): 4 bytes, used to identify a synchronization source. This identifier is random
But to ensure that any two SSRC in the same RTP session are different, RTP must detect
And resolve the conflict.

Provide the source identifier (CSRC): it can have 0 ~ 15 identifiers, each of which is 32 bits in length.
The number of items is determined by the CC field. If more than 15 sources are provided, only 15 are identified.

To meet the needs of various applications, the RTP Header can be further expanded. At that time, X bit will be set to "1 ",
The expanded RTP Header is closely following the SCRC list.

If the extension bit is set to 1, it means that the RTP Fixed Header is followed by a header extension.
3-2. The content of the first 16 bits is determined by the profile and is mainly used to identify different header extension types. This
Extension methods are mainly used to transmit loads independent of specific formats (payload-format-independent)
Application information.

 

Iii. RTCP (real-time transmission control protocol) 3.1 RTCP Functions

RTCP is the control protocol of RTP, which is used to monitor the service quality of the network and the ongoing participation

Information is transmitted in a session. The basic practice of RTCP is to periodically communicate with all participants in the session,
The same mechanism as packet distribution and transmission is used to send control packets. RTP has four functions:
(1) the basic function of RTCP isProvide feedback on data transmission qualityThis is an important part of the RTP protocol. It corresponds to the traffic control and congestion control of other transmission protocols.
RTP sends feedback packets to all participants in the session to allow those who discover the data during transmission
If the problem occurs, the user further judges whether the problem is related only to himself or herself or all the participants, and takes corresponding measures. In addition, with the support of the IP multicast mechanism, this function of RTCP allows the monitor not to participate in a specific functional entity of a RTP session, but to infer the network service by receiving feedback packets.
Quality, playing the role of a third-party monitor. This function is implemented by the RTCP Sender report (SR) and receiver report (RR.

(2) For each RTP source, RTCP isAssign a permanent transport layer IDIs called CNAME. Although SSRC identifiers can distinguish different streams in a session, when RTP discovers
If the SSRC identifier of different code streams conflicts or the application restarts, the SSRC value is changed.
The receiver needs to use CNAME instead of SSRC to track each session participant. In addition, with CNAME, the receiver can associate the streams sent from the same user and through different RTP sessions to complete
Such as the synchronization of audio streams and video streams. CNAME is a SDES packet sent by RTCP (Source
Description source description.

(3) because the above two functions require all session participants to send RTCP packets, in order to be able to accept more users in one RTP session, RTCP provides additional information on adjusting the transmission speed of control packets.
Rate method. One RTP user can receive RTCP packets from other users independently
Measure the test taker's knowledge about the number of session participants. RTCP uses this parameter to calculate control packets for each session participant.
So that the communication bandwidth occupied by RTCP does not exceed 5% of the session bandwidth.

(4) RTCP provides basic session control functions, such as exchanging identities among different session participants.
(Identification) information. This function is optional and is mainly used to control loose sessions,
Such sessions do not strictly manage user joining and leaving. It can be seen that although RTCP is
Access to each session participant provides convenient means, but it does not meet all the communication requirements of the application.
Therefore, RTP allows applications to use other high-level control protocols based on RTCP
Meet specific application requirements.

(1 )~ (3) item functions are essential functions of RTCP, and item 4 is optional.
RTCP messages are of the following types:
SR (sender report): The sender report.
RR (receiver report): receiver report.

SDES (source description items): source description terms, including CNAME.
BYE: indicates the attendee to exit.
APP: a specific function of an application.
Each RTCP package starts with a structure similar to the fixed part of the RTP datagram, followed

The construction unit is similar to the RTCP package type, and its length varies with the type, but it is a 32-bit integer.
Several times.

3.2 SR and RR

The RTP message receiver can use two types of RTCP report packets (SR or RR) to provide statistics on the quality of data reception. The specific choice of SR message or RR message depends on whether the receiver is
Whether it is the sender of An RTP message at the same time. Specifically, if a session participant
After the RTCP packet is sent, a new RTP data packet is sent, so the participant needs to send the SR packet,
Otherwise, the RR packet is sent. The main difference between SR messages and RR messages is that the former contains 20 bytes.
The sender information.

The SR packet consists of three parts: The first part is the RTCP packet header, which is 8 bytes in length; the second part
Is the sender information, the length is 20 bytes; the third part is the receiving report block, the receiving report block carries
Statistics on the receipt of continuous code streams. The SSRC value indicates the specific
In a RTP session, participants may receive multiple streams of the same media type,
Therefore, a single SR or RR message may contain multiple receiving report blocks.

The field meanings in the SR message are as follows.
Version (V), fill (P) and the V and P fields in the RTP Header have the same meaning.
RC: Five bits, indicating the number of receiving report blocks contained in the package.

Load type (PT): 8 bits, whose value reflects the type of the message (for example, for SR, PT is
200; for RR, PT is 201, etc ).

Length: 16 bits, indicating the length of the RTCP package, including header and padding bytes.

SSRC: 32 bits. The value indicates the receiver of the control packet, and
It reflects the specific code stream of the statistical data in the sender information block carried by the message.

NTP timestamp: 64 bits, which records the time when the SR message is sent. This value can be used for estimation.
Test the average sending rate of RTP packets or continuous data. The timestamp is the absolute timestamp, the first 32 of the 64-bit
The bit is an integer from January 1, January 1, 1900 to the current in seconds, and the last 32 digits are
The decimal part of the time.

RTP timestamp: 32 bits, which is the same as NTP timestamp, but its unit and original
Point is the same as the time stamp of RTP data packets. This value can be used for synchronization control between the bitstream or the bitstream.
Selected.

Message sending count: 32 bits. It records the RTP datagram sent when the SR message is sent.
Total number of objects.

Sending Byte Count: 32 bits, which records the continuous data sent when the SR message is sent
The total number of bytes.

SSRC-n: synchronization source identifier. The information in SR is about these synchronization sources.

Fraction lost: 8 bits, which indicates that the previous SR or RR packet is sent.
The number of RTP packets lost in the data receiving process is the same as the percentage of the total number of RTP packets received.

Cumulative number of packet lost: 24 bits, recorded to this
Total number of RTP data packets lost during the receiving of RTCP packets.

Extended maximum number (extended highest sequence number): 32 bits, because

The number of requests in RTP packets is only 16 bits. Therefore, after a period of time
The parameter is set to 0. RTP indicates that this period of time is a sequence number cycle ),
Correspondingly, the extended maximum number consists of two parts, the low 16-bit record is sent to the RTCP
The maximum number of RTP packets received. The 16-bit high contains the number cycle
The two jointly reflect the total number of RTP data packets to be received.

Inter-packet jitter (IJ: interarrival jitter): 32 bits, including the data transmission process
An estimation of the latency jitter experienced by medium RTP packets is determined by the following two formulas. S indicates RTP.
The timestamp value. R indicates the arrival time of the RTP message. The IJ value roughly reflects the RTCP message sending time.
Network congestion.

D (I-1, I) = (Ri-Si)-(Ri-1-Si-1)

J = IJ + (| d (I-1, I) |-IJ)/16
Last SR (LSR: last SR timestamp): 32 bits, whose value is in the NTP timestamp

32-bit, indicating the time when the SR message was recently received.
Since the delay (DLSR) of the previous SR: 32 bits, the value is the last received SR packet sent

The delay of sending the RTCP packet.
Therefore, the receiver of the RTCP packet can use the LSR domain and the DLSR domain to estimate

The round-trip propagation latency. Specifically, if A represents the arrival time of the RTCP message, it is continuous.
The round-trip propagation delay between the receiving and sending ends of the data stream is A-LSR-DLSR.

The RR Message format is 3-4, which is roughly the same as the SR, but does not contain the sender information block,
Therefore, we will not go into details.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.