当前位置: 首页 > 工具软件 > reSIProcate > 使用案例 >

【reSIProcate学习】搭建与测试笔记

黄伟
2023-12-01

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

1.目标
兼容标准、易用性、效率达到> 1000 tps 、占用空间< 1 MB、可移植、支持Windows、并且SIP安全

2.应用
嵌入式电话、软终端、网关、代理、B2BUA、IM/状态服务器、客户端。

3.特性
支持协议:UDP, TCP, TLS, IPv6
SIP协议:RFC3261全兼容
懒惰解析器:当应用程序请求时仅仅解析头部。
编程特性:面向对象接口,支持单线程和多线程
异步DNS,并且支持NAPTR/SRV  
平台: Windows, Linux,BSD, Solaris, QNX, OS/X
支持Multi-homed hosts,即a host
with multiple addresses
安全方面:        MIME & S/MIME
方便开发方面:User Agent Library (DUM)
可扩展性上有所实现。

4.支持的RFC及草案
Supported RFCs:
– 2327: SDP
– 2617: HTTP Digest
– 2782: DNS SRV
– 2915: DNS NAPTR
– 2976: sip INFO
– 3261: sip
– 3263: Locating sip servers
– 3265: subscribe/notify
– 3420: sipfrag
– 3325: network asserted id
– 3428: sip MESSAGE
– 3326: reason header
– 3515: sip REFER
– 3581: symmetric response

In Development
– 3323: Privacy mechanism
– 3262: Reliable provisional
– 3264: Offer/Answer
– 3266: IPv6 in SDP
– 3311: UPDATE
– draft-simple-winfo
– draft-sip-session-timer
– draft-sip-caller-prefs

Drafts: (partial list)
– draft-impp-srv, draft-simple-presence
– draft-sip-replaces, draft-sip-referredby
– Draft-sip-connect-reuse
– draft-sip-join, sip-gruu
– sip-publish, sipping-mwi

5.架构
 

6.代码下载编译(Ubuntu9.04环境)

1)外部库:
Gnu Perfect Hash :哈希功能产生器。sudo apt-get install gperf
Open SSL :使用DTLS时。sudo apt-get install libssl-dev
POPT : 用于解析命令行的库。sudo apt-get install libpopt0 libpopt-dev
Perl Compatible Regular Expression Library : Perl的增则表达式库。sudo apt-get install libpcre3-dev
Berkeley DB :一个小型数据库产品, Repro,——Resiprocate Proxy使用。sudo apt-get install libdb4.2++-dev
Boost : 使用TFM (the testing framework)。sudo apt-get install libboost-dev
总结起来,在ubuntu环境下的要安装的命令是:sudo aptitude update; sudo aptitude install subversion g++ gperf libssl-dev libpopt-dev libpcre3-dev libdb4.2++-dev libboost-dev

2)SVN获取代码
SVN 获取resiproctae代码: svn checkout https://svn.resiprocate.org/rep/resiprocate/main resiprocate  在你当前目录下就会有一个resiprocate子目录。

3)构建
cd resoprocate
./configure
你会被问到一些问题,你只需要按回车就能选定默认的方式。在问到 时需要进行如下修改(你可以看看你的这个文件在哪):
Where is db_cxx.h?

[/usr/include/db4] /usr/include 

Where is popt.h?

[/usr/local/include] /usr/include

Where is libpopt?

[/usr/local/lib] /usr/lib

当然你也可以通过一个菜单项的东西进行编译: ./configure -m ,只要 你的终端支持 vt100-style 。具体的一些编译参数可以参见 Configuration Options
然后:sudo make
使用sudo确保一些不必要的权限问题。

Trouble Shooting:
你要是发现bad interpeter 这样的错误信息,那八成是你在Windows下SVN出的代码导致的format问题,建议删除后在Linux下进行重新的svn checkout

4)测试
首先先装一个抓包分析软件:wireshark
在ubuntu9.04时安装该软件,运行时会出现bus error的问题,据说是和某个版本的GTK冲突……后来我升级到了9.10就ok了。注意在启动时,命令行启动要用sudo,否则会出现找不到网络设备的问题: sudo wireshark &
会出现提示说有危险,这个可以忽略。

在filter里面输入sip,然后按apply键。

运行: resiprocate/resip/stack/test/testClient debug 'sip:user1@localhost;transport=udp'
可以看到抓到几个INVITE包。

在工具栏选择“ Telephony” ->“ VoIP calls” , 可以看到一个呼叫发起。

