DBMS Registrar Server SIP Redirect Server SIP Proxy
DBMS 主要结构 Registrar Server SIP Redirect Server SIP Proxy Server Location Server SIP Proxy Server IP Network User. Agent 图例 SIP协议 私有协议 User. Agnet
2. 功能实体 ü ü ü User Agent Proxy Server Redirect Server Registrar Server Location Server
SIP URL & SIP依靠URL进行路由。SIP URL的格式可以是Email. ID 或者是E. 164地址。 SIP: user@host TEL: 85521717@suntektech. com & URL可以用在下面头域中: Ø FROM头域 FROM: <SIP: kermit@suntektech. com> Ø TO头域 TO: <SIP: tom@netcentrex. com> Ø CONTACT头域:<TEL: 6831@suntektech. com> & 可以方便的嵌入网页,提供多种网上业务
URL的表示规则 SIP-URL = "sip: " [ userinfo "@" ] hostport transport-param = "transport=" ( "udp" | "tcp" ) url-parameters [ headers ] ttl-param = "ttl=" ttl userinfo = user [ ": " password ] ttl = 1*3 DIGIT ; 0 to 255 user = *( unreserved | escaped maddr-param = "maddr=" host | "&" | "=" | "+" | "$" | ", " ) user-param = "user=" ( "phone" | "ip" ) password = *( unreserved | escaped method-param = "method=" Method | "&" | "=" | "+" | "$" | ", " ) tag-param = "tag=" UUID hostport = host [ ": " port ] UUID = 1*( hex | "-" ) host = hostname | IPv 4 address other-param = ( token | ( token "=" ( token | hostname = *( domainlabel ". " ) toplabel [ ". " ] quoted-string ))) domainlabel = alphanum | alphanum *( headers = "? " header *( "&" header ) alphanum | "-" ) alphanum header = hname "=" hvalue toplabel = alpha | alpha *( alphanum | "-" ) hname = 1*uric alphanum hvalue = *uric IPv 4 address = 1*digit ". " 1*digit uric = reserved | unreserved | escaped ". " 1*digit reserved = "; " | "/" | "? " | ": " | "@" | "&" | port = *digit "=" | "+" | "$" | ", " url-parameters = *( "; " url-parameter ) digits = 1*DIGIT url-parameter = transport-param | user-param | method-param | ttl-param | maddr-param | otherparam
例子 l l l l l sip: j. doe@big. com sip: j. doe: secret@big. com; transport=tcp sip: j. doe@big. com? subject=project sip: +1 -212 -555 -1212: 1234@gateway. com; user=phone sip: 1212@gateway. com sip: alice@10. 1. 2. 3 sip: alice@example. com sip: alice%40 example. com@gateway. com sip: alice@registrar. com; method=REGISTER
定位Proxy服务器 & 配置UA指向Proxy Server,由Redirect Server分配合适的Proxy Server & 配置UA指向Redirect
定位SIP User. Agent Server(被叫) & User Agent激活时通过Registrar Server注册。 & Proxy Server通过Location Server得到User Agent Server的路由。 & Proxy Server根据地址呼叫User. Agent Server & 如果没有能到达User. Agent Server的路由,必 须返回User. Agent Client(主叫)具体的原因, 包括代码和文字的原因。
SIP 消息体组成 响 应 的 SIP版 本 SP状 态 码 SP原因短语 CRLF 起始行 Start-Line 消息头域 Message-line 空行 CRLF 消息体 Message-body 消 息 体 ( SDP原 码 , 加 密 的 SDP,…) 请求的方法SP请求的SIP-URL SP SIP版本CRLF General-header | Request-header | Response-header | Entity-header
Start line(起始行详细描述) 起始行 Start-Line = request-line | status-line request-line = Version CRLF Method SP Request-URI SP SIPINVITE sip : SS@Sun. Tek. com SIP 2. 0 status-line phase CRLF = SIP-Version SP status-code SP SIP 2. 0 200 OK
General headers(通用头域) 路由信息:Accept | Accept-Encoding | Accept-Language | Contact | Date| Encryption| Expires | From | Record-Route |Timestamp 呼叫标示 : Call-ID, CSeq, INVITE sip: Sip@Sun. Tek. com SIP 2. 0 Via: SIP/2. 0/UDP proxy. Sun. Tek. com Via: SIP/2. 0/UDP sation 1. Sun. Tek. com From : Wang < sip: Wang@Sun. Tek. com > To : softswitch <sip: Sip@Sun. Tek. com Call-ID : 23434@ sation 1. Sun. Tek. com CSeq: 1 INVITE Contact : Wang@Sun. Tek. com >
其他头域(请求、响应、实体) Request Headers: Hide, In-Reply-To, Max-Forwards, Priority, Proxy. Authentication, Proxy-Require, Response-Key, Subject, Route Response Headers: Proxy-Authenticate, Retry-After, Server, Unsupported, Warning, WWW-Authenticate Entity Headers: Allow, Content-Disposition, Content-Encoding, Content. Language, Content-Length, Content-Type, Expires
关键头域解析(Accept, Call. ID) Ø Accept : 指明请求方所能接受的响应类型. 媒体类型: Internet media types, defined in MIME 缺省值是 application/sdp. syntax Accept : # ( */* | type/subtype ) ; q= value; Example : Accept : text/plain; text/x-dvi; Ø Call. ID: q=0. 5, q=0. 8, text/html, text/x-c 唯一标识一个会话,保持全球的唯一性 Call-ID区分大小写 随机产生,有效的提高安全性 Call. ID相同,消息体不同时将更新会话 Syntax: Call-ID = (“Call-ID” | “i”)”: ”local-id”@”host Example: Call-ID: f 81 d 4 fae-7 dec-11 d 0 -a 765 -00 a 0 c 91 e 6 bf 6@foo. bar. com
5. SIP请求消息 ü INVITE ACK BYE REGISTER CANCEL ü OPTIONS ü ü
ACK(邀请证实) & 证实INVITE请求 & ACK只和INVITE请求一起使用 & ACK有User. Agent Client(主叫)发出 & ACK中的Call. ID, From, To, Cseq由INVITE消息复 制而来
Invite Details Mary INVITE sip: john@192. 190. 132. 31 SIP/2. 0 Via: SIP/2. 0/UDP 192. 190. 132. 20: 3456 Call-ID: a 2 e 3 a@192. 190. 132. 20 From: sip: mary@192. 190. 132. 20 To: sip: john@192. 190. 132. 31 Cseq 1 INVITE Content-type: application/sdp Content-Length: 98 John v=0 o=mary 3123 121231 IP IP 4 192. 190. 132. 20 c=IN IP 4 192. 190. 132. 20 m=audio 49170 RTP/AVP 0 192. 190. 132. 20 SIP/2. 0 200 OK v: SIP/2. 0/UDP 192. 190. 132. 20: 3456 i: a 2 e 3 a@192. 190. 132. 20 f: sip: mary@192. 190. 132. 20 t: sip: john@192. 190. 132. 31 Cseq 1 INVITE c: application/sdp l: 98 v=0 o=john 5664 456456 IP IP 4 192. 190. 132. 31 c=IN IP 4 192. 190. 132. 31 m=audio 23244 RTP/AVP 0 ACK sip: john@192. 190. 132. 31 SIP/2. 0 Via: SIP/2. 0/UDP 192. 190. 132. 20: 3456 Call-ID: a 2 e 3 a@192. 190. 132. 20 From: sip: mary@192. 190. 132. 20 To: sip: john@192. 190. 132. 31 Cseq 1 ACK 192. 190. 132. 31
Bye Details BYE sip: mary@192. 190. 132. 20 SIP/2. 0 v: SIP/2. 0/UDP 192. 190. 132. 31: 3456 i: a 2 e 3 a@192. 190. 132. 20 From: sip: john@192. 190. 132. 31 To: sip: mary@192. 190. 132. 20 Cseq 2 BYE 192. 190. 132. 20 SIP/2. 0 200 OK Via: SIP/2. 0/UDP 192. 190. 132. 31: 3456 Call-ID: a 2 e 3 a@192. 190. 132. 20 From: sip: john@192. 190. 132. 20 To: sip: mary@192. 190. 132. 31 Cseq 2 BYE 192. 190. 132. 31
状态码定义 l l l 1 xx Responses - Information Responses 2 xx Responses - Successful Responses 3 xx Responses - Redirection Responses 4 xx Responses - Request Failures Responses 5 xx Responses - Server Failure Responses 6 xx Responses - Global Failure Responses
Status Code(1 XX,2 XX,3 XX) Ø Informational 1 xx l l 100 Trying(尝试) 180 Ringing(振铃) 181 Call Is Being Forwarded(呼叫正被前转) Ø Successful 2 xx 请求成功,终止搜寻 l l 指示消息 200 OK(成功) Ø Redirection 3 xx 重定向 l 300 Multiple Choices(多个选择) 301 Moved Permanently(永久转移) 302 Moved Temporarily(临时转移) 305 Use Proxy(使用代理) 380 Alternative Service(可选的服务) l l
Status Code(4 XX) Ø Request Failure 4 xx (客户端请求失败) l 400 Bad Request(错误请求) 401 Unauthorized(未鉴权) 402 Payment Required(需要支付(付款)) 403 Forbidden(禁止) 404 Not Found(未找到) 405 Method Not Allowed(方式不允许) 406 Not Acceptable(不接受) 407 Proxy Authentication Required(需要代理验证) 486 Busy Here(本地忙) l l l l
Status Code(5 XX,6 XX) Ø Server Failure 5 xx(服务器失败 5 XX) l l 500 Server Internal Error(服务器内部错误) 501 Not Implemented(未实现) 502 Bad Gateway(错误的网关) 503 Service Unavailable(无效服务) 504 Gateway Time-out(网关超时) 505 Version Not Supported(不支持的版本) Ø Global Failure 6 xx l 600 Busy Everywhere(全忙) 603 Decline(拒绝) 604 Does Not Exist Anywhere(不存在) 606 Not Acceptable(不接受) l l l l
会话描述格式 Session Description b=* (bandwidth information) v=(protocol version) One or more time descriptions (see below) o=(owner/creator z=* (time zone adjustments) and session identifier). k=* (encryption key) s= (session name) a=* (zero or more session i=* (session information) attribute lines) u=* (URI of description) Zero or more media descriptions (see below) e=* (email address) p=* (phone number) c=*(connection information - not required if included in all media)
Sdp语法 l l l l l Time description t= (time the session is active) r=* (zero or more repeat times) Media description m= (media name and transport address) i=* (media title) c=* (connection information - optional if included at session-level) b=* (bandwidth information) k=* (encryption key) a=* (zero or more media attribute lines)
例子 v=0 版本是 0 o=mhandley 2890844526 2890842807 IN IP 4 126. 16. 64. 4 o=<username> <session id> <version> <network type> <address type><address> <session id> 取决于NTP(Network Time Protocol) <version> is increased when a modification is made s=SDP Seminar //只能有一个Session name i=A Seminar on the session description protocol 对于会话水平和媒体水平,都只能是一个i. u=http: //www. cs. ucl. ac. uk/staff/M. Handley/sdp. 03. ps //可选的,允许有多个URI e=mjh@isi. edu (Mark Handley) p=+44 -171 -380 -777 // Email&Phone, 可多选,也可不选。+表示国家代码; -表 示号码连接符 c=IN IP 4 224. 2. 17. 12/127/3 // Connection Data l // c=<network type> <address type> <connection address> l // IN stand for Internet //127 stand for TIME TO LIVE (range 0 -255) l //3表示后面连接的地址生命期是 127
b=12345678: 8 // b=<modifier>: <bandwidth-value>。可选项, modifier 是带宽的修饰语,带宽值的单位是kilobits/second t=2873397496 2873404696 // t=<start time> <stop time> 如果 stop time 为零,则会话无效;如果start time 为 0,则永久有效。注 意要写上start time 和 stop time,以防止防止意外。 K= uri: <202. 1. 2. 3> // Encryption Keys k=<method>: <encryption key> // 到URI指定的地址取密钥 a=recvonly // a=<attribute> m=audio 49170 RTP/AVP 0 // 可多选 m=<media> <port> <transport> <fmt list> // AVP=audio/video profile // <fmt list> 参考下页表 m=video 51372 RTP/AVP 31
Payload types for standard audio encoding Audio Encoding Payload type 1016 1 DVI 4 5, 6 G 721 2 G 722 9 G 728 15 GSM 3 L 16 10, 11 LPC 7 MPA 14 PCMA 8 PCMU 0
例子一:最简单的呼叫 Mary 192. 190. 132. 20 John INVITE john@192. 190. 132. 31 c=IN IP 4 192. 190. 132. 20 m=audio 49170 RTP/AVP 0 3 192. 190. 132. 31 John’s terminal rings 180 Ring 200 OK c=IN IP 4 192. 190. 132. 31 m=audio 12345 RTP/AVP 3 ACK GSM Stream BYE 200 OK Port 12345 The response indicates that John’s terminal can receive GSM data, on port 12345
例子三: 遇忙转移 Proxy User A User B 1 INVITE 100 Trying 468 Busy ACK INVITE 180 Ringing 200 OK ACK Both way RTP voice BYE 200 OK
12. SIP的继续学习方法 1. SIP协议原文(RFC 2543) 2. SIP协议的扩展(RFC 2976) 3. SIP的权威站点 4. 1)http: //www. ietf. org/html. charters/sip-charter. html(官方站 点) 5. 2) Http: //www. sipforum. com(最新应用) 6. 3) Http: //www. sinpcenter. com(最新应用) 7. 4) Http: //www. vovida. org(免费源代码组织) 8. 5) http: //www. cs. columbia. edu/~hgs/sip/(SIP的哥伦比亚大学老 家)
Contact me when you are troubled with SIP. It is my pleasure to discuss with you! Kermit
- Slides: 73