SIP常用消息实例参考 1、REGISTER消息

1、REGISTER消息

       1)头字段填写说明
       Call-id:                 必选
       Cseq:                   必选
       From:                   必选
       To:                       必选
       Max-Forwards: 必选
       Via:                      必选
       Contact:              必选
       Authorization:   必选
       Expires:               常用可选头
       2)非鉴权注册消息实例
       在该实例中192.168.2.161机器发送注册消息给192.168.2.89服务器,发送消息实例如下:

REGISTER sip: 192.168 . 2.89  SIP / 2.0
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 10586
Max - Forwards:  70
From < sip: 01062237496 @192 . 168.2 . 89 > ;tag = ca04c1391af3429491f2c4dfbe5e1b2e;epid = 4f2e395931
To < sip: 01062237496 @192 . 168.2 . 89 >
Call
- ID: da56b0fab5c54398b16c0d9f9c0ffcf2 @192 . 168.2 . 161
CSeq: 
1  REGISTER
Contact: 
< sip: 192.168 . 2.161 : 10586 > ;methods = "INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER"
User - Agent: RTC / 1.2 . 4949  (BOL SIP Phone  1005 )
Event: registration
Allow
- Events: presence
Content
- Length:  0
      当注册成功(回送200 OK)时,服务器发送的res消息参考如下:
SIP / 2.0   200  OK
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 10586
From < sip: 01062237496 @192 . 168.2 . 89 > ;tag = ca04c1391af3429491f2c4dfbe5e1b2e;epid = 4f2e395931
To < sip: 01062237496 @192 . 168.2 . 89 > ;tag =- 00834 - 14d0805b62bc026d
Call
- ID: da56b0fab5c54398b16c0d9f9c0ffcf2 @192 . 168.2 . 161
CSeq: 
1  REGISTER
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,
UPDATE ,PRACK,REFER,SUBSCRIBE,NOTIFY,MESSAGE
Contact: sip:
192.168 . 2.161 : 10586
Content
- Length:  0
Expires: 
3600
       3)鉴权注册消息实例
       当需要鉴权注册时,当请求端192.168.2.161使用BOL或xlite等发送注册消息给192.168.2.89服务器时,服务器对192.168.2.161发送“401 Unauthorized”信息给请求端,提示请求段需要带上鉴权信息重新注册,请求端带上鉴权信息后(带有“Authorization”头字段)重新向服务器注册,服务器验证鉴权头的正确性,如果鉴权成功,给请求端发送200 OK消息。若失败,继续发送401消息。
       第一步:请求端(192.168.2.161)发送REGISTER消息,参考消息如下:
REGISTER sip: 192.168 . 2.89  SIP / 2.0
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 8021
Max - Forwards:  70
From < sip: 01062237493 @192 . 168.2 . 89 > ;tag = efca469543ce4788a6a6a2c7b66cd01f;epid = de4504430d
To < sip: 01062237493 @192 . 168.2 . 89 >
Call
- ID: c88a247a74b54a8c9e676bdde3bba6c9 @192 . 168.2 . 161
CSeq: 
1  REGISTER
Contact: 
< sip: 192.168 . 2.161 : 8021 > ;methods = "INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER"
User - Agent: RTC / 1.2 . 4949  (BOL SIP Phone  1005 )
Event: registration
Allow
- Events: presence
Content
- Length:  0
     第二步:服务器端(192.168.2.89)检查到需要鉴权,给请求端发送401结果码,并带上“WWW-Authenticate”头信息,参考消息如下:
SIP / 2.0   401  Unauthorized
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 8021
From < sip: 01062237493 @192 . 168.2 . 89 > ;tag = efca469543ce4788a6a6a2c7b66cd01f;epid = de4504430d
To < sip: 01062237493 @192 . 168.2 . 89 > ;tag =- 001893 - 38ba013ba3dde36e
Call
- ID: c88a247a74b54a8c9e676bdde3bba6c9 @192 . 168.2 . 161
CSeq: 
1  REGISTER
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,
UPDATE ,PRACK,REFER,SUBSCRIBE,NOTIFY,MESSAGE
Contact: 
< sip: 192.168 . 2.89 : 14010 >
Content
- Length:  0
WWW
- Authenticate: Digest realm = " 192.168 . 2.89 ", qop = "auth", nonce = "e17d377c3d2d9c343e26576a7fd04738481dfc10", opaque = "", stale = FALSE, algorithm = MD5
      第三步:请求端(192.168.2.161)通过“Authorization”头字段带上鉴权头信息,发送一个新的REGISTER消息,参考消息如下:
REGISTER sip: 192.168 . 2.89  SIP / 2.0
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 8021
Max - Forwards:  70
From < sip: 01062237493 @192 . 168.2 . 89 > ;tag = efca469543ce4788a6a6a2c7b66cd01f;epid = de4504430d
To < sip: 01062237493 @192 . 168.2 . 89 >
Call
- ID: c88a247a74b54a8c9e676bdde3bba6c9 @192 . 168.2 . 161
CSeq: 
2  REGISTER
Contact: 
< sip: 192.168 . 2.161 : 8021 > ;methods = "INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER"
User - Agent: RTC / 1.2 . 4949  (BOL SIP Phone  1005 )
Authorization : Digest username = " 01062237493 ", realm = " 192.168 . 2.89 ", qop = auth, algorithm = MD5, uri = "sip: 192.168 . 2.89 ", nonce = "e17d377c3d2d9c343e26576a7fd04738481dfc10", nc = 00000001 , cnonce = " 12660455546344082314666316435946 ", response = "f57e47ce03162293b9ced07362ce2b79"
Event: registration
Allow
- Events: presence
Content
- Length:  0
      第四步:服务器端(192.168.2.89)验证鉴权信息的合法性,若验证成功,发送200 OK消息,参考消息如下:
SIP / 2.0   200  OK
Via: SIP
/ 2.0 / UDP  192.168 . 2.161 : 8021
From < sip: 01062237493 @192 . 168.2 . 89 > ;tag = efca469543ce4788a6a6a2c7b66cd01f;epid = de4504430d
To < sip: 01062237493 @192 . 168.2 . 89 > ;tag =- 001894 - a5eb977c8969aa51
Call
- ID: c88a247a74b54a8c9e676bdde3bba6c9 @192 . 168.2 . 161
CSeq: 
2  REGISTER
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,
UPDATE ,PRACK,REFER,SUBSCRIBE,NOTIFY,MESSAGE
Contact: sip:
192.168 . 2.161 : 8021
Content
- Length:  0
Expires: 
3600

你可能感兴趣的:(SIP协议)