天天看點

SIP協定&開源SIP伺服器搭建和用戶端安裝1. SIP 2 開源SIP伺服器和用戶端

SIP 是一個應用層的控制協定,可以用來建立,修改,和終止多媒體會話,例如Internet電話

SIP在建立和維持終止多媒體會話協定上,支援五個方面:

1)   使用者定位: 檢查終端使用者的位置,用于通訊。

2)   使用者有效性:檢查使用者參與會話的意願程度。

3)   使用者能力:檢查媒體和媒體的參數。

4)   建立會話: “ringing”,建立會話參數在呼叫方和被叫方。

5)       會話管理:包括發送和終止會話,修改會話參數,激活服務等等。

使用者代理:SIP使用者代理是一個SIP邏輯網絡端點,用于建立、發送、接收SIP消息并管理一個SIP會話

代理伺服器:SIP代理伺服器(PROXY)在網絡上位于SIP UAC和UAS之間,用于幫助UAC和UAS間的消息路由

注冊伺服器:SIP注冊伺服器用于接收SIP注冊請求,并儲存發送注冊請求的UA的位置資訊

重定向伺服器:SIP 重定向伺服器允許 SIP 代理伺服器将 SIP 會話邀請資訊定向到外部域

1.       使用者首次試呼時,終端代理A向代理伺服器發送REGISTER 注冊請求。

2.       代理伺服器通過後端認證/計費中心獲知使用者資訊不在資料庫中,便向終端代理回送401Unauthorized 質詢資訊,其中包含安全認證所需的令牌。

3.       終端代理提示使用者輸入其辨別和密碼後,根據安全認證令牌将其加密後,再次用REGISTER 消息報告給代理伺服器。

4.       代理伺服器将REGISTER消息中的使用者資訊解密,通過認證/計費中心驗證其合法後,     将該使用者資訊登記到資料庫中,并向終端代理A 傳回成功響應消息200 OK。

1.       終端向代理伺服器送Register消息登出,其頭中expire 字段置0。

2.       代理伺服器收到後回送200OK 響應,并将資料庫中的使用者有關資訊登出。

1.       使用者摘機發起一路呼叫,終端代理A 向該區域的代理伺服器發起Invite 請求。

2.       代理伺服器通過認證/計費中心确認使用者認證已認證後,檢查請求消息中的Via 頭域中是否已包含其位址。若已包含,說明發生環回,傳回訓示錯誤的應答。如果沒有問題,代理伺服器在請求消息的Via 頭域插入自身位址,并向Invite 消息的To 域所訓示的被叫終端代理B 轉送Invite 請求。

3.       代理伺服器向終端代理A 送呼叫進行中的應答消息,100 Trying。

4.       終端代理B 向代理伺服器送呼叫進行中的應答消息,100 Trying;

5.       終端代理B 訓示被叫使用者振鈴,使用者振鈴後,向代理伺服器發送180 Ringing 振鈴資訊。

6.       代理伺服器向終端代理A 轉發被叫使用者振鈴資訊。

7.       被叫使用者摘機,終端代理B 向代理伺服器傳回表示連接配接成功的應答(200 OK)。

8.       代理伺服器向終端代理A 轉發該成功訓示(200 OK)。

9.       終端代理A 收到消息後,向代理伺服器發ACK 消息進行确認。

10.   代理伺服器将ACK 确認消息轉發給終端代理B。

11.   主被叫使用者之間建立通信連接配接,開始通話。

1.       使用者通話結束後,被叫使用者挂機,終端代理B 向代理伺服器發送Bye 消息。

2.       代理伺服器轉發Bye 消息至終端代理A,同時向認證/計費中心送使用者通話的詳細資訊,請求計費。

3.       主叫使用者挂機後,終端代理A向代理伺服器發送确認挂斷響應消息200 OK。

4.       代理伺服器轉發響應消息200OK。

1.       使用者A 發起一路呼叫,終端代理A 向代理伺服器發Invite 請求消息。

2.       代理伺服器向被叫使用者的終端代理B 轉發該Invite 請求。

3.       代理伺服器向終端代理A 回送100 Trying 響應,表示呼叫已在進行中。

4.       終端代理B向代理伺服器回送100 Trying,告知代理伺服器呼叫正在處理。

5.       被叫使用者振鈴,終端代理B 向代理伺服器送180 Ring 響應。

6.       代理伺服器向終端代理A 轉發該響應消息。

7.       被叫久振鈴無應答,終端代理A判斷逾時後,向代理伺服器送Cancel 消息放棄該呼叫。

8.       代理伺服器收到Cancel消息後,向終端代理A 回送200 OK 響應。

