The difference between rtmp/rtp/rtsp/rtcp

Source: Internet
Author: User
Tags mongodb postgresql redis rfc port number

Introduction

In a simple sentence summary: RTSP initiate/End streaming media (application layer), RTP transport Stream Media data (transport layer), RTCP to RTP control, synchronization (transport layer).


The reason for this is a little confusing, because the CTC standard does not require RTCP, so in the standard RTSP code does not see the relevant parts. In the private RTSP code, the control, synchronization, etc., is in the RTP header to do the extension definition implementation.


In addition, RFC3550 can be regarded as the RFC1889 upgrade document, only see RFC3550.


RTP

The real-time transport protocol (real-time Transport Protocol) is a Transport layer protocol for multimedia traffic on the Internet . The RTP protocol details the standard packet format for transmitting audio and video over the Internet. RTP protocols are commonly used in streaming media systems (with the RTCP protocol), video conferencing and a Push-to-talk system (with either a/p or SIP), making it the technical foundation of the IP telephony industry. The RTP protocol and the RTP Control Protocol (RTCP) are used together, and it is built on the UDP protocol. 


RTP itself does not provide on-time delivery mechanisms or other quality of service (QoS) guarantees, and it relies on low-level services to implement this process. RTP does not guarantee the transmission or prevention of out-of-order transmission (this means that RTP packets may be unordered on the way ), and the reliability of the underlying network is uncertain. the serial number in RTP allows the receiver to reorganize the sender's packet sequence , and the serial number can also be used to determine the appropriate packet location, for example: In video decoding, no sequential decoding is required.


RTP consists of two tightly linked parts: The rtp--transmits data with real-time properties, and the RTP Control Protocol (RTCP) ―--monitors the quality of the service and transmits information about ongoing session participants.


RTCP 

real-time Transport Control Protocol (Real-time Transport control Protocol or RTP control protocol or shorthand RTCP) is a sister protocol for real-time Transport Protocol (RTP). The RTCP provides out-of-channel (Out-of-band) control for RTP media streams. The RTCP itself does not transmit data , but it collaborates with RTP to package and send multimedia data. RTCP periodically transfers control data between participants in a streaming multimedia session. RTCP's main function is to provide feedback on the quality of service provided by RTP (Quality of services), and to synchronize audio and video.


RTCP collects statistics on related media connections, such as: number of bytes transferred, number of packets transmitted, number of packets lost, jitter, unidirectional and bidirectional network latency, and so on. Network applications can use the information provided by RTCP to try to improve the quality of services, such as restricting information traffic or using smaller codecs instead of compression. The RTCP itself does not provide data encryption or identity authentication. SRTCP can be used for such purposes.


SRTP & srtcp 

Secure Real-time transport protocol (secure real-time Transport protocol or SRTP) is in real-time transport protocol (real-time Transport protocol or RTP) is a protocol defined to provide encryption, message authentication, integrity assurance, and replay protection for data in a live transport protocol in unicast and multicast applications. It was developed by David Oran (Cisco) and Rolf Blom (Ericsson) and was first released by the IETF in March 2004 as RFC 3711.


Because the real-time transport protocol and the real-time Transport Control Protocol (RTP Control Protocol or RTCP) are closely linked, the secure real-time transport protocol also has a companion protocol, which is known as secure real-time Transport Control Protocol (secure RTCP or SRTCP) The secure real-time transport Control Protocol provides similar security-related features for real-time transport control protocols, just as the secure real-time transport protocol provides for real-time transport protocols.


Enabling the use of secure real-time transport protocol SRTP or secure real-time transport Control Protocol srtcp is optional, but even with secure real-time transport protocol SRTP or secure real-time transport Control Protocol srtcp, all of the features they provide (such as encryption and authentication) are optional, These features can be used independently or disabled. The only exception is that when using secure real-time transport Control Protocol SRTCP, its message authentication feature must be used.


RTSP

Live Streaming Protocol RTSP (real Time streaming Protocol) is a multimedia streaming protocol used to control sound or imagery, and allows simultaneous multiple streaming requirements control , and the network communication protocols used in the transmission are not within the scope of their definition, The server side can choose to use TCP or UDP to transmit the stream content , its syntax and operation is similar to HTTP 1.1, but does not particularly emphasize time synchronization, so the comparison can tolerate network latency. In addition, the previously mentioned allow for simultaneous multiple stream demand control (multicast), besides reducing the server-side network usage, it can support multi-video conferencing (video Conference). Because it works in the same way as the HTTP1.1, the caching of proxy server "cache" also applies to RTSP, and because RTSP has a re-directed function, the actual load situation can be converted to serve the server, To avoid excessive load concentration on the same server and cause delays.


RTSP's request mainly has describe,setup,play,pause,teardown,options and so on, as the name implies can know the dialogue and control role.


