Acquaintance RTP protocol (a)

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/yuewen2008/article/details/90415611

Before the recent projects need to use rtp protocol for this network protocol is not understood recently learned about the basic agreement Something about learning the protocol column and linux geeks time network performance to optimize network performance analysis portion of the benefit column to do today a simple summary.

A, UDP protocol

Linux system four network reference model transport layer two protocol is important TCP and UDP protocols. That is where the User DataProgram Protocol UDP User Datagram Protocol that provides for simple things unreliable messaging services.
UDP is a connectionless protocol. I.e. transferring data source and destination ports without establishing a connection,
it is not necessary to establish a connection and thus there is no need to maintain the connection state of
the UDP packet header only 8 bytes of TCP header has 20 bytes.
I caught as video streaming network packets based rtp protocol, RTP down protocol based on UDP transport protocol UDP header encapsulated. UDP protocol header total of 8 bytes.

Here Insert Picture Description

Wherein the data packet header format of UDP is defined below
the first two bytes of the source port number
of the third byte and the fourth byte is the destination port number of
the fifth byte and the sixth byte of the packet length
of 7 bytes and 8-byte data packet checksum

Here Insert Picture Description

Two, RTP protocol

RTP protocol is mainly used for real-time data transmission scenarios including audio video transmission. RFC3550 RTP protocol depends not specified transport protocol (UDP or TCP), but in most of the systems are based on real-time streaming media is characteristic UDPUDP fast packet processor (not reliable, simple and direct), this feature very suitable for high latency requirement of real-time streaming media system.

Here Insert Picture Description

The picture shows the data packet header as defined in the RTP

Here Insert Picture Description

RTP protocol header contains 12 bytes.

RTP header core fields:
M flag

:Mark标识位,用于标识一段视频序列包是否结束。因为视频的数据量大,视频序列可能会包括在多个RTP包中。需要标识位指示序列也结束。

PT

Payload type 标识RTP携带的媒体数据的类型。通过该字段可以知道RTP包携带的是什么类型的编码格式,比如是音频流还是视频流等。

Sequence number

序列号,用于标识RTP包的顺序。我们知道对视频来说是有严格是时序的,那么在网络上传输的数据包必须有能标识顺序的字段,该字段是加1递增的

Timestamp

标准中规定的是对应于每个RTP包携带的视/音频的采样时间,注意并不是指定的时钟时间,这里的采样时间通过音频或视频的一个采用周期来换算的,换算公式: ts_current_90000hz = (当前系统时间ms - start_time_ms) * 90000.0 / 1000.0这个字段值有比较多的灵活性,常见的生成值方案有:根据实际的采样时间,按照固定的音视频采样周期递增,比如以40ms的周期递增,那么每个RTP的时间戳间隔就9000*40ms = 3600。

SSRC

一条RTP流的唯一标识,有多条RTP流,那么每条 RTP流的SSRC是不能相同的

以上字段刚开始分析协议时需要注意pt类型 因为该类型用来标识rtp协议传输到底是音频流还是视频流,那么pt类型又有哪些定义呢?具体如下

Here Insert Picture Description

Here Insert Picture Description

三、网络问题分析

  1. 丢包: seqnumber 是否按照顺序依次增加
  2. Mark位: 时间戳相同包的序列最后一个包需要打mark位 接收端依据mark值来组包。
  3. Ssrc:是否一致
  4. 乱序: 还是通过seq number来判断是否乱序 对于视频流来说乱序将导致视频播放异常

四、SDP协议

I.e., the SDP Session Description Protocol Session Description Procotol. The ability to describe the local media support, the ability to tell their own media to end. SDP is the object of the media session, the media stream information is transmitted, to allow the recipient to participate in the session in a session description. SDP basically work on the internet. He defines a uniform format session description, but does not define the transmission of multicast address allocation and SDP message, nor support the negotiation of media encoding schemes, these functions are controlled by the underlying transport protocol is complete. A typical session transfer protocol comprising: SAP (Session Announcement Protocol Session Announcement Protocol), SIP (Session Initiation Protocol, Session Initiation Protocol), RTSP, HTTP, MIME, and use of E-Mail.

Here Insert Picture Description

SDP includes the following aspects:
the name and purpose of (1) a session
(2) Session survival time
(3) comprises a media information in the session, comprising: a
media type (video, audio, etc)
transfer protocol (RTP / UDP / IP , H.320, etc)
media format (H.261video, MPEG video, etc)
multicast or distal (unicast) address and port
(4) information (addresses and receive media required, ports, formats and so on )
bandwidth information (5) used in
(6) reliable contact information (contact information)

For rtp agreement has just understand the problem with the analysis process also requires further study.

Guess you like

Origin blog.csdn.net/yuewen2008/article/details/90415611
RTP