9.       代理伺服器将Cancel 消息轉發給終端代理B。

10.   終端代理B 向代理伺服器回送200 OK 響應。

11.   終端代理B 向代理伺服器送487 請求已撤銷的響應消息。

12.   代理伺服器收到後回送ACK确認。

13.   代理伺服器向終端代理A 送487 請求已撤銷消息。

14.   終端代理A 向代理伺服器回送ACK 确認。

7.       被叫久振鈴無應答,終端代理B判斷逾時後,向代理伺服器送408 Request timeout 消息放棄該呼叫。

8.       代理伺服器收到408Request timeout 消息後,轉發該消息給終端代理A。

9.       代理伺服器收到後回送ACK确認給終端代理B。

10.   終端代理A 向代理伺服器回送ACK 确認。

1)       proxy會檢查Request-URI。如果它指向的是本proxy所負責的區域,那麼proxy會用位置服務的結果來替換這個URI。否則,proxy不改變這個URI。

2)       proxy會檢查Route頭域的最上URI。如果這個URI指向這個proxy,這個proxy從Route頭域中移除(這個路由節點已經到達)。

3)       proxy會轉發請求到最上的Route頭域值所标志的URI,或者Request-URI(如果沒有Route頭域)。

本例子是一個基本的SIP四邊傳送,U1->P1->P2->U2,使用proxy來傳送。下邊是過程。

U1 發送:

INVITE sip:[email protected] SIP/2.0

Contact: sip:[email protected]

發給P1,P1是一個外發的proxy。P1并不管轄domain.com,是以它查找DNS并且發送請求到那裡。它也增加一個Record-Route頭域值:

Record-Route: <sip:p1.example.com;lr>

P2收到這個請求。這是domain.com是以它查找位置伺服器并且重寫Request-URI。它也增加一個Record-Route頭域值。請求中沒有Route頭域,是以它解析一個新的Request-URI來決定把請求發送到哪裡。

INVITE sip:[email protected] SIP/2.0

Record-Route: <sip:p2.domain.com; lr>

在u2.domain.com的被叫方接收到這個請求并且傳回一個200OK應答:

SIP/2.0 200 OK

Contact: sip: [email protected]

Record-Route: <sip:p2.domain.com;lr>

u2的被叫方并且設定對話的狀态的remote target URI為:

sip: [email protected]并且它的路由集合是:

(<sip:p2.domain.com;lr>,<sip:p1.example.com;lr>)

這個轉發通過P2到P1到U1。現在U1設定它自己的對話狀态的remote target URI為:sip:[email protected]并且它的路由集合是:

(<sip:p1.example.com;lr>,<sip:p2.domain.com;lr>)

由于所有的路由集合元素都包含了lr參數,那麼U1構造最後的BYE請求:

BYE sip:[email protected] SIP/2.0

Route:<sip:p1.example.com;lr>,<sip:p2.domain.com;lr>

就像其他所有的節點(包括proxy)會做的那樣,它會使用DNS來解析最上的Route頭域的URI值,這樣來決定往哪裡發送這個請求。這就發到了P1。P1發現Request-URI中标記的URI不是它負責的域,于是它就不改變這個Request-URI。然後看到它是Route頭域的第一個值,于是就從Route頭域中移去,并且轉發這個請求到P2:

Route: <sip:p2.domain.com;lr>

P2也發現它自己并非負責這個Request-URI的域(P2負責的是domain.com并非u2.domain.com),于是P2并不改變它。它看到自己在Route的第一個值,于是移去這個,并且向u2.domain.com轉發(根據在Request-URI上查找DNS):

在這裡例子中,U1和U2是在不同的私有域空間中,并且他們通過proxy P1開始一個對話,這個P1作為不同私有namespace的一個網關存在。

U1->P1->U2

U1發送:

INVITE sip:[email protected]/2.0

Contact:<sip:[email protected]>

P1使用自己的定位服務并且發送下邊的資訊到U2:

INVITE sip:[email protected]/2.0

Record-Route:<sip:gateway.rightprivatespace.com;lr>

U2發送200 OK應答回給P1:

Contact:<sip:[email protected]>

P1重寫它的Record-Route頭域參數,提供成為U1能夠使用的參數,并且發送給P1:

Record-Route: <sip:gateway.leftprivatespace.com;lr>

稍後,U1發送接下來的BYE到P1:

BYE sip:[email protected]/2.0

Route:<sip:gateway.leftprivatespace.com;lr>

P1轉發到U2:

BYE sip:[email protected]/2.0

1)       Asterisk

2)       Cipango

3)       FreeSWITCH

4)       GNU SIP Witch