环境:ubuntu9.10 IP:192.168.1.100
一.配置测试Linphone
Linphone是一个比较著名的开源软件,作为测试终端,我们需要先安装配置好它。
安装:sudo apt-get install linphone
运行后首先设置一个默认账户,其他选择默认选项即可:
   1.打开终端。
   2.在命令行提示符处输入 sipomatic。
   3.启动 Linphone。
   4.输入 sip:robot@192.168.1.100:5064 作为 SIP 地址并单击致电或应答。
   5.如果 Linphone 配置正确,则听到电话铃声,稍后将听到一个简短声明。
二.测试resiprocate下的testClient
首先运行wireshark,设定好监听本地端口,然后在filter中填入sip以抓取SIP消息包
然后运行在resiprocate下的/resip/stack/test里面的testClient,具体命令行为:
./testClient debug 'sip:gnuhpc@192.168.1.100;transport=udp'
此时会有响铃声,你可以选择接受,接收后Client会发送BYE消息终止,然后再INVITE,此时你可以再选择Decline,从wireshark下看抓包就可以看到一些信令交互了
三.测试resiprocate下的testServer
运行在resiprocate下的/resip/stack/test里面的testServer,具体命令行为:
./testServer debug 5 udp
启动一个UAS,现在我们使用Linphone作为UAC向<sip:testServer@192.168.1.100:5070>发起一个呼叫。
通过Linphone的状态栏我们看到呼叫被接受,然后我们挂机。
我们可以完整的看到信令交互。

代码分析:

[cpp:collapse] + expand sourceview plaincopy

终端中打印的调试信息

