RTP Introduction
RTP is a real-time transmission protocol that provides end-to-end transmission services. It is used to transmit real-time data in single-target broadcast and multi-target broadcast network services, real-time data transmission is monitored and controlled by the RTCP protocol.
RTP is defined in RFC
Applications using RTP protocolProgramRun on RTP, and the program running RTP runs on the UDP upper layer to use the UDP port number and check and. As shown in 1, RTP can be seen as the child layer of the transport layer. Audio and TV data blocks generated by multimedia applications are encapsulated in the RTP information package. Each RTP information is encapsulated in the UDP message segment and then encapsulated in the IP data packet.
The information package structure contains multiple domains that are widely used in multimedia, including audio-on-demand, video on demand, and Internet telephony) and videoconferencing ). The RTP specification does not set standards for the compression formats of sound and television. It can be used to transmit files in common formats. For example, a WAV or GSM (Global System for Mobile Communications) audio, MPEG-1, and MPEG-2 television can also be used to transmit sound and television files stored in proprietary formats.
From the perspective of application developers, RTP execution programs can be considered as part of applications, because developers must integrate RTP into applications. On the sender end, developers must write the program that executes the RTP protocol to the application that creates the RTP information package, the application then sends the RTP information package to the socket interface (socket interface) of UDP, as shown in 2. At the receiving end, the RTP information package is input to the application through the UDP interface, therefore, developers must write the program that executes the RTP protocol to the application that extracts media data from the RTP information package.
The working process of RTP transmission sound is illustrated as an example. Assume that the audio source is a PCM encoded sound of 64 KB/s, and the application uses 20 milliseconds of encoding data as a chunk ), that is, there are 160 bytes of sound data in a data block. The application needs to add the RTP title for the sound data to generate the RTP information package, which includes the type, sequence number, and timestamp of the sound data. Then, the RTP information package is sent to the UDP interface, where it is encapsulated in the UDP information package. At the receiving end, the application receives the RTP information package from the interface and extracts the sound data block from the RTP information package, then, use the information in the title field of the RTP information package to correctly decode and play the sound.
If the application uses the standard RTP protocol instead of a proprietary scheme to provide payload type, sequence number, or timestamp, applications are easier to run with other network applications. For example, if two different companies are developing Internet phone software and they all integrate RTP into their products, there is hope: users who use telephone software from different companies can communicate with each other.
It should be emphasized that RTP itself does not provide any mechanism to ensure that data is delivered to the receiving end in a timely manner or other service quality is ensured, it does not guarantee that the information package will not be lost during delivery or that the order of the information package will not be disrupted. Indeed, the RTP encapsulation can only be seen on the system end. The middle Router does not distinguish that the IP datagram carries the RTP information package.
RTP allows each media source to be allocated a separate RTP information packet stream, such as a camera or microphone. For example, if two groups participate in a video conference, four information packet streams may be opened: two cameras transmit television streams and two microphones transmit sound streams. However, many popular coding techniques, including MPEG-1 and MPEG-2, bundle sound and TV images together in the coding process to form a single data stream, One Direction generates a RTP information packet stream.
RTP information packages are not restricted and can only be used for single-target broadcast. They can also be used in one-to-many (one-to-many) multi-target broadcast tree or multi-to-many multi-target broadcast tree. For example, many-to-many multi-target broadcast, in this application, all senders usually send their RTP information packet streams to the multi-target broadcast tree with the same multi-target broadcast address.
RTP information package title Field
The RTP Title consists of four information packet header domains and other domains: payload type domain, sequence number domain, timestamp) and synchronization source identifier. The structure of the title field of the RTP information package is shown in:
1. Payload type
The length of the payload type field in the RTP information package is 7 bits. Therefore, RTP supports 128 different payload types. For sound streams, this field is used to indicate the encoding type used by the sound, such as PCM, adaptive incremental modulation, or linear prediction encoding. If the sender decides to change the encoding method in the middle of a session or broadcast, the sender can use this domain to notify the receiver. Table 1 lists the types of sound loads currently supported by RTP.
Table 1 currently supported audio payload types in RTP
For TV streams, the payload type can be used to indicate the type of TV encoding, such as motion JPEG, MPEG-1, MPEG-2 or h.231. The sender can also change the TV encoding method at any time during a session or period. Table 16-02 lists some TV payload types currently supported by RTP.
Table 2 types of sound payload currently supported by RTP
2. Sequence Number
The length of the sequence number field is 16 bits. Each time an RTP information packet is sent, the sequence number is incremented by 1. the receiving end can use it to check whether the information packet is lost and process the information packet by sequence number. For example, the application at the receiving end receives an RTP information packet stream. The RTP information packet has an interval between the serial number 86 and 89, and the receiving end will know that the information packets 87 and 88 have been lost, and take measures to process lost data.
3. Timestamp
The length of the timestamp field is 32 bytes. It reflects the sampling time (time) of the first byte in the RTP data packet ). The receiver can use this timestamp to remove the jitter of information packets caused by the network, and provide the synchronization function for playback at the receiver.
4. Synchronization source identifier
The length of the synchronization source identifier (SSRC) domain is 32 characters. It is used to identify the origin of the RTP information packet stream. Each information packet stream during the RTP session or period has a clear SSRC. SSRC is not the IP address of the sender, but a random number assigned by the source end at the beginning of the new Information Package stream.
From "http://baike.eccn.com/eewiki/index.php/%E5% AE %9E%E6%97%B6%E4%BC%A0%E8%BE%93%E5%8D%8F%E8% AE % AE %28RTP%29"