5)       Mobicents

6)       Mysipswitch

7)       OpenSER

8)       OpenSIPS

9)       SSailFin

10)   SIP Express Router sipX

11)   Yate

12)   YXA

1)       Blink

2)       Ekiga

3)       Empathy

4)       Jitsi

5)       KPhone

6)       Linphone

7)       MicroSIP

8)       PhoneGaim

9)       QuteCom

10)   SFLphone

11)   Telephone

12)   Twinkle

13)   Yate client

程式設計語言

作業系統

許可協定

功能

Asterisk

C

跨平台

GNU GPL/Proprietary

Voice mail

Conference calling

Interactive voice response

automatic call distribution

Cipango

Java

Apache 2.0

Free Switch

MPL

會議,使用XML-RPC 控制呼叫,Interactive voice response (IVR), TTS/ASR (語音合成和語音識别), Public switched telephone network (PSTN) 接口,可連接配接模拟和數字中繼,VoIP 協定包括 SIP,SCCP, H.323, XMPP, GoogleTalk, t.38 等等

GNU SIP Witch

C++

GPL

Call forwarding, call distribution, call hold, presence information and (text) messages, supports encrypted calls and also enables NAT traversal to establish the peer-to-peer connections.

Mobicents

LGPL

Mysipswitch

C#

BSD

SIP account creation

Setting up a customized dial plan

Setting up 3rd party SIP Registrations

SIP traffic forwarding

SIP Accounts activity monitoring via the website

SIP traffic monitoring via telnet

Online switchboard: call hold/resume, call transfer/forward, call hangup

Usual security features

Click to Call (Beta)

Possibility to run it on a local computer

Multiple call forwarding

RUBY Dial plans

ENUM Lookup

Opensip

Linux, FreeBSD, Solaris

GNU GPL

SIP registrar server

SIP router / proxy (lcr, dynamic routing, dialplan features)

SIP redirect server

SIP presence agent

SIP back-to-back User Agent

SIP IM server (chat and end-2-end IM)

SIP to SMS gateway (bidirectional)

SIP to XMPP gateway for presence and IM (bidirectional)

SIP load-balancer or dispatcher

SIP front end for gateways/asterisk

SIP NAT traversal unit

SIP application server

SailFin

Cross-platform

SIP Express Router

Linux, BSD, Solaris

RFC 3261 functionality, a variety of database backends (mysql, oracle, postgres, radius, text-db), management features (remote management via XML-RPC, load-balancing), NATi traversal, telephony features (LCR, speeddial), multidomain hosting, ENUM, presence, and even more

sipX

Fedora CentOS RHEL

Affero General Public License

traditional private branch exchange (PBX) like voice mail, interactive voice response systems, auto attendants and the like. Furthermore it integrates with Exchange 2007and Active Directory Environments.

Yate

GNU General Public License with linking exception

VoIP server

SS7 switch

VoIP client

Jabber server

Jabber client

Conference server - with up to 200 voice channels in a single conference

VoIP to PSTN gateway

PC2Phone and Phone2PC gateway

IP Telephony server and/or client

H.323 gatekeeper

H.323 multiple endpoint server

H.323<->SIP Proxy

SIP session border controller

SIP router

SIP registration server

IAX server and/or client

Jingle client or server

MGCP server (Call Agent)

ISDN passive and active recorder

ISDN, RBS, analog passive recorder

Call center server

IVR engine

Prepaid and/or postpaid cards system

YXA

Erlang

New BSD license

名稱

Blink

Python

Mac OS X, Windows and Linux

OSX Integration (iCloud, iTunes, Address Book, Keychain, Voice Over)

iCloud synchronization for accounts

History menu for outgoing and incoming calls

History browser

System Address Book external plugin (can dial with Blink from Address Book)

Answering machine

Call transfer

Call recording

LDAP directory

Launch external application on incoming calls

Phone number translations

Ekiga

C C++

Unix-like, Windows

GNU General Public License

Call forwarding on busy, no answer, always (SIP and H.323)

Call transfer (SIP and H.323)

Call hold (SIP and H.323)

DTMF support (SIP and H.323)

Basic instant messaging (SIP)

Text chat (SIP and H.323)

Register with several registrars (SIP) and gatekeepers (H.323) simultaneously

Ability to use an outbound proxy (SIP) or a gateway (H.323)

Message waiting indications (SIP)

Audio and video (SIP and H.323)

STUN support (SIP and H.323)

LDAP support

Audio codec algorithms: iLBC, GSM 06.10, MS-GSM, G.711 A-law, G.711 µ-law, G.726, G.721, Speex, G.722, CELT (also G.723.1, G.728, G.729, GSM 06.10, GSM-AMR, G.722.2 [GSM‑AMR-WB] using Intel IPP)

