Presentation is loading. Please wait.

Presentation is loading. Please wait.

SIP 协议介绍.

Similar presentations


Presentation on theme: "SIP 协议介绍."— Presentation transcript:

1 SIP 协议介绍

2 SIP协议介绍 SIP Session Initiation Protocol(会话初始协议)
多媒体会话可以是多媒体会议、远程教学、因特网电话等各种应用。

3 SIP协议特点 应用层协议 基于文本的消息编码 独立于较低层次的传输协议 通过代理、重定向功能支持用户的移动性 易实现性 易扩展性
具有多个层次的可实现性,最小的实现非常简单。最完全的实现相对复杂,但能够完成非常多的功能

4 SIP消息 SIP协议是一个基于文本的协议,其消息包括请求和响应。
请求: INVITE、ACK、OPTIONS、BYE、 CANCEL、REGISTER等。 响应: 1XX、2XX、3XX、4XX、5XX、 6XX等。

5 SIP消息的格式与编码 文本协议 消息格式 开始行(请求行、状态行) 消息头域 空行(CRLF) [消息体] 消息体包含媒体信息,采用SDP协议描述

6 SIP请求 主要方法: INVITE: 表示请求用户或服务加入一个会话 ACK:用来确认客户已经收到了一个对INVITE请求的最终响应
格式:Method SP Request-URI SP SIP-Version CRLF 例子:INVITE SIP/2.0 主要方法: INVITE: 表示请求用户或服务加入一个会话 ACK:用来确认客户已经收到了一个对INVITE请求的最终响应 OPTIONS:用于查询对方用户代理的能力 BYE:用于结束一个会话 CANCEL:用于撤销一个正在等待的请求 REGISTER:用于将自己的地址信息注册到服务器上 其他方法: INFO, REFER, PRACK, COMET, SUBSCRIBE, UNSUBSCRIBE, NOTIFY, MESSAGE等

7 SIP请求例子 INVITE sip:bob@beijin.com SIP/2.0
Via: SIP/2.0/UDP pc33.shanghai.com;branch=z9hG4bK776asdhds Max-Forwards: 70 To: Bob From: Alice Call-ID: CSeq: INVITE Contact: Content-Type: application/sdp Content-Length: 142 [message body(SDP)]

8 SIP响应 响应类型: 1XX 进展报告,请求已收到,正在处理 2XX 请求成功 3XX 重定向,还需进一步操作才能完成请求
格式:SIP-Version SP Status-Code SP Reason-Phrase CRLF 例子:SIP/ Not Found 响应类型: 1XX 进展报告,请求已收到,正在处理 2XX 请求成功 3XX 重定向,还需进一步操作才能完成请求 4XX 客户端错误,请求包含无效语法,或服务 器不能接受该请求 5XX 服务器端错误 6XX 全局错误

9 SIP响应例子 SIP/ OK Via: SIP/2.0/UDP server10.beijin.com;branch=z9hG4bKnashds8;received= Via: SIP/2.0/UDP bigbox3.site3.shanghai.com;branch=z9hG4bK74c ;received= Via: SIP/2.0/UDP pc33.shanghai.com;branch=z9hG4bK776asdhds;received= To: Bob From: Alice Call-ID: a84b4c76e66710 CSeq: INVITE Contact: Content-Type: application/sdp Content-Length: 131 [message body(SDP)]

10 SIP Request-URI 指示请求的目的地址 代理服务器基于Request-URI路有请求

11 SIP tags Tag是一种伪随机数,被用于From和To头域中,用于唯一标识一个Dialog
任何用户代理或服务器产生一个请求的响应,并在To头域中插入to-tag。如: To:

12 SIP消息头域 需要的头域有To, From, Via, Call-ID, CSeq
可选的头域有Subject, Authorization等 头域介绍: Accept Authorization Call-Id Contact Content-Length Content-Type Cseq Encryption Expires

13 SIP消息头域(续) From Max-Forwards Priority Record-Route Require Retry-After
Subject To Unsupported Via Warning

14 SIP消息体 消息体可以使任何协议格式 常用消息体类型有SDP、ISUP等
SDP例子: v=0 o=bob IN IP4 server1.juphoon.com s=Let's Talk t=0 0 c=IN IP m=audio RTP/AVP 0 3

15 SIP Transaction 一个SIP事务处理包含一个请求、零个或多个临时响应和一个最终响应。
同一个事务处理中,请求和响应的To、From、Call-ID、CSeq等头域的值相同。 Call-ID用于标识一个会话,在同一时刻全局唯一。 事务类型: INVITE Client Transaction INVITE Server Transaction non-INVITE Client Transaction non-INVITE Server Transaction

