`
javatoyou
  • 浏览: 1100533 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

SDP 协议简单解析

 
阅读更多

SDP—Session Description Protocol

The Session Description Protocol, defined by RFC 2327 [1], was developed by the IETF MMUSIC working group. It is more of a description syntax than a protocol in that it does not provide a full-range media negotiation capability. The original purpose of SDP was to describe multicast sessions set up over the Internet's multicast backbone, the MBONE. The first application of SDP was by the experimental Session Announcement Protocol (SAP) [2] used to post and retrieve announcements of MBONE sessions. SAP messages carry a SDP message body, and was the template for SIP's use of SDP. Even though it was designed for multicast, SDP has been applied to the more general problem of describing general multimedia sessions established using SIP.

As seen in the examples of Chapter 3, SDP contains the following information about the media session:

  • IP Address (IPv4 address or host name);

  • Port number (used by UDP or TCP for transport);

  • Media type (audio, video, interactive whiteboard, and so forth);

  • Media encoding scheme (PCM A-Law, MPEG II video, and so forth).

In addition, SDP contains information about the following:

  • Subject of the session;

  • Start and stop times;

  • Contact information about the session.

Like SIP, SDP uses text coding. An SDP message is composed of a series of lines, called fields, whose names are abbreviated by a single lower-case letter, and are in a required order to simplify parsing. The set of mandatory SDP fields is shown in Table 2.1. The complete set is shown in Table 7.1.

Table 7.1: SDP Field List in Their Required Order

Field

Name

Mandatory/Optional

v=

Protocol version number

m

o=

Owner/creator and session identifier

m

s=

Session name

m

i=

Session information

o

u=

Uniform Resource Identifer

o

e=

Email address

o

p=

Phone number

o

c=

Connection information

m

b=

Bandwidth information

o

t=

Time session starts and stops

m

r=

Repeat times

o

z=

Time zone corrections

o

k=

Encryption key

o

a=

Attribute lines

o

m=

Media information

o

a=

Media attributes

o

SDP was not designed to be easily extensible, and parsing rules are strict. The only way to extend or add new capabilities to SDP is to define a new attribute type. However, unknown attribute types can be silently ignored. A SDP parser must not ignore an unknown field, a missing mandatory field, or an out-of-sequence line. An example SDP message containing many of the optional fields is shown here:

     v=0
     o=johnston 2890844526 2890844526 IN IP4 43.32.1.5
     s=SIP Tutorial
     i=This broadcast will cover this new IETF protocol
     u=http://www.digitalari.com/sip
     e=Alan Johnston alan@mci.com
     p=+1-314-555-3333 (Daytime Only)
     c=IN IP4 225.45.3.56/236
     b=CT:144
     t=2877631875 2879633673
     m=audio 49172 RTP/AVP 0
     a=rtpmap:0 PCMU/8000
     m=video 23422 RTP/AVP 31
     a=rtpmap:31 H261/90000

The general form of a SDP message is:

     x=parameter1 parameter2 ... parameterN

The line begins with a single lower-case letter x. There are never any spaces between the letter and the =, and there is exactly one space between each parameter. Each field has a defined number of parameters. Each line ends with a CRLF. The individual fields will now be discussed in detail.

7.1.1 Protocol Version

The v= field contains the SDP version number. Because the current version of SDP is 0, a valid SDP message will always begin with v=0.

7.1.2 Origin

The o= field contains information about the originator of the session and session identifiers. This field is used to uniquely identify the session. The field contains:


     o=username session-id version network-type address-type
     address

The username parameter contains the originator's login or host or - if none. The session-id parameter is a Network Time Protocol (NTP) [3] timestamp or a random number used to ensure uniqueness. The version is a numeric field that is increased for each change to the session, also recommended to be a NTP timestamp. The network-type is always IN for Internet. The address-type parameter is either IP4 or IP6 for IPv4 or IPv6 address either in dotted decimal form or a fully qualified host name.

7.1.3 Session Name and Information

The s= field contains a name for the session. It can contain any non-zero number of characters. The optional i= field contains information about the session. It can contain any number of characters.

7.1.4 URI

The optional u= field contains a uniform resource indicator (URI) with more information about the session.

7.1.5 E-Mail Address and Phone Number

The optional e= field contains an e-mail address of the host of the session. If a display name is used, the e-mail address is enclosed in <>. The optional p= field contains a phone number. The phone number should be given in globalized format, beginning with a +, then the country code, a space or , then the local number. Either spaces or are permitted as spacers in SDP. A comment may be present in ().

7.1.6 Connection Data

The c= field contains information about the media connection. The field contains:

     c=network-type address-type connection-address

The network-type parameter is defined as IN for the Internet. The address type is defined as IP4 for IPv4 addresses, IP6 for IPv6 addresses. The connection-address is the IP address that will be sending the media packets, which could be either multicast or unicast. If multicast, the connection-address field contains:


     connection-address=base-multicast-address/ttl/number-of-
       addresses

where ttl is the time-to-live value, and number-of-addresses indicates how many contiguous multicast addresses are included starting with the base-multicast-address.

7.1.7 Bandwidth

The optional b= field contains information about the bandwidth required. It is of the form:

     b=modifier:bandwidth-value

The modifier is either CT for conference total or AS for application specific. CT is used for multicast session to specify the total bandwidth that can be used by all participants in the session. AS is used to specify the bandwidth of a single site. The bandwidth-value parameter is the specified number of kilobytes per second.

7.1.8 Time, Repeat Times, and Time Zones

The t= field contains the start time and stop time of the session.

     t=start-time stop-time

The times are specified using NTP timestamps. For a scheduled session, a stop-time of zero indicates that the session goes on indefinitely. A start-time and stop-time of zero for a scheduled session indicates that it is permanent. The optional r= field contains information about the repeat times that can be specified in either in NTP or in days (d), hours (h), or minutes (m). The optional z= field contains information about the time zone offsets. This field is used if a reoccurring session spans a change from daylight-savings to standard time, or vice versa.

7.1.9 Encryption Keys

The optional k= field contains the encryption key to be used for the media session. The field contains:

     k=method:encryption-key

The method parameter can be clear, base64, uri, or prompt. If the method is prompt, the key will not be carried in SDP; instead, the user will be prompted as they join the encrypted session. Otherwise, the key is sent in the encryption-key parameter.

7.1.10 Media Announcements

The optional m= field contains information about the type of media session. The field contains:

     m=media port transport format-list

The media parameter is either audio, video, application, data, telephone-event, or control. The port parameter contains the port number. The transport parameter contains the transport protocol, which is either RTP/AVP or udp. (RTP/AVP stands for Real-time Transport Protocol [4] / audio video profiles [5], which is described in Section 7.3.) The format-list contains more information about the media. Usually, it contains media payload types defined in RTP audio video profiles. More than one media payload type can be listed, allowing multiple alternative codecs for the media session. For example, the following media field lists three codecs:

     m=audio 49430 RTP/AVP 0 6 8 99

One of these three codecs can be used for the audio media session. If the intention is to establish three audio channels, three separate media fields would be used. For non-RTP media, Internet media types should be listed in the format-list. For example,

     m=application 52341 udp wb

could be used to specify the application/wb media type.

7.1.11 Attributes

The optional a= field contains attributes of the preceding media session. This field can be used to extend SDP to provide more information about the media. If not fully understood by a SDP user, the attribute field can be ignored. There can be one or more attribute fields for each media payload type listed in the media field. For the RTP/AVP example in Section 7.1.10, the following three attribute fields could follow the media field:

     a=rtpmap:0 PCMU/8000
     a=rtpmap:6 DVI4/16000
     a=rtpmap:8 PCMA/8000
     a=rtpmap:99 iLBC

Other attributes are shown in Table 7.2. Full details of the use of these attributes are in the standard document [1]. The details of the iLBC (Internet Low Bit Rate) Codec are in [6].

Table 7.2: SDP Attribute Values

Attribute

Name

a=rtpmap:

RTP/AVP list

a=cat:

Category of the session

a=keywds:

Keywords of session

a=tool:

Name of tool used to create SDP

a=ptime:

Length of time in milliseconds for each packet

a=recvonly

Receive only mode

a=sendrecv

Send and receive mode

a=sendonly

Send only mode

a=orient:

Orientation for whiteboard sessions

a=type:

Type of conference

a=charset:

Character set used for subject and information fields

a=sdplang:

Language for the session description

a=lang:

Default language for the session

a=framerate:

Maximum video frame rate in frames per second

a=quality:

Suggests quality of encoding

a=fmtp:

Format transport

a=mid:

Media identification grouping

a=direction:

Direction for symmetric media

a=rtcp:

Explicit RTCP port (and address)

a=inactive

Inactive mode

7.1.12 Use of SDP in SIP

The use of SDP with SIP is given in the SDP Offer Answer RFC 3264 [7]. The default message body type in SIP is application/sdp. The calling party lists the media capabilities that they are willing to receive in SDP in either an INVITE or in an ACK. The called party lists their media capabilities in the 200 OK response to the INVITE. More generally, offers or answers may be in INVITEs, PRACKs, or UPDATEs or in reliably sent 18x or 200 responses to these methods.

Because SDP was developed with scheduled multicast sessions in mind, many of the fields have little or no meaning in the context of dynamic sessions established using SIP. In order to maintain compatibility with the SDP protocol, however, all required fields are included. A typical SIP use of SDP includes the version, origin, subject, time, connection, and one or more media and attribute fields as shown in Table 2.1. The origin, subject, and time fields are not used by SIP but are included for compatibility. In the SDP standard, the subject field is a required field and must contain at least one character, suggested to be s= if there is no subject. The time field is usually set to t=0 0.

SIP uses the connection, media, and attribute fields to set up sessions between user agents. Because the type of media session and codec to be used are part of the connection negotiation, SIP can use SDP to specify multiple alternative media types and to selectively accept or decline those media types. When multiple media codecs are listed, the caller and called party's media fields must be aligned—that is, there must be the same number, and they must be listed in the same order. The offer answer specification, RFC 3264 [7], recommends that an attribute containing a=rtpmap: be used for each media field [7]. A media stream is declined by setting the port number to zero for the corresponding media field in the SDP response. In the following example, the caller Tesla wants to set up an audio and video call with two possible audio codecs and a video codec in the SDP carried in the initial INVITE:

     v=0
     o=Tesla 2890844526 2890844526 IN IP4 lab.high-voltage.org
     s=-
     c=IN IP4 100.101.102.103
     t=0 0
     m=audio 49170 RTP/AVP 0 8
     a=rtpmap:0 PCMU/8000
     a=rtpmap:8 PCMA/8000
     m=video 49172 RTP/AVP 32
     a=rtpmap:32 MPV/90000

The codecs are referenced by the RTP/AVP profile numbers 0, 8, and 32. The called party Marconi answers the call, chooses the second codec for the first media field and declines the second media field, only wanting a PCM A-Law audio session.

     v=0
     o=Marconi 2890844526 2890844526 IN IP4 tower.radio.org
     s=-
     c=IN IP4 200.201.202.203
     t=0 0
     m=audio 60000 RTP/AVP 8
     a=rtpmap:8 PCMA/8000
     m=video 0 RTP/AVP 32

If this audio-only call is not acceptable, then Tesla would send an ACK then a BYE to cancel the call. Otherwise, the audio session would be established and RTP packets exchanged. As this example illustrates, unless the number and order of media fields is maintained, the calling party would not know for certain which media sessions were being accepted and declined by the called party.

One party in a call can temporarily place the other on hold (i.e., suspending the media packet sending). This is done by sending an INVITE with identical SDP to that of the original INVITE but with a=sendonly attribute present. The call is made active again by sending another INVITE with the a=sendrecv attribute present. (Note that older RFC 2543 compliant UAs may initiate hold using c=0.0.0.0.) For further examples of SDP use with SIP, see the SDP Offer Answer Examples document [8].

分享到:
评论

相关推荐

    sdp-transform, 用于会话描述协议的简单解析器/编写器.zip

    sdp-transform, 用于会话描述协议的简单解析器/编写器 SDP转换 SDP的简单解析器和编写器。 基于 RFC4566 SDP RFC5245 ICE和许多其他语法定义内部语法。为了简单起见,它将强制值为整数的值,并在解析时将其他内容...

    js-sdp-parser:使用javascript来构建和解析sdp协议

    `js-sdp-parser`是一个开源项目,它提供了使用JavaScript来构建和解析SDP协议的能力,这对于在浏览器环境中进行实时通信开发至关重要。 ### SDP协议简介 SDP协议的主要作用是描述多媒体会话的属性,如音频、视频...

    rtp rtsp sip sdp nat 协议

    4. SDP(会话描述协议):SDP是一种简单的文本格式,用于描述多媒体会话的特性,如媒体类型(音频、视频)、编码方式、传输地址和端口等。SIP消息中通常包含SDP,帮助参与方了解如何加入会话。 5. NAT(网络地址...

    sdp-transform:会话描述协议的简单解析器

    SDP的简单解析器和编写器。 根据 , 等定义内部语法。 为简单起见,它将强制将整数值转换为整数,并在解析时将其他所有内容保留为字符串。 该模块应易于扩展或构建,并且结构严谨。 安装 $ npm install sdp-...

    LumiSoftNet FTP,SDP,POP3协议封装

    通过这些组件,开发者可以轻松集成FTP、SDP和POP3协议到自己的应用程序中,无论是简单的文件传输,还是复杂的多媒体会议或邮件服务,LumiSoftNet都能提供强大的支持。其清晰的API设计和详尽的文档通常会使得学习和...

    SDP学习笔记

    例如,一个简单的SDP可能如下: ``` v=0 o=- 488908723434343 2 IN IP4 192.168.1.1 s=SDP Example c=IN IP4 192.168.1.1 t=0 0 m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 ``` 这个例子描述了一个...

    SIP协议解析与实现(c/c++)

    **SIP协议解析与实现(c/c++)** SIP(Session Initiation Protocol)协议是一种用于创建、修改和终止多媒体通信会话的信令协议,广泛应用于VoIP、视频会议和即时消息等领域。根据RFC3261,SIP设计为简单、可扩展且...

    C#实现SDP文件播放 VLC播放技术

    3. **解析SDP文件**: 使用正则表达式或自定义解析器读取SDP文件,获取媒体流的URL和端口信息。例如,"m=video 5004 RTP/AVP 96"表示一个视频流,端口为5004,编码类型为96。 4. **设置播放源**: 将解析得到的SDP...

    io.joss.sdp:会话描述协议(SDP)解析器

    Jive SDP解析器一个简单的Java SDP解析器,在Java 8之外没有任何依赖关系。用法SessionDescription sdp = SessionDescription.parse(input);建造摇动

    parsip:用于NodeJS的简单SIPSDP解析模块

    parSIP 用于Node / JS的直接SIP / SDP解析模块用法从SIP到JSON var parsip = require ( 'parsip' ) ;var sip_message = "..." // Valid SIP Message herevar sip = parsip . getSIP ( sip_message ) ;从SDP到JSON if...

    libsdptransform:基于sdp转换JavaScript库的会话描述协议C ++解析器

    libsdptransform是SDP的简单解析器和编写器。 根据 , 等定义内部语法。用法安装完成后(请参见下面的安装): # include " sdptransform/sdptransform.hpp " libsdptransform API在sdptransform C ++名称空间中...

    SDP:SDP求解器的通用python包装器

    1. **多求解器支持**:包装器会包含对不同SDP求解器的接口,比如SeDuMi、SDPA、Mosek、CVXOPT等,使得用户可以通过简单的配置更改就切换求解器。 2. **问题定义接口**:提供一个统一的语法来定义SDP问题,如定义...

    一个简单得SIP协议栈实现

    本项目提供了一个简单的SIP协议栈实现,旨在帮助开发者理解SIP工作原理,并能够处理UDP和RTP协议数据。 首先,我们来深入理解SIP协议。SIP是一种基于文本的协议,类似于HTTP,但设计用于实时通信。它的主要功能包括...

    蓝牙协议源代码(C语言写的)

    这包括简单配对(SPP)、安全连接(LE Secure Connections)和密钥交换协议。C语言实现时,需要处理密钥生成、身份验证算法(如ECC或AES)以及安全模式。 7. **C语言编程**:C语言是一种底层、高效且可移植的语言,...

    eXosip2_manual.rar_eXosip2_eXosip2 API_eXosip_malloc_sip_sip sdp

    - 解析SDP:`eXosip_sdp_parse()`函数用于解析接收到的SDP信息,提取媒体类型、端口、编码等信息。 - 更新SDP:在协商过程中,`eXosip_sdp_change_mLine()`和`eXosip_sdp_set_attribute()`可以用来修改SDP字段。 ...

    最简单明了的Rtsp协议以及实现

    这个压缩包中的文件很可能是包含了一个简单的Rtsp客户端示例,通过阅读和分析这些代码,初学者可以深入了解Rtsp协议的实现细节,以及如何在VC++环境下处理网络通信和流媒体数据。这对于进一步学习网络编程和媒体服务...

    osip、eXosip协议栈源码最新版4.1.0

    《osip与eXosip协议栈:源码解析与应用探索》 osip(OSI Protocol Stack)和eXosip是两个重要的开源SIP(Session Initiation Protocol)协议栈,它们为开发者提供了实现VoIP(Voice over Internet Protocol)、...

Global site tag (gtag.js) - Google Analytics