Video codec algorithms: H.261, H.263+, H.264, Theora, MPEG-4

Empathy

BSD, Linux, Other Unix-like

ulti-protocol: Google Talk (Jabber/XMPP), MSN, IRC, Salut, AIM, Facebook, Yahoo!, Gadu Gadu, Groupwise, ICQ and QQ. (Supported protocols depend on installed Telepathy Connection Manager components.) Supports all protocols supported by Pidgin.

File transfer for XMPP, and local networks.

Voice and video call using SIP, XMPP and Google Talk.

Some IRC support.

For detailed list of supported protocol features see here

Conversation theming (see list of supported Adium themes).

Sharing and viewing location information.

Private and group chat (with smileys and spell checking).

Conversation logging.

Automatic away and extended away presence.

Automatic reconnection using Network Manager.

Python bindings for libempathy and libempathy-gtk

Support for collaborative applications (“tubes”).

Jitsi

Linux, Mac OS X, Windows (all Java supported)

Attended and blind call transfer

Auto away

Auto re-connect

Auto answer and Auto Forward

Call encryption with SRTP and ZRTP

Conference calls

Direct media connection establishment with the ICE protocol

Desktop Streaming

Encrypted password storage using a master password

File transfer for XMPP, AIM/ICQ, Windows Live Messenger, YIM

Instant messaging encryption with OTR

IPv6 support for SIP and XMPP

Media relaying with the TURN protocol

Message Waiting Indication (RFC 3842)

Voice and video calls for SIP and XMPP using H.264 and H.263 or VP8 for video encoding

Wideband audio with SILK, G.722, Speex and Opus

DTMF support with SIP INFO, RTP (RFC 2833/RFC 4733), In-band

Zeroconf via mDNS/DNS-SD (à la Apple's Bonjour)

DNSSEC

Group video support (Jitsi Videobridge)

Packet loss concealment with the SILK and Opus codecs

KPhone

Linux

Multiple parallel sessions (in the case of audio, one may be active, the others are held).

Own ring tones or "ring music"

NAT-traversal and STUN support

Supported sound systems: ALSA and OSS

SRTP encryption for voice

Presence information

Call Hold

Call forwarding

Auto Answer

Linphone

       GNU GPL version 2

SIP user agent compliant with RFC 3261

SIP/UDP, SIP/TCP, SIP/TLS

Supports IPv6

Digest authentication

Supports multiple calls simultaneously with call management features: hold on with music, resume, transfer...

Multiple SIP proxy support: registrar, proxies, outbound proxies

Text instant messaging with delivery notification

Presence using the SIMPLE standard in peer to peer mode

DTMF (telephone tones) support using SIP INFO or RFC 2833

MicroSIP

C/C++

Windows

Profile of a lightweight background application[2]

Small memory footprint (<20 mb RAM usage)

Strong adherence to the SIP standard

Support for a number of codecs: Speex (narrow band and wideband), G.711 (u-law, a-law), GSM, iLBC, SILK (narrow band, wideband and ultra wideband), G.722

No Support for VP8 codec as of now

STUN and ICE NAT traversal

SIP SIMPLE presence and messaging

QuteCom

SIP compliance

Provider agnostic

Allows users to send SMS to France

NAT traversal

Audio smileys

Qt-based GUI

Chatting with MSN, AIM, ICQ, Yahoo and XMPP users

Encryption via SRTP, but key exchange over Everbee key that is not a Standard

Uses standard Session Initiation Protocol

SFLphone

C / C++

GNU General Public License 3

SIP and IAX compatible

Unlimited number of calls

Attended call transfer

Call hold

Multiple audio conferencing (from 0.9.7 version)

TLS and ZRTP support (from 0.9.7 version)

Audio codecs supported: G711u, G711a, GSM, Speex (8, 16, 32 kHz), CELT, G.722

Multiple SIP accounts support

STUN support per account (0.9.7)

DTMF support (SIP INFO)

Instant messaging

Call history + search feature

Silence detection with Speex audio codec

Account assistant wizard

Central server providing free SIP/IAX account

SIP presence subscription

Video multiparty conferencing (EXPERIMENTAL)

Multichannel audio support [EXPERIMENTAL]

Flac and OGG/Vorbis ringtone support

Desktop notification: voicemail number, incoming call, information messages

Minimize on start-up

Minimize to tray

not Direct IP-to-IP SIP call - P2P is not supported by IAx2 according to the documentation

SIP Re-invite

Address book support: Evolution Data Server integration (for the GNOME client), KABC integration for the KDE client

PulseAudio support

Native ALSA interface, DMix support

Locale settings: French, English, Russian, German, Chinese, Spanish, Italian, Vietnamese

Automatic opening of incoming URL

Telephone

Objective-C

Mac OS X

BSD License

Twinkle

GNU/Linux

2 call appearances (lines)

Multiple active call identities

Custom ring tones

Call Waiting

3-way conference calling

Mute

Call redirection on demand

Call redirection unconditional

Call redirection when busy

Call redirection no answer

Reject call redirection request

Blind call transfer

Call transfer with consultation (attended call transfer)

Reject call transfer request

Call reject

Repeat last call

Do not disturb

Auto answer

Message Waiting Inidication

Voice mail speed dial

User defineable scripts triggered on call events

E.g. to implement selective call reject or distinctive ringing

RFC 2833 DTMF events

Inband DTMF

Out-of-band DTMF (SIP INFO)

STUN support for NAT traversal

Send NAT keep alive packets when using STUN

NAT traversal through static provisioning

Persistent TCP connections for NAT traversal

Missed call indication

History of call detail records for incoming, outgoing, successful and missed calls

DNS SRV support

Automatic failover to an alternate server if a server is unavailable

Other programs can originate a SIP call via Twinkle, e.g. call from address book

System tray icon

System tray menu to quickly originate and answer calls while Twinkle stays hidden

User defineable number conversion rules

Simple address book

Support for UDP and TCP as transport for SIP

Presence

Simple file transfer with instant message

Instant message composition indication

Command line interface (CLI)

1)       高通過量

