ผลต่างระหว่างรุ่นของ "Session Initiation Protocol"

เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
FujiwaraTomoyo (คุย | ส่วนร่วม)
เพิ่มแม่แบบ: เมสเซนเจอร์
Awksauce (คุย | ส่วนร่วม)
เก็บกวาด
บรรทัด 9:
[[โพรโทคอล]] SIP ถูกออกแบบมาคล้ายกับ[[โพรโทคอล]] HTTP ในส่วนของการร้องขอและการตอบรับ (request/response) ระหว่างลูกข่าย (client) ซึ่งเป็นผู้เริ่มต้นการเชื่อมต่อ โดยส่งการร้องขอ (request) การทำงานบางอย่างกับเครื่องแม่ข่าย (server) และ SIP ยังใช้ข้อมูล header, กฎการเข้ารหัส และหมายเลขสถานะ (status codes) เหมือนกับ HTTP อีกด้วย
 
ในการส่งสัญญาณมีเดีย SIP จะต้องทำงานร่วมกับ[[โพรโทคอล]]อื่นๆอื่น ๆ ในการส่งสัญญาณ แต่ SIP เท่านั้นที่จะถูกใช้เป็นตัวเริ่มต้นการสื่อสาร (communication session) โดยปกติ SIP ฝั่งลูกข่าย (client) จะใช้[[โพรโทคอล]] TCP หรือ UDP พอร์ตหมายเลข 5060 หรือ 5061 ในการเชื่อมต่อกับเครื่องแม่ข่าย (server) หรือ SIP endpoint โดยพอร์ตหมายเลข 5060 จะใช้ในการส่งสัญญาณแบบไม่เข้ารหัส (non-encrypted signaling traffic) ส่วนพอร์ตหมายเลข 5061 จะใช้ในกรณีที่มีการส่งสัญญาณแบบเข้ารหัส และจะทำงานร่วมกับ Transport Layer Security (TLS) อีกที โดยหลักๆหลัก ๆ แล้ว SIP จะทำหน้าที่ติดต่อหรือยกเลิกการส่งสัญญาณเสียงหรือภาพวิดีโอ ซึ่งในโปรแกรมประยุกต์หลายชนิดจะใช้ SIP ในการส่งข้อมูลมิเดียเช่น โปรแกรม instant messaging ที่สามารถส่งภาพและเสียงพร้อมกันได้ นอกจากนี้ยังมีเอกสารหลากหลายฉบับที่เกี่ยวข้องกับ SIP ซึ่งถูกประกาศโดย [[IETF]] เช่น Real-time Transport Protocol (RTP), Session Description Protocol (SDP) โดย SDP จะถูกใช้ร่วมกับ SIP สำหรับการทำข้อตกลง (negotiate) รูปแบบตัวแปรที่ใช้ในการเชื่อมต่อข้อมูลมิเดีย เช่น หมายเลขพอร์ต , [[โพรโทคอล]], การเข้ารหัสสัญญาณมิเดีย (codecs) โดยข้อมูลของ SDP เหล่านี้จะถูกส่งภายใต้ข้อมูลของ SIP packet body อีกที
 
เป้าหมายในการออกแบบ[[โพรโทคอล]] SIP ก็เพื่อใช้เป็นมาตรฐานในการเริ่มต้นการส่งสัญญาณโทรศัพท์ (signaling and call setup protocol) บนเครือข่ายแบบ IP-based และสามารถทำงานร่วมกับ public switched telephone network (PSTN) ที่มีอยู่เดิมได้ทันที และ SIP ถูกออกแบบมาโดยอ้างอิงถึงการเชื่อมต่อกันระว่าง proxy server และ user agents เพื่อให้มีลักษณะคล้ายกับการทำงานของโทรศัพท์มากที่สุด เช่น การส่งหมายเลข (dialing a number), การส่งสัญญาณกระดิ่ง (ringing), การส่งสัญญาญรอการเชื่อมต่อ (ring back) และการส่งสัญญาณสายไม่ว่าง (busy tone)
บรรทัด 27:
 
