Tuesday, July 23, 2013

Easy understanding of RTP packets.

For any kind of real-time media transmission over internet it is mandatory to follow some specification. We know that the basic data that are transmitted over internet are UDP or TCP packet. Now the main fact is that how the data of specific (ICMP, RTP, RTCP ... etc) type  will transmit.


Now here we will talk about RTP packets.

The RTP --- means --  Real time transport protocol(as we all know!!!!)

The protocol details are given on rfc3550 .

RTP packets:

Q.1. How RTP Transmission packets are constructed ?
Q.2. What is the format of RTP packet ?
Q.3. Describe the RTP header.  

Q. 1. How RTP Transmission packets are constructed ?
Ans:  First of all RTP Transmission packets are not encrypted. They are the raw data of media encoder. For example a h264 encoder creates the raw data by taking input from any video media source and a G722 audio encoder creates the raw data by taking input from any audio source. These data are stored as payload  in a RTP packets without any encryption.  Now the most important part is how the data will arrange in a UDP/TCP packet so that network/any receiver will understand it as a RTP packet. For easy understanding we will take UDP transport for RTP packet and the codec will be x-vrtc1 (121) .


 An RTP transmission packet has 3 part for a successful transmission.

Part 1: IP (source and destination)
Part 2: Transmission protocol and port (source and destination)

Part 1 + Part 2  = 42 byte (UDP)

Part 3: RTP packets  (size depends on network MTU)


Q. 2. What is the format of RTP packet ?
Ans: In basic word it is just an equation.The equation is --

RTP = RTP-header (12-bytes) + RTP-Payload (n- byte).

In details it is like -- 

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |V=2|P|X|  CC   |M|     PT      |       sequence number         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           timestamp                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |           synchronization source (SSRC) identifier            |
   +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
 
 
 
 
First 12-bytes of a RTP packet is RTP-header.
The next n-bytes are RTP-Payload as data.


So now you know everything. Then , what is the crucial part ?
 The crucial part is that the -- Payload is divided into 2 part.

Payload = Payload - header + Payload - data.

Example:  h263 (34) Payload = 4 - byte Payload header + n - byte Payload data. 

If you miss to differentiate these 2 part most of the time your decoder will fail to decode the data.


 Q. 3. Describe the RTP header. 
Ans:   If you ask me I'll say there is nothing so hard that you need to describe.

1.  Version (v=2):  constant.

2.  Padding (p): how much data you need to ignore.

3.  Extension (X): Not so important to implement.

4.  CSRC count (CC): Important when some media profile specific extension are enforced. It is basically the info of media source. I mean the received packets or sending packets SRC info.

5.  Marker (M): Most important to identify a frame end. If it is 1 that means it is the last packet of a complete frame.

6. Payload Type (PT): which is used to determine the codec. For x-vrtc1 it is 121 and for h263 it is 34.

7. Sequence number: Differentiate one packet from other and maintain the sequence so that a receiver can create a complete packet.

8. Timestamp: Use to identify the delay between packets.

9. SSRC: Source Identifier which uniquely  identify the RTP packet for particular media line on a conference or a call.



That's all !!!!

You are good to go.




No comments:

Post a Comment

How to enable hotspot in TPG iPhone

 By default, the hotspot does not work on the phone. It will ask you to contact the provider. This video will help you bypass the network ...