专注三网融合之接入网/核心网等技术,音视频信令和媒体传输相关协议
专家前辈入驻,谈笑有鸿儒,往来无白丁,共同学习探讨IMS/IPPBX相关技术
欢迎同行加入IMS/IPPBX/VoIP/SIP QQ交流群: 255404741 (猛戳直接加群)
AG Projects msrprelay是用强大的python脚本实现的msrp relay开源服务器,有官方描述,哥就不在这里瞎扯了:
This project implements an MSRP Relay (RFC 4976). Its main role is to help NAT traversal of MSRP based Instant Messaging and File Transfer sessions between SIP end-points located behind NAT.
下载安装dependencies
msrprelay依赖的软件包如下:
python-gnutls-1.2.5.tar.gz
python-application-1.4.0.tar.gz
Twisted-14.0.0.tar.bz2
zope.interface-4.1.1.tar.gz
SQLObject-1.6.0.tar.gz
MySQL-python-1.2.5
在https://pypi.python.org/pypi中的search中分别输入上述安装包名字,下载对应的安装包,
进入目录后执行python setup.py install 即可安装相应的软件
下载安装msrp
The software can be downloaded as a tar archive from:
http://download.ag-projects.com/MSRP/
python-msrplib-0.14.2.tar.gz
msrprelay-1.0.8.tar.gz
安装方法同上
运行msrprelay
INSTALL 文档中有说明:
Start the MSRPRelay, either by executing:
./msrprelay --no-fork
or as a daemon, which is the default behaviour.
This can also be done using the init.d script:
/etc/init.d/msrprelay start
根本就没有/etc/init.d/msrprelay,从源码根路径下直接运行
此运行不是daemon的方式(./msrprelay start可以daemon方式运行)
[root@localhost msrprelay-1.0.8]# pwd
/opt/msrprelay-1.0.8
[root@localhost msrprelay-1.0.8]# ./msrprelay --no-fork
Starting MSRP Relay 1.0.8
RelayFactory starting on 2855
另开一console查看端口,默认采用标准的2855端口
[root@localhost msrprelay-1.0.8]# netstat -tulnp | grep python
tcp 0 0 0.0.0.0:2855 0.0.0.0:* LISTEN 6544/python
[root@localhost msrprelay-1.0.8]#
传输文件测试
具体详细说明参考test/README 。
仿照说明测试步骤如下:
1. 创建用于传输的文件
[root@localhost test]# pwd
/opt/msrprelay-1.0.8
[root@localhost msrprelay-1.0.8]# echo xxxxxxxxxxx >TODO.txt
[root@localhost msrprelay-1.0.8]# echo yyyyyyyyyyy >>TODO.txt
[root@localhost msrprelay-1.0.8]#
2. start both clients in two console
console I of sender:
[root@localhost test]# ./msrp_send_file.py ../TODO.txt [email protected] 172.16.0.55
Password:
Sending initial AUTH
Got challenge, sending response AUTH
Path to send in SDP:
msrps://172.16.0.55:2855/EBu5/m2eo1QLtkUP3FOeNDEzOTkxNTQwMDguOTMwOjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345//nhZNDamYUxKrl22;tcp
Destination path:
console II of recevier:
[root@localhost test]#
[root@localhost test]# ./msrp_receive_file.py [email protected] 172.16.0.55
Password:
Sending initial AUTH
Got challenge, sending response AUTH
Path to send in SDP:
msrps://172.16.0.55:2855/Y82Mpnt4ZLvbYPD9iMct0zEzOTkxNTQwMjUuMTc2OjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345/BIglF+5r9DIwtLth;tcp
Destination path:
3. 相互指定对方的msrp destination path
查看步骤2显示的msrp path,将msrp_send_file.py输出的msrp path粘贴到msrp_receive_file.py的“Destination path: ”的输入提示后,反之依然:
console I of sender:
[root@localhost test]# ./msrp_send_file.py ../TODO.txt [email protected] 172.16.0.55
Password:
Sending initial AUTH
Got challenge, sending response AUTH
Path to send in SDP:
msrps://172.16.0.55:2855/EBu5/m2eo1QLtkUP3FOeNDEzOTkxNTQwMDguOTMwOjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345//nhZNDamYUxKrl22;tcp
Destination path: msrps://172.16.0.55:2855/Y82Mpnt4ZLvbYPD9iMct0zEzOTkxNTQwMjUuMTc2OjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345/BIglF+5r9DIwtLth;tcp
Starting transmission of "TODO.txt"
sent 0 of 24 bytes
File transfer completed.
Connection lost!
Sent 24 bytes in 10 seconds, (0.00 kb/s)
Connection lost
Connection was closed cleanly.
[root@localhost test]#
console II of recevier:
[root@localhost test]#
[root@localhost test]# ./msrp_receive_file.py [email protected] 172.16.0.55
Password:
Sending initial AUTH
Got challenge, sending response AUTH
Path to send in SDP:
msrps://172.16.0.55:2855/Y82Mpnt4ZLvbYPD9iMct0zEzOTkxNTQwMjUuMTc2OjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345/BIglF+5r9DIwtLth;tcp
Destination path: msrps://172.16.0.55:2855/EBu5/m2eo1QLtkUP3FOeNDEzOTkxNTQwMDguOTMwOjE3Mi4xNi4wLjU1;tcp msrps://localhost:12345//nhZNDamYUxKrl22;tcp
Receiving file "TODO.txt"
received 24 of 24 bytes
File transfer completed successfully.
Received 24 bytes in 0 seconds, (12.98 kb/s)
Connection lost!
Connection lost
Connection was closed cleanly.
[root@localhost test]#
4. 查看结果
测试文件果然从 /opt/msrprelay-1.0.8/TODO.txt传输到了 /opt/msrprelay-1.0.8/test/TODO.txt
[root@localhost test]# ls
msrp_receive_file.py msrp_send_file.py README TODO.txt
[root@localhost test]# cat TODO.txt
xxxxxxxxxxx
yyyyyyyyyyy
[root@localhost test]# cat ../TODO.txt
xxxxxxxxxxx
yyyyyyyyyyy
[root@localhost test]#
更多信息参考源码INSTALL和README说明
参考文件
http://www.msrprelay.org/projects/msrprelay/wiki/InstallationGuide
转载请注明出处 http://blog.csdn.net/xuyunzhang/article/details/29354391 谢谢。