Chinaunix首页 | 论坛 | 博客
  • 博客访问: 752047
  • 博文数量: 119
  • 博客积分: 137
  • 博客等级: 少校
  • 技术积分: 1582
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-28 16:39
文章分类

全部博文(119)

文章存档

2017年(3)

2016年(7)

2014年(1)

2013年(8)

2012年(20)

2011年(27)

2010年(53)

分类: LINUX

2013-11-06 11:11:02

本文作者:宣寄托

1,搭建sip测试用的环境(ubuntu 9.10/9.04)

sip服务器(proxy):openser,也可以用asterisk但无法支持sipmessge 发送。
sip客户端:linphone (或自写sip测试程序)

2,sip服务器搭建.

采用openser服务器。

2.1
首先安装mysql,可以在终端提示符后运行下列命令:

sudo apt-get install mysql-server
sudo apt-get install mysql-client

一旦安装完成,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:

sudo netstat -tap | grep mysql

当您运行该命令时,您可以看到类似下面的行:

tcp 0 0 localhost.localdomain:mysql *:* LISTEN -

如果服务器不能正常运行,您可以通过下列命令启动它:

sudo /etc/init.d/mysql restart

进入mysql

mysql -uroot -p

(输入mysql的root密码)

配置 MySQL 的管理员密码:

sudo mysqladmin -u root password newpassword

2.2 安装openser

可以到synaptic Package Manager 里面去选择openser的部件安装.包括:

(1)openner1.3.2-3
(2)openner-mysql-module 1.3.2-3


开始配置,首先创建openser所需的数据库及数据表:
sudo gedit /etc/openser/openserctlrc
这个东西会在openserdbctl时使用需要放开注释的项目并配置相应值
DBENGINE=MYSQL
执行如下:

xuanjt@ubuntu:~$ sudo /usr/sbin/openserdbctl create        //一定注意这个在ubuntu下是openserdbctl,在其他版本linux可能会是openser_mysql.sh
ERROR: database engine not specified, please setup on
e in the config script
xuanjt@ubuntu:~$ sudo /usr/sbin/openserdbctl create
MySQL password for root:                                      //这里输入root用户密码
INFO: test server charset
INFO: creating database openser ...
INFO: Core OpenSER tables succesfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into openser ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute? (y/n): y
INFO: creating extra tables into openser ...
INFO: Extra tables succesfully created.

添加用户:

这里需要用到openser数据库的密码,默认是openserrw


例如:

xuanjt@ubuntu:~$ openserctl add 8004 8004 8004@192.168.0.101
MySQL password for user 'openser@localhost':
new user '8004' added


一次添加:
> openserctl add 8001 1111 8001@192.168.0.101
~> openserctl add 8002 1111 8002@192.168.0.101
~> openserctl add 8003 1111 8003@192.168.0.101

执行命令:openser 如下:


xuanjt@ubuntu:~$ openser
Listening on
             udp: 127.0.0.1 [127.0.0.1]:5060
             udp: 192.168.0.101 [192.168.0.101]:5060
             tcp: 127.0.0.1 [127.0.0.1]:5060
             tcp: 192.168.0.101 [192.168.0.101]:5060
Aliases:
             tcp: ubuntu.local:5060
             tcp: localhost:5060
             udp: ubuntu.local:5060
             udp: localhost:5060



如此就可以测试sip终端功能了。


测试用例:
两个sip终端都用linpone,一个是在ubuntu系统下的linphone(3.1.2在ubuntu9.10下通过source software manager安装),和sipserver即openser在一个物理机器。
另一个是在windows下用linphone 3.2.0(window 版本);
安装后配置:preference->Manage sip Account->Proxy acount

配置完成后启动sipserver即可以互打电话了。……。

可以用wireshark抓包工具观察sip数据包情况,注意区分eth0和lo的去别,一个是局域网,以个是loopback即本机对本机。











//--------------------------------------------------------------附录 ---------------------------------------------------------------------

 -- command 'start|stop|restart'

 restart ............................ restart OpenSER
 start .............................. start OpenSER
 stop ............................... stop OpenSER

 -- command 'acl' - manage access control lists (acl)

 acl show [] .............. show user membership
 acl grant ....... grant user membership (*)
 acl revoke [] .... grant user membership(s) (*)

 -- command 'lcr' - manage least cost routes (lcr)

   * IP addresses must be entered in dotted quad format e.g. 1.2.3.4 *
   * and must be entered in integer or text,*
   * e.g. transport '2' is identical to transport 'tcp'.             *
   *   scheme: 1=sip, 2=sips;   transport: 1=udp, 2=tcp, 3=tls       *
   * Examples:  lcr addgw_grp usa 1                                  *
   *            lcr addgw level3 1.2.3.4 5080 sip tcp 1              *
   *            lcr addroute +1 '' 1 1                               *
 lcr show .....................................................................
           ............. show routes, gateways and groups
 lcr reload ...................................................................
           ............. reload lcr gateways
 lcr addgw_grp ............................................
           .............. add gateway group, autocreate grp_id if not present .
 lcr rmgw_grp  .......................................................
           ............... delete the gw_grp
 lcr addgw
           ............... add a gateway with prefix and strip ................
           ................(prefix and strip are optional arguments) ..........
 lcr rmgw  ..........................................................
           ............... delete a gateway
 lcr addroute .................................
           .............. add a route ( use '' to match anything in )
 lcr rmroute  .................................
           .............. delete a route

 -- command 'cr' - manage carrierroute tables

 cr show ........................................................ show tables
 cr reload ...................................................... reload tables
 cr addrt ...................... add a tree
 cr rmrt  ........................................ rm a tree
 cr addcarrier ................
               ...............
               ........................................ add a carrier
               (strip, rewrite_prefix, rewrite_suffix and comment are optional
                arguments) ....................................................
 cr rmcarrier  ................. rm a carrier

 -- command 'rpid' - manage Remote-Party-ID (RPID)

 rpid add ......... add rpid for a user (*)
 rpid rm ................. set rpid to NULL for a user (*)
 rpid show ............... show rpid of a user

 -- command 'add|mail|passwd|rm' - manage subscribers

 add .. add a new subscriber (*)
 passwd ......... change user's password (*)
 rm ...................... delete a user (*)
 mail .................... send an email to a user

 -- command 'add|dump|reload|rm|show' - manage trusted

 trusted show ...................... show db content
 trusted dump ...................... show cache content
 trusted reload .................... reload db table into cache
 trusted add
             ....................... add a new entry
             ....................... (from_pattern and tag are optional arguments)
 trusted rm ............... remove all entres for the given src_ip

 -- command 'dispatcher' - manage dispatcher

   * Examples:  dispatcher addgw 1 sip:1.2.3.1:5050 'outbound gateway'
   *            dispatcher addgw 2 sip:1.2.3.4:5050
   *            dispatcher rmgw 4
 dispatcher show ..................... show dispatcher gateways
 dispatcher reload ................... reload dispatcher gateways
 dispatcher dump ..................... show in memory dispatcher gateways
 dispatcher addgw
            .......................... add gateway
 dispatcher rmgw ................ delete gateway

 -- command 'cisco_restart' - restart CISCO phone (NOTIFY)

 cisco_restart ................ restart phone configured for

 -- command 'online' - dump online users from memory

 online ............................. display online users

 -- command 'monitor' - show internal status

 monitor ............................ show server's internal status

 -- command 'ping' - ping a SIP URI (OPTIONS)

 ping ......................... ping with SIP OPTIONS

 -- command 'ul|alias' - manage user location or aliases

 ul show []................ show in-RAM online users
 ul show --brief..................... show in-RAM online users in short format
 ul rm [].... delete user's usrloc entries
 ul add ............ introduce a permanent usrloc entry
 ul add .. introduce a temporary usrloc entry

 -- command 'fifo'

 fifo ............................... send raw FIFO command


转自:

http://jituo666.blog.163.com/blog/static/294817212010224468542/


阅读(3099) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~