During the RTSP conversation, Setup can determine the port used by the RTP/RTCP, Play/pause/teardown can start or stop the RTP send, etc.

First, RTP data protocol

RTP Data Protocol is responsible for the streaming media data packets and the real-time transmission of media streams, each RTP datagram by the head (header) and load (Payload) two parts, wherein the first 12 bytes of the head meaning is fixed, the load can be audio or video data . The header format of the RTP datagram is shown in Figure 1:



Some of the more important fields and their meanings are as follows:

  CSRC flag count (CC): Indicates the number of source flag (CSRC) identities provided. The csrc identifier , immediately following the RTP fixed head, is used to represent the source of the RTP datagram, which allows multiple data sources to be present in the same session, which can be combined into a single data source through the RTP mixer . For example, you can produce a CSRC list that represents a conference call that combines the voice data of all speakers into one RTP data source through an RTP mixer.


load Type (PT, payload type): Indicates the format of the RTP payload, including the encoding algorithm used, sampling frequency, bearer channel, etc. For example, type 2 indicates that the RTP packet carries voice data encoded with the ITU g.721 algorithm, with a sampling frequency of 8000Hz and mono.


serial number : used to provide the receiver with the method of detecting data loss, but how to handle the lost data is the application's own business, the RTP protocol itself is not responsible for data retransmission.


Time stamp: The sampling time of the first byte in the payload is recorded, and the receiver is able to determine whether the arrival of the data is affected by the delay jitter, but how to compensate for the delay jitter is the application's own business.


From the RTP datagram format is not difficult to see, it contains the type of transmission media, format, serial number, time stamp and whether there is additional data and other information, which provides a corresponding basis for real-time streaming media transmission. The purpose of the RTP protocol is to provide end-to-end transport services for real-time data, such as interactive audio and video, so there is no concept of connectivity in RTP, which can be built on the underlying connection-oriented or non-connected transport protocol, and RTP does not depend on a particular network address format. It is sufficient to only need the underlying transport protocol to support framing (Framing) and Fragmentation (segmentation), and RTP itself does not provide any reliability mechanisms, which are guaranteed by the transport protocol or the application itself . In typical applications, RTP is typically implemented on top of the transport protocol as part of the application.


Second, RTCP Control protocol 

The RTCP control protocol needs to be used in conjunction with the RTP data protocol, and when an application initiates an RTP session, it consumes two ports, respectively, for RTP and RTCP . RTP by itself does not provide a reliable guarantee for sequential transmission of packets, nor does it provide traffic control and congestion control, which is done by RTCP. Typically, the RTCP uses the same distribution mechanism as RTP to periodically send control information to all members of the session, and the application receives the data, obtains information about the session participants, and the network condition, packet loss probability, etc. The result is the ability to control the quality of the service or diagnose the condition of the network.


The functions of the RTCP protocol are implemented by different RTCP datagrams, mainly in the following categories:


SR: send-side report, the so-called sender is the application or terminal to emit RTP datagram, the sender can also be the receiving side.
RR: The receiving side reports that the so-called receiver is the application or terminal that receives but does not send RTP datagrams.
sdes: source Description, the main function is as a member of the session on identity information carrier, such as user name, e-mail address, telephone number, and also has the ability to communicate session control information to the session members.
BYE: notification departure, the primary function is to indicate that one or several sources are no longer valid, that is, the other members in the notification session will exit the session themselves.
app: defined by the application itself, it solves the extensibility problem of RTCP and provides a great deal of flexibility for the implementation of the Protocol.


The RTCP datagram carries the necessary information of service quality monitoring, can dynamically adjust the service quality, and can control the network congestion effectively. Because the RTCP datagram is multicast, all members of the session can use the control information returned by the RTCP datagram to understand the current situation of the other participants.


In a typical application, the application that sends the media stream will periodically generate the send-side report SR, which contains synchronization information between different media streams, as well as the number of datagrams and bytes that have been sent, and the receiving end can estimate the actual data transfer rate based on this information. On the other hand, the receiving end sends a receive-side report RR to all known senders, which contains important information such as the maximum serial number of the received datagram, the number of lost datagrams, the delay jitter, and the timestamp, which can be used by the sending application to estimate the round-trip delay. The transmission rate can be dynamically adjusted according to the probability of datagram loss and delay jitter to improve the network congestion, or to smoothly adjust the service quality of the application according to the network condition.


Third, RTSP real-time Streaming protocol 

As an application layer protocol, RTSP provides an extensible framework, its significance is to make real-time streaming media data controlled and on-demand becomes possible . 


In general, RTSP is a streaming media representation protocol that is primarily used to control data transmission with real-time characteristics, but it does not transmit data by itself, but must rely on some of the services provided by the underlying transport protocol. RTSP can provide streaming media such as play, pause, fast forward and other operations, it is responsible for defining the specific control message, operation method, status code, etc., also describes the interaction with RTP (RFC2326).