warmbupt@pchuang:/windows/MyCode/resiprocate$ resip/stack/test/testServer debug 5 udp
Choosing Debug level since string was not understood: debug
DEBUG | 20100223-223126.561 | testServer | RESIP | 3077773008 | ssl/Security.cxx:867 | BaseSecurity::BaseSecurity
INFO | 20100223-223126.562 | testServer | RESIP:DNS | 3077773008 | dns/AresDns.cxx:190 | DNS initialization: found  2 name servers
INFO | 20100223-223126.562 | testServer | RESIP:DNS | 3077773008 | dns/AresDns.cxx:193 |  name server: 202.102.224.68
INFO | 20100223-223126.562 | testServer | RESIP:DNS | 3077773008 | dns/AresDns.cxx:193 |  name server: 202.102.227.68
DEBUG | 20100223-223126.562 | testServer | RESIP | 3077773008 | Compression.cxx:40 | COMPRESSION SUPPORT NOT COMPILED IN
DEBUG | 20100223-223126.562 | testServer | RESIP | 3077773008 | Compression.cxx:43 | Compression configuration object created; algorithm = 0
DEBUG | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | TransportSelector.cxx:93 | No compression library available
DEBUG | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | InternalTransport.cxx:86 | Creating fd=3 V4/UDP
DEBUG | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | InternalTransport.cxx:94 | Binding to 0.0.0.0
INFO | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | UdpTransport.cxx:48 | Creating UDP transport host= port=5070 ipv4=1
DEBUG | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | UdpTransport.cxx:62 | No compression library available: Transport: [ V4 0.0.0.0:5070 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223126.563 | testServer | RESIP:DNS | 3077773008 | DnsUtil.cxx:434 | Considering: lo -> 127.0.0.1 flags=0x49
DEBUG | 20100223-223126.563 | testServer | RESIP:DNS | 3077773008 | DnsUtil.cxx:444 |   ignore because: interface is loopback
DEBUG | 20100223-223126.563 | testServer | RESIP:DNS | 3077773008 | DnsUtil.cxx:434 | Considering: wlan0 -> 192.168.1.107 flags=0x1043
DEBUG | 20100223-223126.563 | testServer | RESIP:DNS | 3077773008 | DnsUtil.cxx:463 |   using this
DEBUG | 20100223-223126.563 | testServer | RESIP | 3077773008 | SipStack.cxx:225 | Adding domain alias: 127.0.0.1:5070
DEBUG | 20100223-223126.563 | testServer | RESIP | 3077773008 | SipStack.cxx:225 | Adding domain alias: 192.168.1.107:5070
DEBUG | 20100223-223126.563 | testServer | RESIP:TRANSPORT | 3077773008 | TransportSelector.cxx:196 | Adding transport: [ V4 0.0.0.0:5070 UDP target domain=unspecified mFlowKey=0 ]
INFO | 20100223-223126.563 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:37 | This is the Server
DEBUG | 20100223-223133.933 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:287 | incoming from: [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223133.933 | testServer | RESIP | 3077770096 | Helper.cxx:375 | Helper::makeResponse(SipReq:  INVITE testServer@192.168.1.107:5070 tid=437909975 cseq=INVITE contact=warmbupt@192.168.1.107:5060 / 20 from(wire) code=100 reason=
DEBUG | 20100223-223133.933 | testServer | RESIP:TRANSACTION | 3077770096 | TimerQueue.cxx:85 | Adding timer: Timer Trying tid=437909975 ms=80
DEBUG | 20100223-223133.933 | testServer | RESIP:TRANSACTION | 3077770096 | TransactionState.cxx:2145 | Send to default TU:
INVITE sip:testServer@192.168.1.107:5070 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK437909975
Max-Forwards: 70
Contact: <sip:warmbupt@192.168.1.107:5060>
To: <sip:testServer@192.168.1.107:5070>
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 20 INVITE
Subject: Phone call
Content-Type: application/sdp
User-Agent: Linphone/3.1.2 (eXosip2/3.3.0)
Content-Length: 294
v=0
o=warmbupt 123456 654321 IN IP4 192.168.1.107
s=A conversation
c=IN IP4 192.168.1.107
t=0 0
m=audio 7078 RTP/AVP 111 110 0 8 101
a=rtpmap:111 speex/16000/1
a=rtpmap:110 speex/8000/1
a=rtpmap:0 PCMU/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
DEBUG | 20100223-223133.933 | testServer | RESIP | 3077770096 | SipStack.cxx:502 | RECV: SipReq:  INVITE testServer@192.168.1.107:5070 tid=437909975 cseq=INVITE contact=warmbupt@192.168.1.107:5060 / 20 from(wire)
ERR | 20100223-223133.933 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:63 | Server received: INVITE
DEBUG | 20100223-223133.933 | testServer | RESIP | 3077770096 | Helper.cxx:375 | Helper::makeResponse(SipReq:  INVITE testServer@192.168.1.107:5070 tid=437909975 cseq=INVITE contact=warmbupt@192.168.1.107:5060 / 20 from(wire) code=180 reason=
ERR | 20100223-223133.933 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:69 | Sent 180
DEBUG | 20100223-223133.933 | testServer | RESIP | 3077770096 | SipStack.cxx:319 | SEND: SipResp: 180 tid=437909975 cseq=INVITE contact=fluffy@pchuang.cn.ibm.com:5070 / 20 from(tu)
DEBUG | 20100223-223133.933 | testServer | RESIP | 3077770096 | Helper.cxx:375 | Helper::makeResponse(SipReq:  INVITE testServer@192.168.1.107:5070 tid=437909975 cseq=INVITE contact=warmbupt@192.168.1.107:5060 / 20 from(wire) code=200 reason=
ERR | 20100223-223133.934 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:74 | Sent 200
DEBUG | 20100223-223133.934 | testServer | RESIP | 3077770096 | SipStack.cxx:319 | SEND: SipResp: 200 tid=437909975 cseq=INVITE contact=fluffy@pchuang.cn.ibm.com:5070 / 20 from(tu)
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | InternalTransport.cxx:86 | Creating fd=4 V4/UDP
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:566 | Looked up source for destination: [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ] -> [ V4 192.168.1.107:0 UDP target domain=unspecified mFlowKey=3 ] sent-by=192.168.1.107 sent-port=5060
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:945 | Transmitting to [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ] tlsDomain= via [ V4 192.168.1.107:5070 UDP target domain=unspecified mFlowKey=3 ]
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK437909975
Contact: <sip:fluffy@pchuang.cn.ibm.com:5070;transport=UDP>
To: <sip:testServer@192.168.1.107:5070>;tag=2c609410
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 20 INVITE
Content-Length: 0
sigcomp id=
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:213 | Adding message to tx buffer to: [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:566 | Looked up source for destination: [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ] -> [ V4 192.168.1.107:0 UDP target domain=unspecified mFlowKey=3 ] sent-by=192.168.1.107 sent-port=5060
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:945 | Transmitting to [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ] tlsDomain= via [ V4 192.168.1.107:5070 UDP target domain=unspecified mFlowKey=3 ]
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK437909975
Contact: <sip:fluffy@pchuang.cn.ibm.com:5070;transport=UDP>
To: <sip:testServer@192.168.1.107:5070>;tag=2c609410
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 20 INVITE
Content-Length: 0
sigcomp id=
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:213 | Adding message to tx buffer to: [ V4 192.168.1.107:5060 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223133.934 | testServer | RESIP:TRANSACTION | 3077770096 | TimerQueue.cxx:85 | Adding timer: Timer StaleServer tid=437909975 ms=32000
DEBUG | 20100223-223134.002 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:287 | incoming from: [ V4 127.0.1.1:5060 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223134.002 | testServer | RESIP:TRANSACTION | 3077770096 | TransactionState.cxx:2145 | Send to default TU:
ACK sip:fluffy@pchuang.cn.ibm.com:5070;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK471088285;received=127.0.1.1
Max-Forwards: 70
Contact: <sip:warmbupt@192.168.1.107:5060>
To: <sip:testServer@192.168.1.107:5070>;tag=2c609410
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 20 ACK
User-Agent: Linphone/3.1.2 (eXosip2/3.3.0)
Content-Length: 0
DEBUG | 20100223-223134.002 | testServer | RESIP | 3077770096 | SipStack.cxx:502 | RECV: SipReq:  ACK fluffy@pchuang.cn.ibm.com:5070 tid=471088285 cseq=ACK contact=warmbupt@192.168.1.107:5060 / 20 from(wire)
ERR | 20100223-223134.002 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:63 | Server received: ACK
DEBUG | 20100223-223140.898 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:287 | incoming from: [ V4 127.0.1.1:5060 UDP target domain=unspecified mFlowKey=3 ]
DEBUG | 20100223-223140.898 | testServer | RESIP | 3077770096 | Helper.cxx:375 | Helper::makeResponse(SipReq:  BYE fluffy@pchuang.cn.ibm.com:5070 tid=2023412367 cseq=BYE contact=warmbupt@192.168.1.107:5060 / 21 from(wire) code=100 reason=
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSACTION | 3077770096 | TimerQueue.cxx:85 | Adding timer: Timer Trying tid=2023412367 ms=3500
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSACTION | 3077770096 | TransactionState.cxx:2145 | Send to default TU:
BYE sip:fluffy@pchuang.cn.ibm.com:5070;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK2023412367;received=127.0.1.1
Max-Forwards: 70
Contact: <sip:warmbupt@192.168.1.107:5060>
To: <sip:testServer@192.168.1.107:5070>;tag=2c609410
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 21 BYE
User-Agent: Linphone/3.1.2 (eXosip2/3.3.0)
Content-Length: 0
DEBUG | 20100223-223140.899 | testServer | RESIP | 3077770096 | SipStack.cxx:502 | RECV: SipReq:  BYE fluffy@pchuang.cn.ibm.com:5070 tid=2023412367 cseq=BYE contact=warmbupt@192.168.1.107:5060 / 21 from(wire)
ERR | 20100223-223140.899 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:63 | Server received: BYE
DEBUG | 20100223-223140.899 | testServer | RESIP | 3077770096 | Helper.cxx:375 | Helper::makeResponse(SipReq:  BYE fluffy@pchuang.cn.ibm.com:5070 tid=2023412367 cseq=BYE contact=warmbupt@192.168.1.107:5060 / 21 from(wire) code=200 reason=
ERR | 20100223-223140.899 | testServer | RESIP:TEST | 3077770096 | testServer.cxx:81 | Sent 200 to BYE
DEBUG | 20100223-223140.899 | testServer | RESIP | 3077770096 | SipStack.cxx:319 | SEND: SipResp: 200 tid=2023412367 cseq=BYE contact=fluffy@pchuang.cn.ibm.com:5070 / 21 from(tu)
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSACTION | 3077770096 | TimerQueue.cxx:85 | Adding timer: Timer J tid=2023412367 ms=32000
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:566 | Looked up source for destination: [ V4 127.0.1.1:5060 UDP target domain=unspecified mFlowKey=3 ] -> [ V4 127.0.1.1:0 UDP target domain=unspecified mFlowKey=3 ] sent-by=192.168.1.107 sent-port=5060
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSPORT | 3077770096 | TransportSelector.cxx:945 | Transmitting to [ V4 127.0.1.1:5060 UDP target domain=unspecified mFlowKey=3 ] tlsDomain= via [ V4 127.0.1.1:5070 UDP target domain=unspecified mFlowKey=3 ]
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.107:5060;rport=5060;branch=z9hG4bK2023412367;received=127.0.1.1
Contact: <sip:fluffy@pchuang.cn.ibm.com:5070;transport=UDP>
To: <sip:testServer@192.168.1.107:5070>;tag=2c609410
From: <sip:warmbupt@192.168.1.107>;tag=1530548280
Call-ID: 1226925604
CSeq: 21 BYE
Content-Length: 0
sigcomp id=
DEBUG | 20100223-223140.899 | testServer | RESIP:TRANSPORT | 3077770096 | Transport.cxx:213 | Adding message to tx buffer to: [ V4 127.0.1.1:5060 UDP target domain=unspecified mFlowKey=3 ]

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

 类似资料: