what's the RTP protocol

what's the RTP

  RTP full name is Real-time Transport Protocol (Real-time Transport Protocol). It is a proposed IETF standard, RFC documents corresponding to RFC3550 (RFC1889 their outdated version). RFC3550 defines not only the RTP, and defines the related ancillary agreements RTCP (Real-time Transport Control Protocol, namely Real-time Transport Control Protocol).

  RTP is used for a variety of needs real-time transmission of multimedia data over IP networks of voice, video, fax and other services to provide end to end real-time transmission. RTP provides end to end real-time transmission on the Internet and stream synchronization time information, but does not guarantee the quality of service, the quality of service provided by RTCP.

 

RTP application environment

  RTP for transmitting real-time data in a unicast or multicast network. They typically has the following applications.

  1. Simple multicast audio conference. Voice communication is achieved through a multicast address and a pair of ports. An audio data (RTP), the other for control packet (RTCP).
  2. Audio and video conferencing. If the audio and video conferences in a conference simultaneously, the two media are transferred to different RTP sessions, each session uses a different transport address (IP address + port). If a user simultaneously uses two sessions, each session corresponding RTCP packets are normalized using the name CNAME (Canonical Name). Participants can obtain the associated audio and video based on RTCP packet CNAME, and then synchronize audio and video based on timing information (Network time protocol) RTCP packet.
  3. Translation and mixers. Translator and mixer are RTP-level relay system. In the user area via IP multicasting can not be directly translated Used reach , such as a firewall exists between the sender and the receiver. When the participant can receive different audio encoding format, such as by a participant access to a low-speed link session, then you must use a mixer. Before entering the audio data network format needs to be changed, the mixer from one source or multiple sources audio packet is reconstructed and the reconstructed merged plurality of audio, audio coding using another encoding, then the new RTP packet forwarding . Out of all data packets to use a mixer, the mixer as their synchronization source (the SSRC, see RTP encapsulation) identified, talker can be confirmed by contributing source list (CSRC list, see RTP encapsulation).

stream media

  Streaming refers to the continuous time-based media streaming technology used on the Internet.

  Currently on the Internet to transmit audio and video information, etc. There are two main ways: download and streaming

  Under downloads , users need to download the entire file to the local media before you can play media files. In the video broadcast and other applications, due to the formation the entire media file to wait for the end of the broadcast, that is, the user can see at least the live program at the end of the broadcast, the broadcast can not be achieved with the download method.

  Streaming is the key technology of streaming media . Use streaming can download while watching streaming media program. Since the Internet is a packet-based transmission, the receiving end receives the packet delay and often scrambled (streaming built on UDP). To achieve streaming, latency is reduced and the recovery from the packet start timing. In the transmitter, in order to reduce the delay, the transmitted data is often pretreated (reduce the quality and compression efficiency). For timing recovery at the receiving end, a receiving buffer employed; the media in order to achieve smooth playback, playback buffer is used.

  Using the reception buffer, the received data may be cached packet, then the packet according to the encapsulation information (e.g., packet sequence number, and time stamp), the scrambled packet reordering, the last reordered packets into play buffer player.

  Why do you want to play a buffer? Easy to think, because the network can not be very good, and the time consuming need to deal with the data packet sequencing, we get sorted data packets at intervals are unequal. If you do not play the buffer, then the program will be very slow play, called jitter. Instead, use the playback buffer at the start of playback, it takes tens of seconds to fill the first playback buffer (e.g. PPLIVE), delay jitter can be effectively eliminated, so that less losses achieved smoothly streaming real-time premise play.

  So far, more use of streaming video format on the Internet mainly has the following three: RealNetworks company RealMedia, Apple's QuickTime and Microsoft's Advanced Streaming Format (ASF).

  Above when talking about the receive buffer, the package comes to the media stream packet (packet sequence number and time stamp, etc.), which will be reflected in a later RTP package. Further, RealMedia streaming media formats only these different codecs, but the RTP, the streaming media data which are to be transmitted and encapsulated no different.

 

How reorganization out of order packet

  It may be ordered according to the sequence number of the RTP packet.

How to get the timing packets

  May be obtained according to the timing data packet the time stamp of the RTP packet.

