Tuesday, December 02, 2008

sipping with Net::SIP

As I had indicated in my earlier post, Net::SIP module for perl really streamlines a lot of the things for quick testing and automation. Net::SIP provides the SIP framework using which one can develop any of the SIP entity functionalities like Registrar, Proxy, UA, etc.

Net::SIP has a lot more associated modules, that help whip up some specific SIP entities in a couple of hours. Like for eg: Net::SIP::Registrar helps to implement a fully working registrar functionality fairly quickly. There are many such modules to help you build many of these entities.

The following is a sample code that acts as a SIP UA that registers with a registrar and makes a call using the Net::SIP::Simple module (from the module example) complete with SDP and RTP packet handling.

use Net::SIP;

# create new agent
my $ua = Net::SIP::Simple->new(
outgoing_proxy => '192.168.0.10',
registrar => '192.168.0.10',
domain => 'example.com',
from => 'me',
auth => [ 'me','secret' ],
);

# Register agent
$ua->register;

# Invite other party, send anncouncement once connected
$ua->invite( 'you',
init_media => $ua->rtp( 'send_recv', 'announcement.pcmu-8000' ),
asymetric_rtp => 1,
);

# Mainloop
$ua->loop;
Isn't that simple? If one has some custom requirements, then Net::SIP provides low level modules and utilities using which one can implement custom SIP entities and behaviours.  Net::SIP::Packet lets you handle the SIP packets and Net::SIP::Leg which acts as a wrapper around sockets and lets one send and receive data.

happy sipping....


1 comment:

Unknown said...

Hi there.
How could I Register the specific Client against the SIP Server (other IP), using Net::SIP module.

Tried to use the suggested by you. However I don't see any request for such Registration.

Thanks