專註三網融合之接入網/核心網等技術,音視頻信令和媒體傳輸相關協議專家前輩入駐,談笑有鴻儒,往來無白丁,共同學習探討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 alice@172.16.0.55 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 alice@172.16.0.55 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 alice@172.16.0.55 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 alice@172.16.0.55 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 謝謝。