* Network Servers แบ่งออกเป็น 2 ชนิด
# Proxy server มี 2 ชนิดคือแบบ Stateful และ Stateless แบบ Stateful จะจำเซสชั่นการร้องขอของแต่ละไคล์เอนต์ที่กำลังรอการตอบกลับไว้และจะไม่ทำการส่งต่อการร้องขอซ้ำที่มาจากเซสชั่นที่เดิม ส่วน Stateless จะไม่มีการเก็บเซสชั่น ดังนั้นการร้องขอซ้ำจะถูกส่งต่อไปยังปลายทางทุกครั้งเพราะ Stateless จะไม่มีการจดจำว่าเคยส่งไปแล้วหรือยัง โดยทั้งสองแบบจะทำหน้าเป็นทั้ง UAC และ UAS ที่ทำหน้าที่รับและส่งต่อ SIP Message ของไคลเอนต์ไปยังเครื่องแม่ข่ายอื่นๆอื่น ๆ โดย Proxy server จะส่งข้อมูลในนามของไคลเอนต์ แต่จะมีการเปลี่ยนแปลงข้อมูลผู้ส่งใน SIP Header จากที่อยู่ของไคลเอนต์เป็นที่อยู่ของ Proxy server แทน และเครื่องแม่ข่ายปลายทางจะติดต่อกับไคลเอนต์ผ่าน Proxy server อีกทีหนึ่ง
# Redirect server จะทำหน้าที่รับ SIP request จากไคลเอนต์ จากนั้นจะส่งผลลัพธ์เป็นที่อยู่ของเครื่องแม่ข่ายถัดไปไปยังเครื่องไคลเอนต์ โดยที่ Redirect server จะไม่มีการส่งต่อข้อมูล SIP messages ไปยังเครื่องแม่ข่ายอื่นๆอื่น ๆ เหมือน Proxy server
 
* การกำหนดที่อยู่ของผู้รับและผู้ส่ง (Addressing) SIP จะระบุที่อยู่ของผู้รับและผู้ส่งในรูปแบบของ SIP URLs (SIP Universal Resource Locators) โดยจะอยู่ในรูปแบบ sip:ชื่อยูสเซอร์@ที่อยู่เครื่อง ตัวอย่างเช่น sip:john@example.com, sip:6680001@111.11.11.1 เป็นต้น
 
 
== ตัวอย่าง SIP's Call flow ==
 
 
* แบบ Point to Point
 
Alice Bob
| |
| |
| 1. INVITE |
|- ---------------------->|
| 2. 180 Ringing |
| |<-----------------------|
| |
| |
| 3. 200 OK |
| |<-----------------------|
| 4. ACK |
|- ---------------------->|
| RTP Media |
| |<============>|
| |
| |
| 5. BYE |
| |<----------------------- |
| 6. 200 OK |
|- ----------------------> |
| |
| |
 
 
* แบบ Via Proxy server โทรจาก John's Soft phone ไปยัง Bob's SIP Phone โดยที่ John's Soft phone ส่งข้อมูลผ่าน Proxy server ที่ชื่อ site-a.com ส่วน Bob's SIP Phone ส่งข้อมูลผ่าน Proxy server ที่ชื่อ site-b.com
 
site-a.com............site-b.com
 
. proxy proxy .
site-a.com............site-b.com
. .
. proxy proxy .
John's .......................................................... Bob's
. .
softphone SIP Phone
John's .......................................................... Bob's
| | | |
softphone SIP Phone
John | 1. INVITE | | |
| | | |
เริ่มต้นโทรออก |-----------------> | 2. INVITE | |
John | 1. INVITE | | |
| 3. 100 เริ่มต้นโทรออก Trying |-----------------> | 24. INVITE | |
| <---------------- | 35. 100 Trying |----------------> | 4. INVITE |
| |<---------------- | 56. 100180 TryingRinging |----------------> |Bob
John | | 7. 180 Ringing |<---------------- | ได้ยินสัญญาณโทรเข้า
| |<-------------- | 6. 180 Ringing | Bob
ได้ยิน Ringback John tone | | 78. 180 Ringing |<---------------- | |9. ได้ยินสัญญาณโทรเข้า200 OK |
หรือ Music ได้ยิน Ringback tone | 8. 180 Ringing on hold |<--------------- | 910. 200 OK |<--------------- | Bob |รับสาย
หรือ Music on hold |<--------------- | 1011. 200 OK |<--------------- | | Bob รับสาย
| 11. 200 OK |<--------------- | | |
| 12. ACK F12 |
|<--------------- | | |
|- -------------------------------------------------------> |
| 12. ACK F12 |
| RTP Media Session |
|--------------------------------------------------------> |
สนทนา |<==============================> | สนทนา
| RTP Media Session |
| 13. BYE |
สนทนา |<==============================> | สนทนา
| |<-------------------------------------------------------- | Bob วางหู
| 13. BYE |
| 14. 200 OK |
|<-------------------------------------------------------- | Bob วางหู
John วางหู |--------------------------------------------------------> |
| 14. 200 OK |
| |
John วางหู |--------------------------------------------------------> |
| |
 
 
== ตัวอย่าง SIP Request ==
 