16 SIP Dialog Dialog is a peer-to-peer SIP relationship between two user agents that persists for some time Dialog有利于对消息进行排序和把请求正确的路由给两侧的用户 Dialog ID: Call-Id, 本地tag, 对端tag 组成 Dialog状态: 由本地请求序列号,对端请求序列号,本地URI,对端URI,secure标志 Dialog的创建方法: RFC3261 INVITE RFC3265 SUBSCRIBE

17 SIP Transport 使用UDP、TCP、TLS等协议传输 缺省端口号 :5060(UDP)、5061(TCP)
可靠性保证 使用SeqNum保证消息次序 超时重传保证消息可靠发送 使用RFC3262的PRACK方法实现临时响应的可靠传输

18 SIP协议逻辑实体 User Agent :能够发送和接收请求,如SIP Phone User Agent Client:初始SIP请求 User Agent Server:返回SIP响应 Proxy Server:决定请求的下一跳和转发请求 Stateless Proxy:无状态代理服务器 Stateful Proxy:有状态代理服务器 Registrar Server :接受客户端的注册(REGISTER) 请求 Redirect Server:返回下一跳的地址信息给客户端

19 SIP Phone的特性 呼叫响应:发送200 OK 响应 呼叫忙:发送483 Busy Here 响应
呼叫拒绝:发送603 Declined 响应 显示呼叫ID: 显示From头域的主叫信息 呼叫保持:发送re-INVITE请求 呼叫选择:根据From、Priority、Subject选择呼叫 呼叫等待:发送180 Ringing 响应 呼叫排队:发送181 Call Queued 响应

20 SIP协议安全 Authentication(鉴定):服务器或用户代理可以在Authentication头域的challenge参数中使用共享密钥鉴别另一个用户代理 Encryption(加密):消息体或者一些消息头域可以被加密处理 Digital Signatures (数字签证)

21 SIP协议请求过程-1 UAC Proxy UAS Request Response location service
finger/DNS/LDAP 在编写使用实例的文档时可采用标准模版,在使用实例基础上可得到功能需求 。

22 SIP协议请求过程-2 UAC Redirect Proxy UAS Request Response location service
finger/DNS/LDAP

23 SIP基本呼叫流程 INVITE is a Request and contains Tesla’s media information
180 Ringing is an Informational response and is not required 200 OK is a final Response and contains Marconi’s media information ACK completes three-way-handshake. BYE tears down session

24 SIP代理呼叫流程 INVITE is sent to Proxy instead of to Heisenberg directly.
Proxy looks up address of Heisenberg and forwards INVITE to that IP Address. Responses to INVITE route back through the Proxy: 180 Ringing and 200 OK 200 OK contains a Contact header which allows the ACK and all future requests to go directly bypassing Proxy.

25 SIP重定向呼叫流程 INVITE is sent to Redirect Server
Server looks up address of Heisenberg and returns that address in a Contact header in a 302 Moved Temporarily response The ACK completes the transaction with the Server Schroedinger then re-sends the INVITE directly to Heisenberg

26 SIP注册呼叫流程 Heisenberg sends a REGISTER request to a Registrar Server. The request contains Contact headers listing the URLs for which Heisenberg wishes to receive incoming SIP calls Registrar Accepts registration and replies with 200 OK and echoes current Contact list

27 SIP到PSTN呼叫流程 Request-URI in the INVITE contains a Telephone Number which is sent to PSTN Gateway. The Gateway maps the INVITE to a SS7 ISUP IAM (Initial Address Message) 183 Session Progress establishes early media session so caller hears Ring Tone. Two way Speech path is established after ANM (Answer Message) and 200 OK

28 PSTN到SIP呼叫流程 ISDN telephone call is routed to a PSTN/SIP Gateway
The Gateway maps the ISDN Setup message to a SIP INVITE message to a Proxy Proxy consults Database and maps telephone number to SIP URL of the SIP Phone and proxies the INVITE The 180 Ringing response is mapped to a ISDN Alerting message - no ring tone is generated

29 Proxy并行查找呼叫流程 Single INVITE request returns three Contact headers from Redirect Server. Babbage tries each location in parallel Each INVITE has same To, From, and Call-ID, but a unique branch tag which identifies each leg. First two INVITEs fail, but third is successful and session is established. Forking Proxy Servers also can perform this function.

30 SIP可靠性呼叫流程 Unreliable UDP transport is assumed
OPTIONS message is lost between Proxy and UAS. Stateful Proxy realizes message loss and retransmits message after timer T1 expires 200 OK response is lost between Proxy and UAC. UAC retransmits OPTIONS after timer T2 expires Proxy realizes response loss and retransmits 200 OK response

31 相关协议 Real Time Protocol (RTP) – media packets
Real Time Control Protocol (RTCP) – monitor & report Session Description Protocol (SDP) Session Initiation Protocol (SIP) Real Time Stream Protocol (RTSP) – play out control Q.931 SS7 H.323

32 谢 谢 !


Download ppt "SIP 协议介绍."

Similar presentations


Ads by Google