RTSP has more references to the http/1.1 protocol when it is enacted, and even many of the descriptions are identical to http/1.1. The reason why RTSP intentionally uses syntax and operations similar to http/1.1 is to a large extent compatible with the existing web infrastructure, and for this reason,most of the http/1.1 extension mechanisms can be introduced directly into RTSP. 


The set of media streams controlled by RTSP can be defined by the representation description (Presentation Description), which refers to the collection of one or more media streams that the streaming media server provides to the client, while the description contains information about the various media streams in the presentation. such as data encoding/decoding algorithm, network address, media streaming content.
Although the RTSP server also uses identifiers to differentiate between each first-class connection session (session), the RTSP connection is not bound to a transport layer connection (such as TCP, etc.), which means that during the entire RTSP connection, RTSP users can open or close multiple reliable transport connections to the RTSP server to make an RTSP request. In addition, RTSP connections can be based on a non-connection-oriented transport protocol such as UDP.


The RTSP protocol currently supports the following operations:
Retrieving media: allows a user to submit a presentation description to the media server via HTTP or another method. If the representation is multicast, the description contains the multicast address and port number used for the media stream, and if it is unicast, the destination address should only be provided for security in the presentation description.
invitation to join: The media server can be invited to participate in an ongoing meeting, or play back the media in the presentation, or record all media or a subset of it in the presentation, ideal for distributed teaching.


Add Media: notifies users of new and available media streams, which is especially useful for live lectures. Like http/1.1, RTSP requests can also be handled by proxies, channels, or caches. 


RTMP VS tcp&udp

1, TCP is a point-to-Point protocol, which means that each client needs to separate client/server connections and therefore cannot implement data broadcasts to multiple clients at the network level . If a traffic must be transmitted to multiple clients at the same time, the server must transmit a copy of the data stream to each client, TCP can dynamically adjust the transmission speed according to the network bandwidth and congestion level and resend the lost packets, so that the reliability of data transmission, but the server resources are expensive, It is difficult to guarantee the real-time data stream transmission in the case of large data stream.


2, UDP is an unreliable transport protocol, on the sending side, UDP transmits data at a speed only by the speed of application-generated data, the ability of the computer and the transmission bandwidth limit; at the receiving end, UDP places each message segment in the queue and the application reads a message segment from the queue each time.


The UDP protocol does not need to maintain the connection state, and does not think that each packet must reach the receiving end, so the network load is smaller than TCP, the transmission speed is faster than TCP, but the more congested the network, the more packets are lost.


3, rtmp protocol (realtime Messaging Protocol, live Messaging protocol) is a protocol designed specifically for the efficient transmission of video, audio and data . It enables real-time video and sound transmission by establishing a binary TCP connection or connecting to an HTTP tunnel.


Shared objects are an important data type in rtmp data, and when any client changes the data, the shared object is able to update the server-side data in a timely manner, so that each client can be aware of the changes in the data.


RTMP supports more media protocols than traditional media servers. It supports the dynamic transmission of multiple lines that may contain sound, image and script data from the server to the customer and from the customer to the server. RTMP handles sound, image, and script data separately.


Sound and video data are buffered separately from the server. If the sound data reaches a certain limit in the sound buffer, all data in the buffer is discarded and the recently arrived data is allowed to start collecting in the buffer and being sent to each customer. The video data is processed in a similar manner, unlike when a new keyframe arrives and the data in the buffer is cleared. When the old frame data is discarded, if the client's data is found to be incorrect, the old and new two different frames are fitted.


rtmp gives different priority levels to the data. In real-time conversations, the sound is the most important, the image is given a low priority, and the script data is given priority over the middle of the sound and the image.


The RTMP protocol can create multiple data streams, but each data flow can have only one direction.


With rtmp, you can build a system that allows clients to interact with the RTMP server and the application server at the same time, allowing the server's load to be dispersed, although the performance requirements for rtmp servers are high in this improved system architecture.


rtmp:real Time Messaging Protocol (live messaging protocol)
RTMP (the Real-time Messaging Protocol) protocol acts as a client and server-side transport protocol, a TCP/IP protocol specifically designed for efficient transmission of video, audio, and data, and data transmitted using the RTMP protocol is unencrypted, Includes authentication information such as user name and password. 


Category: Adobe


rtp:real-time Transport Protocol (real-time Transfer Protocol)
Real-time Transport Protocol (RTP) provides end-to-end delivery services with real-time features for data, such as interactive video audio or analog data under multicast or unicast network services. Applications typically run RTP on UDP to use their multi-node and checksum services, both of which provide the functionality of the Transport Layer protocol. However, RTP can be used in conjunction with other appropriate underlying networks or transport protocols.
Category: IETF
Source: RFC 3550


http://blog.csdn.net/frankiewang008/article/details/7665547

Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

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.