SIP Intro 第三部...
最近還是忙,但還是先起個頭,這一部想介紹Registration,也是一樣從例子開始入手,再一一其內容、結構與流程,因為有了一、二部的基礎,我想在這一部會開始往旁邊發展,也就是說會牽扯比較多一點的東西。
ps.實在對一些網誌高手不好意思,本人第一次寫,而且向來超不會寫文章...還請多多指教、包含!
下面是之前的SIP Intro 一二部,有興趣的可以參考!
SIP Intro --- 第一部SIP Intro --- 第二部(part 1)SIP Intro --- 第二部(part 2)SIP Intro --- 第二部 (part 3)進入正題!
為何要REGISTER呢? 因為若不向SIP server註冊,那別人怎麼能知道你在哪裡,又怎麼跟妳通訊呢? 所以我們每個User都要向SIP server至少註冊一個號碼,如此,當別人要跟這個號碼做通訊時,才找的到位置。
而一筆(號碼)註冊的資訊,我們又稱之為Address of Record,裡面包含了IP、號碼等等資訊。而註冊的流程有如何呢?以下先來看一個例子,下面這個例子是在表示一個user要註冊一筆新的資訊的流程。
Bob SIP Server
| |
| REGISTER F1 | (向SIP server發送一個註冊的Msg)
|-------------------->|
| 401 Unauthorized F2 | (SIP server會要求認證)
|<--------------------|
| REGISTER F3 | (重新發送一次,並加入認證資訊)
|-------------------->|
| 200 OK F4 | (若成功,則會回OK給user)
|<--------------------|
| |
F1 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob ;tag=a73kszlfl
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Contact:
Content-Length: 0
第一個packet裡
F2 401 Unauthorized SIP Server -> Bob
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
;received=192.0.2.201
From: Bob ;tag=a73kszlfl
To: Bob ;tag=1410948204
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="atlanta.example.com",qop="auth",nonce="ea9c8e88df84f1cec4341ae6cbe5a359",opaque="",stale=FALSE,algorithm=MD5
Content-Length: 0
F3 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashd92
Max-Forwards: 70
From: Bob ;tag=ja743ks76zlflH
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 2 REGISTER
Contact:
Authorization: Digest username="bob",realm="atlanta.example.com",nonce="ea9c8e88df84f1cec4341ae6cbe5a359", opaque="",uri="sips:ss2.biloxi.example.com",response="dfe56131d1958046689d83306477ecc"
Content-Length: 0
F4 200 OK SIP Server -> Bob
SIP/2.0 200 OK
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashd92 ;received=192.0.2.201
From: Bob ;tag=ja743ks76zlflH
To: Bob ;tag=37GkEhwl6
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 2 REGISTER
Contact: ;expires=3600
Content-Length: 0
下一個例子,是在表示user想要對他註冊的Address of Record做更新的operation。
Bob SIP Server
| |
| REGISTER F1 |
|------------------------------>|
| 200 OK F2 |
|<------------------------------|
| |
F1 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob ;tag=a73kszlfl
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Contact: mailto:bob@biloxi.example.com
Authorization: Digest username="bob",realm="atlanta.example.com",qop="auth", nonce="1cec4341ae6cbe5a359ea9c8e88df84f",opaque="",uri="sips:ss2.iloxi.example.com", response="71ba27c64bd01de719686aa4590d5824"
Content-Length: 0
F2 200 OK SIP Server -> Bob
SIP/2.0 200 OK
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7;received=192.0.2.201
From: Bob ;tag=a73kszlfl
To: Bob ;tag=34095828jh
再來這個例子是user要求現有的註冊資訊。
Bob SIP Server
| |
| REGISTER F1 |
|------------------------------>|
| 200 OK F2 |
|<------------------------------|
| |
F1 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob ;tag=a73kszlfl
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Authorization: Digest username="bob",realm="atlanta.example.com",nonce="df84f1cec4341ae6cbe5ap359a9c8e88",opaque="",uri="sips:ss2.biloxi.example.com",response="aa7ab4678258377c6f7d4be6087e2f60"
Content-Length: 0
F2 200 OK SIP Server -> Bob
SIP/2.0 200 OK
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7;received=192.0.2.201
接下來這個例子是取消註冊。
Bob SIP Server
| |
| REGISTER F1 |
|------------------------------>|
| 200 OK F2 |
|<------------------------------|
| |
F1 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob ;tag=a73kszlfl
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Expires: 0
Contact: *
Authorization: Digest username="bob", realm="atlanta.example.com",nonce="88df84f1cac4341aea9c8ee6cbe5a359", opaque="",uri="sips:ss2.biloxi.example.com",response="ff0437c51696f9a76244f0cf1dbabbea"
Content-Length: 0
F2 200 OK SIP Server -> Bob
SIP/2.0 200 OK
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7;received=192.0.2.201
From: Bob ;tag=a73kszlfl
To: Bob ;tag=1418nmdsrf
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Content-Length: 0
最後是ㄧ個註冊不成功的例子,這只是其中之一,因為不成功的可能原因太多了,所以只列一個。
Bob SIP Server
| |
| REGISTER F1 |
|------------------------------>|
| 401 Unauthorized F2 |
|<------------------------------|
| REGISTER F3 |
|------------------------------>|
| 401 Unauthorized F4 |
|<------------------------------|
| |
F1 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7;received=192.0.2.201
From: Bob ;tag=a73kszlfl
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Contact:
Content-Length: 0
F2 Unauthorized SIP Server -> Bob
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7;received=192.0.2.201
From: Bob ;tag=a73kszlfl
To: Bob ;tag=1410948204
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="atlanta.example.com", qop="auth",nonce="f1cec4341ae6ca9c8e88df84be55a359", opaque="", stale=FALSE, algorithm=MD5
Content-Length: 0
F3 REGISTER Bob -> SIP Server
REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashd92
Max-Forwards: 70
From: Bob ;tag=JueHGuidj28dfga
To: Bob
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 2 REGISTER
Contact:
Authorization: Digest username="bob", realm="atlanta.example.com",nonce="f1cec4341ae6ca9c8e88df84be55a359", opaque="",
uri="sips:ss2.biloxi.example.com",
response="61f8470ceb87d7ebf508220214ed438b"
Content-Length: 0
F4 401 Unauthorized SIP Server -> Bob
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashd92;received=192.0.2.201
From: Bob ;tag=JueHGuidj28dfga
To: Bob ;tag=1410948204
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="atlanta.example.com", qop="auth",nonce="84f1c1ae6cbe5ua9c8e88dfa3ecm3459",opaque="", stale=FALSE, algorithm=MD5
Content-Length: 0