2)       靈活的路由功能和整合

3)       有效的應用的建立

4)       支援C/C++

5)       運作平台:Linux

1)       較為廣泛應用

2)       Twinkle不支援視訊通話

3)       Linphone和Kphone支援視訊通話

5)       運作平台: Linux

1)       OpenSIPS源代碼下載下傳:

用svn down下代碼 svn cohttps://opensips.svn.sourceforge.net/svnroot/opensips/branches/1.9 opensips_1_9

2)       安裝MySQL

3)       OpenSIPS安裝

root@ubuntu:cd /home/amaryllis/work/project/opensips/

root@ubuntu:make menuconfig

4)       OpenSIPS檔案配置

a)       修改配置檔案opensipsctlrc:

root@ubuntu:gedit /usr/local/opensips_proxy/etc/opensips/opensipsctlrc

b)       安裝資料庫:

root@ubuntu:cd /usr/local/opensips_proxy/sbin/

root@ubuntu:./opensipsdbctl create

c)       檢查M4是否安裝:

apt-get install m4

d)      生成opensips_residential_2013-3-10_22:52:46.cfg檔案:

root@ubuntu:./osipconfig

5)       設定啟動項:

root@ubuntu:cd /home/amaryllis/work/project/opensips/packaging/debian

root@ubuntu:cpopensips.init /etc/init.d/opensips

root@ubuntu:chmod+x /etc/init.d/opensips

root@ubuntu:gedit/etc/init.d/opensips

6)       設定預設項opensips.default:

root@ubuntu:cd /home/amaryllis/work/project/opensips/packaging/debian 

root@ubuntu:cp opensips.default /etc/default/

root@ubuntu:cd  /etc/default/

root@ubuntu:mv opensips.default opensips

root@ubuntu:gedit opensips

7)       啟動OpenSIPS:

root@ubuntu:/etc/init.d/opensips restart(重新開機)

或者

root@ubuntu:/etc/init.d/opensips start(啟動)

1)       下載下傳源代碼:源代碼一般以file.tar.gzfile.tar.bz2或file.src.rpm ,用tar jxvf file.tar.bz2 或者tar zxvffile.tar.gz來解壓安裝包

2)       設定編譯環境:安裝gcc;perl; python; glibc; gtk; make; auto make 等開發工具或基礎包。如果您在編 譯軟體時,有時提示缺少什麼東西之類的,大多少的是這些開發工具和開發庫等;從CD光牒中找出安 裝就是了;有時CD光牒沒有提供,請用 google 搜尋相應的軟體包,有時可能也會用到源碼包編譯安 裝所依賴的包; 有時本來系統中已經安裝了所依賴的包,但系統提示找不到應該怎麼辦?這時需 要我們設定一下PKG_CONFIG_PATH的環境變量就行了; #export PKG_CONFIG_PATH=/usr/lib/pkgconfig

3)       ./cofigure –prefix=/usr/你想要安裝的目錄

4)       Make

5)       Make install

rpm -i 需要安裝的封包件名

繼續閱讀