How sound and image synchronization

  (I.e., the timestamp of the RTP packet) in accordance with the relative time of the image and the audio stream stream, and their absolute time (i.e. the corresponding RTCP packet RTCP), can be synchronized sound and image.

Receive buffer and playing the role of a buffer

  Buffer for receiving a scrambled ordering of the data packet; playback jitter buffer to eliminate play, play time or the like.

 

RTP protocol level

  RTP (Real-time Transport Protocol), which as the name suggests is used to provide real-time transmission, and thus can be viewed as a sub-layer of the transport layer. RTP is divided in the transport layer, it is based on the UDP . Like UDP protocol, in order to achieve real-time transfer function, there are fixed the RTP package. RTP is used to provide time information and stream synchronization for real-time transmission end to end, but does not guarantee quality of service. The quality of service provided by RTCP .

  Many people also put RTP classified as part of the application layer, which is from the perspective of application developers for the. Operating system, TCP / IP protocol stack provided is our most popular services, and RTP implementations or rely on developers themselves. Therefore, from the perspective of the development, the implementation and realization of the RTP application layer protocol is not different, it may be seen as an application layer protocol RTP.

  RTP RTP implementer when sending data, the data to be first encapsulated into RTP packets in the received RTP data packet, the data needs to be extracted from the RTP packet.

 

RTP encapsulation

  Encapsulation of a protocol to meet the functional requirements of the protocol. RTP encapsulation should have synchronization source, and time stamp fields, also includes the following fields

  • The version number (V): 2 bits for RTP version used marker.
  • Padding bits (P): 1 bit, if the tail bit, the RTP packet contains additional padding bytes.
  • Extension bit (X): 1 bit, if the bit is then secured just behind the head there is an RTP extension header.
  • CSRC counter (CC): 4 bits, the number of CSRC comprises fixed head along the back.
  • Flag (M): 1 bit, the bit is interpreted to be borne by the configuration file (Profile).
  • Payload type (PT): 7 bits, identifies the type of the RTP payload.
  • Sequence number (SN): 16 bits, after each of the sender after sending the RTP packet field value is increased by one, the receiver can detect the packet loss of the domain and packet sequence restoration. The initial value of the sequence number is random.
  • Timestamp: 32 bits, recording the first data byte in the packet sampling time. When a session start, a timestamp is initialized to an initial value. Even when no signal is transmitted, the timestamp value must also continue to increase with time (elapsed time thing). Timestamp is to remove jitter and synchronization indispensable.
  • Synchronization Source Identifier (SSRC): 32 bit, synchronization source refers to the source of the RTP packet stream. In the same RTP session you can have two of the same SSRC value. This identifier is chosen randomly RFC1889 recommended a random MD5 algorithm.
  • Contributing Source list (CSRC List): 0 ~ 15 items, each of 32 bits, all the source RTP packets used to mark the new packet to a RTP mixers contributing. These contribute to the mixer SSRC identifier into the table. SSRC identifiers are listed, so that the receiver can correctly pointed out that the identity of the two sides to talk.

The RTP session

  When the application establishes a RTP session, the application for the purposes of determining a transport address. A destination transport address from the network address and port pair composed of two ports: one for RTP packet, RTCP packet to a, so that the RTP / RTCP data can be correctly transmitted. UDP port odd (even UDP port +1) RTP data is sent to the even UDP port, and a corresponding control signal sent to the adjacent RTCP data, this constitutes a UDP port pair. It follows the RTP transmission, reception and vice versa.

  1. RTP protocol streaming media information received from the upper layer code stream (e.g. H.263), encapsulated into RTP packets; RTCP control information received from the upper layer, encapsulated into RTCP control packets.
  2. RTP RTP data packets sent to the UDP port pair even port; RTCP RTCP control packets sent to the UDP port of the receiving port.

 

RTCP package

  RTP RTCP required to provide a guarantee for the quality of service, it is necessary to introduce the relevant knowledge of RTCP.

  The main function of RTCP is: synchronization, and identifies the members of the multicast group between the quality of service monitoring and feedback, media.

  During RTP session, each participant periodically transmit RTCP packets. RTCP packet comprising the number of packets sent, the number of lost packets statistics, therefore, each participant can use this information to dynamically change transmission rate or even payload type changes. With the use of RTP and RTCP, which can optimize transmission efficiency and effective feedback minimal overhead, and thus is particularly suitable for real-time data transmission network.

  RTCP is transmitted using UDP, but only RTCP package some control information, the packet is so short, it may be a plurality of RTCP packets encapsulated in a UDP packet. There are following five types of RTCP packets.

