RTP and RTCP protocols

Source: Internet
Author: User

1. Streaming Media)
1.1 concept of streaming media
Streaming Media Technology is the product of the development of network technology and multimedia technology to a certain stage. The term "streaming media" can refer to the stream technology that transmits continuous time-based media on the Internet, or the continuous time-based media itself that uses stream technology. Currently, there are two main methods for transmitting audio, video, and other multimedia information online: Download and stream transmission. The download method is used. You need to download the entire media file before playing the video. Due to network bandwidth restrictions, downloading often takes a long time, so this processing method is very delayed. The Key Technology for implementing streaming media is stream transmission. Before transmission, we first pre-process the multimedia (reduce the quality and efficient compression), and then use the cache system to ensure continuous and correct data transmission. Streaming Transmission means that users do not have to wait until the entire file is completely downloaded, but play and watch the video on the client after several seconds to dozens of seconds of startup latency. The remaining part of the media file will be downloaded in the background. Compared with the pure download mode, this stream transmission mode for simultaneous download and playback of multimedia files not only greatly shortens the startup latency, but also greatly reduces the demand for system cache capacity. Another advantage of stream transmission is the possibility of transmitting media data that is unknown or unknown in advance (such as online live broadcast and video conferencing.
Up to now, there are three main stream video formats used on the Internet: RealNetworks RealMedia, Apple QuickTime, and Microsoft Advanced Streaming Format (ASF ).

1.2 Support for streaming media protocols
A notable characteristic of multimedia applications is the large amount of data, and many applications require high real-time performance. The traditional TCP protocol is a connection-oriented Protocol. Its retransmission mechanism and congestion control mechanism are not applicable to real-time multimedia transmission. RTP is an application-oriented transport layer protocol that does not provide any guarantee of Transmission reliability and traffic congestion control mechanisms. RTP is located on top of UDP (User datainprotocol. Although UDP is not as reliable as TCP and cannot guarantee the service quality of real-time services, RTCP needs to monitor data transmission and service quality in real time. However, because UDP transmission latency is lower than TCP, it can work well with audio and video. Therefore, in practical applications, RTP/RTCP/UDP is used for Audio/Video Media, while TCP is used for data and control signaling transmission. Currently, live-time transport protocols and RTCP support streaming media transmission) and Real-Time Streaming Protocol. The three protocols are briefly introduced below. Streaming Media Protocol Stack 1.
Figure 1 Streaming Media Protocol Stack

2. Real-time transport protocol ):
RTP is a transmission protocol for multimedia data streams over the Internet. It is published by IETF (Internet Engineering Task Group) as rfc1889. RTP is defined to work during one-to-one or one-to-many transmission. It aims to provide time information and implement stream synchronization. Typical RTP applications are built on UDP, but can also work on TCP, ATM, and other protocols. RTP itself only guarantees the transmission of real-time data. It does not provide a reliable transmission mechanism for transmitting data packets in sequence, nor provides traffic control or congestion control. It relies on RTCP to provide these services.

2.1 RTP Mechanism
An acute problem that threatens multimedia data transmission is the unpredictable data arrival time. However, streaming media transmission requires timely arrival of data for playback and playback. The RTP protocol provides time tags, serial numbers, and other structures for controlling the exile of timely data. In the concept of stream, "Time tag" is the most important information. The sender sets the time tag in the data packet according to the real-time sampling. After receiving the data packet, the receiver restores the original and timely data according to the time tag at the correct rate. Different media formats have different attributes. However, RTP itself is not responsible for synchronization. RTP is only a Transport Layer Protocol. In order to simplify the transport layer processing and improve the efficiency of this layer. Move some transport layer protocol functions (such as traffic control) to the application layer. Synchronization is completed by the application layer protocol. It does not have the complete functions of the transport layer protocol, and does not provide any mechanism to ensure real-time data transmission. It does not support resource reservation or service quality. RTP packets do not even contain the length and packet boundary descriptions. At the same time, the RTP protocol datagram text and control packets use different adjacent ports, which greatly improves the Protocol flexibility and simplicity of processing.
The RTP protocol and UDP protocol work together to complete the transport layer protocol function. UDP only transmits data packets regardless of the time sequence of data packets. RTP protocol data units are carried by UDP groups. When carrying RTP data packets, sometimes a frame of data is divided into several packets with the same time tag, you can know that the time tag is not necessary. The multiplexing of UDP allows the RTP protocol to meet the needs of multimedia sessions by supporting explicit multi-point delivery.
Although the RTP protocol is a transport layer protocol, it is not implemented as a separate layer in the OSI architecture. RTP provides services based on a specific application. RTP only provides the Protocol framework. developers can fully expand the protocol according to the specific requirements of the application.

2.2 RTP packet structure
RTP Header Format 2:

The first 12 octal labels appear in each RTP packet, and the csrc id list only appears when the mixer is inserted. The meanings of each section are as follows:
Version 1 (v)
Two bits are used to identify the RTP version.