INVITE sip:junk@realm SIP/2.0
Route: <sip:192.168.0.79;lr>
Via: SIP/2.0/UDP 192.168.0.200:5060;branch=z9hG4bKrfpISNp7Z6jqn
From: sip:original@192.168.0.79;tag=aEJISW8Nwm
To: sip:junk@realm
Supported: 100rel, sec-agree
Contact: sip:original@192.168.0.200
CSeq: 5714 INVITE
Call-ID: 34VISPImLSPTBk0OgCZ3lgbCyjup48
s: subject
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: 157
v=0
o=original 3326093141 3326093142 IN IP4 192.168.0.200
s=SipSession
c=IN IP4 192.168.0.200
t=0 0
m=application 49152 TCP Chipflip
a=direction:both
 
 
 
== รายละเอียดของ SIP Messages ==
เส้น 137 ⟶ 130:
! Code !! Description !! References
|-
| 200 || OK. ||
|-
| 202 || Accepted. || RFC 3265
|-
| 204 || No Notification. ||
|}
 
เส้น 152 ⟶ 145:
| 300 || Multiple choices. || RFC 3261
|-
| 301 || Moved permanently. ||
|-
| 302 || Moved temporarily. ||
|-
| 305 || Use proxy. ||
|-
| 380 || Alternative service. ||
|}
 
เส้น 167 ⟶ 160:
! Code !! Description !! References
|-
| 400 || Bad request. ||
|-
| 401 || Unauthorized. ||
|-
| 402 || Payment required. ||
|-
| 403 || Forbidden. ||
|-
| 404 || Not found. ||
|-
| 405 || Bad request. ||
|-
| 406 || Not acceptable. ||
|-
| 407 || Proxy authentication required. ||
|-
| 408 || Request timeout. ||
|-
| 410 || Gone. ||
|-
| 412 || Conditional request failed. || RFC 3903
|-
| 413 || Request entity too large. ||
|-
| 414 || Request-URI too long. ||
|-
| 415 || Unsupported media type. ||
|-
| 416 || Unsupported URI scheme. ||
|-
| 417 || Unknown Resource-Priority. || RFC 4412
|-
| 420 || Bad extension. ||
|-
| 421 || Extension required. ||
|-
| 422 || Session Interval too small. || RFC 4028
|-
| 423 || Interval too brief. ||
|-
| 428 || Use Identity Header. || RFC 4474
เส้น 225 ⟶ 218:
| 470 || Consent needed. || RFC 5360
|-
| 480 || Temporarily unavailable. ||
|-
| 481 || Call/Transaction does not exist. ||
|-
| 482 || Loop detected. ||
|-
| 483 || Too many hops. ||
|-
| 484 || Address incomplete. ||
|-
| 485 || Ambiguous. ||
|-
| 486 || Busy here. ||
|-
| 487 || Request terminated. ||
|-
| 488 || Not acceptable here. ||
|-
| 489 || Bad event. || RFC 3265
|-
| 491 || Request pending. ||
|-
| 493 || Undecipherable. ||
|-
| 494 || Security agreement required. || RFC 3329
|}
 
 
5xx: การตอบกลับข้อผิดพลาดที่เกิดจากเครื่องแม่ข่าย (Server error)
เส้น 261 ⟶ 253:
| 500 || Server internal error. || RFC 3261
|-
| 501 || Not implemented. ||
|-
| 502 || Bad gateway. ||
|-
| 503 || Service unavailable. || RFC 3261
|-
| 504 || Server timeout. ||
|-
| 505 || Version not supported. ||
|-
| 513 || Message too large. ||
|-
| 580 || Precondition Failure. || RFC 3312
เส้น 282 ⟶ 274:
! Code !! Description !! References
|-
| 600 || Busy everywhere. ||
|-
| 603 || Decline. ||
|-
| 604 || Does not exist anywhere. ||
|-
| 606 || Not acceptable. ||
|}
 
== ตัวอย่างภาษา Perl ==
 
use Net::SIP;
# #create new agent
my $ua = Net::SIP::Simple->new (
outgoing_proxy => '192.168.0.10',
registrar => '192.168.0.10',
domain => 'example.com',
from => 'me',
auth => [ 'me', 'secret' ], );
# #Register agent
$ua->register;
# #Invite other party, send anncouncement once connected
$ua->invite ( 'you',
init_media => $ua->rtp ( 'send_recv', 'announcement.pcmu-8000' ),
asymetric_rtp => 1, );
# #Mainloop
$ua->loop;
 
{{เมสเซนเจอร์}}