Types of

Abbreviations

use

200

SR(Sender Report)

The sender report

201

RR(Receiver Report)

The receiving end report

202

SDES(Source Description Items)

Description source

203

BYE

End transmission

204

APP

Specific application

Table 5 kinds of 1 RTCP packet type

These five similar packet encapsulation, the following describes only the SR type, and other types refer to RFC3550.

  Packet transmission end report SR (Sender Report) to the transmission side in the case of multicast send reports to all the receiving ends. The main contents of SR are grouped: SSRC of the RTP stream corresponding to the number of packets an RTP timestamp of the RTP packet stream newly generated and the NTP, RTP stream comprising the number of bytes contained in the RTP stream.

  • Version (V): with RTP header fields.
  • Padding (P): with the RTP header fields.
  • Receiving a report counter (RC): 5 bits, the number of the reception report blocks in the SR packet, may be zero.
  • Packet type (PT): 8 bits, SR packet 200.
  • A length field (Length): 16 bits, where the SR packet is stored in 32-bit units is reduced to a total length.
  • Synchronization source (SSRC): SR packet synchronization source identifier of the sender. Like the RTP packet corresponding to SSRC.
  • NTP Timestamp (Network time protocol) SR package absolute time value is sent. The role of NTP is to synchronize different RTP media streams.
  • RTP Timestamp: corresponding to the NTP timestamp, and the RTP timestamp of an RTP packet with the same unit and the random initial values.
  • Sender's packet count: from the beginning of the SR send the packet to the packet generation period of time, the total number of RTP data packets transmitted by the sender when the SSRC changed, this field is cleared.
  • Sender`s octet count: from the beginning of the SR send the packet to the packet generation period of time, the total number of bytes in the payload data transmitted by the sender (not including the header and padding). When the sender changes its SSRC, this field should be cleared.
  • Synchronization source SSRC identifier of n: the report is included in the block receives statistical information from the source to the packet.
  • Loss rate (Fraction Lost): showed a loss ratio from the last SR or RR packet is sent (SSRC_n) coming from a synchronization source n RTP packet.
  • The total number of missing from the beginning of the received packet to the transmission SSRC_n SR, SSRC_n pass over from the RTP data packets: the cumulative number of lost packets.
  • Spreading largest sequence number received: from the received RTP data packet SSRC_n largest sequence number,
  • Receive jitter (Interarrival jitter): RTP packets accepted statistical variance estimation time
  • Last SR timestamp (Last SR, LSR): SR packet takes an intermediate recently received from the NTP timestamp SSRC_n 32 bits. If you have not received the current SR package, the field is cleared.
  • Delay since last SR (Delay since last SR, DLSR): SR packet last received from SSRC_n to delay sending this report.

 

Other related agreements

Real Time Streaming Protocol (RTSP)

  Real Time Streaming Protocol RTSP (Real-Time Streaming Protocol) is a protocol proposed by IETF, RFC documents corresponding to RFC2362.

  RTSP is an application-layer protocol (TCP / IP Network System). It operates in C / S mode, which is a multimedia playback control protocol which is used so that the user can control the operation of the local image at the same player to play streaming media, i.e. convective media can pause / resume, and so on back and forward control.

Resource Reservation Protocol (RSVP)

  Resource reservation protocol RSVP (Resource Reservation Protocol) is a protocol proposed by IETF, RFC documents corresponding to RFC2208.

  RSVP operates above the IP layer below the transport layer is a network control protocol. RSVP by reserving some bandwidth on the router, to provide quality of service for the transmission of streaming media to a certain extent. In certain experimental systems, such as network video conferencing tools on the integrated vic RSVP.

 

 

 

 

Reference: https://www.cnblogs.com/lidabo/p/7217549.html

 

Guess you like

Origin www.cnblogs.com/zhuminghui/p/10929513.html
RTP