② Fill Mark (P)
1-bit. For example, if a fill position is set, the package end will contain additional fill characters, which is not a payload. The last octal counter to be filled contains the octal counter that should be ignored. Some encryption algorithms require fixed-size padding or several RTP packets carried in the underlying protocol data unit.

③ Extension (X)
1-bit. For example, if an extension bit is set, the fixed header is followed by a header extension.

④ CSRC count (cc)
4-digit, CSRC count includes the number of CSRC identifiers following the Fixed Header.

⑤ Mark (m)
One-bit mark interpretation is defined by the setting to allow important events to be marked out in the package stream. Other identifiers can be defined, or no flag is specified by changing the number of bits.

⑥ Load type (PT)
7 bits, record which codec will be used in the following information, and find the corresponding decoder to parse the code.

Common types:
Payload type Codec
0 PCM μ-Law
8 PCM-A Law
9g .. 722 audio codec
4G .. 723 Audio Codec
15g .. 728 Audio Codec
18g .. 729 Audio Codec
34G.. 763 Audio Codec
31G .. 761 Audio Codec

Series 7
A 16-bit serial number increases by 1 with each RTP packet, which is used by the receiver to detect packet loss. The initial values of serial numbers are random, making it more difficult to attack encrypted text.

Time Scale
32-bit. The time scale reflects the sampling time of the first octal number in RTP data packets. The sampling time must be exported from a monotonic and linearly increasing clock to allow synchronization and jitter calculation. The time scale allows the timer er to know how to play the data at the right time.

It can be seen that if there is only a series number, it cannot completely play the data in order, because if there is a section in the data that has no data, there will be errors if there is only a series number, you need to make it know at which time the data is correctly played, so that we can play the correct information.

⑨ SSRC
A 32-bit SSRC segment identifies the synchronization source. This identifier is not randomly selected, so that no two synchronization sources in the same RTP packet connection have the same SSRC identifier. Although the probability of selecting the same identifier for multiple sources is low, all RTP implementations must detect and resolve conflicts. If the source changes the source transmission address, you must also select a new ssrc id to avoid inserting it into the loop source.

⑩ CSRC list
0 to 15 items, 32 bits for each item. The CSRC list indicates the load source in the package. The number of IDS is given by the CC segment. If more than 15 sources are used, only 15 are identified. The CSRC identifier is inserted by the mixer and is identified by the SSRC identifier of the active source.

3. RTCP (Real-Time Transport Control Protocol)
RTCP is responsible for managing the communication quality exchange control information between the current application processes. During the RTP session, each participant periodically transmits the RTCP package, which contains statistics such as the number of sent packets and the number of lost packets. Therefore, the server can dynamically change the transmission rate or even the type of the payload. RTP and RTCP can be used together to optimize transmission efficiency with effective feedback and minimal overhead. Therefore, RTP is especially suitable for transmitting real-time online data.

3.1 RTCP Working Mechanism
When an application starts a RTP session, two ports are used: one for RTP and the other for RTCP. RTP itself does not provide a reliable transmission mechanism for transmitting data packets in sequence, nor does it provide traffic control or congestion control. It relies on RTCP to provide these services. Some RTCP packets are issued between RTP sessions in a periodic manner to transmit functions such as listening service quality and exchanging session user information. The RTCP package contains statistics such as the number of sent data packets and the number of lost data packets. Therefore, the server can dynamically change the transmission rate or even the type of the payload. RTP and RTCP can be used together to optimize transmission efficiency with effective feedback and minimal overhead. Therefore, RTP is particularly suitable for transmitting real-time online data. Based on the data transmission feedback between users, you can develop a traffic control policy, while the interaction of session user information can develop a session control policy.

3.2 RTCP Datagram
In the RTCP communication control, the functions of the RTCP protocol are implemented through different RTCP datagram, mainly including the following types:
① SR: sending end report. The so-called sending end refers to the application or terminal that sends the RTP datagram. The sending end can also be the receiving end.
② RR: the receiving end report. The so-called receiving end refers to an application or terminal that only receives but does not send RTP datagram.
③ Sdes: source description. The main function is to act as a carrier for the identity information of session members, such as the user name, email address, and phone number, it also provides the ability to send session control information to session members.
④ Bye: indicates that one or more sources are no longer valid, that is, other members in the notification session will quit the session.
⑤ App: defined by the application itself, solves the problem of RTCP scalability, and provides great flexibility for Protocol Implementers.

4. Resource Reservation Protocol (RSVP) (resorce Reservation Protocol)
Because audio and video data streams are more sensitive to network latency than traditional data streams, high-quality audio and video information must be transmitted over the network. In addition to bandwidth requirements, more conditions are required. RSVP is a Resource Reservation Protocol on the Internet. It uses RSVP to reserve some network resources (that is, bandwidth) and can provide QoS for streaming media transmission to a certain extent.

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.