Hi All,
Can someone point me in the right direction of a command line SIP Ping utility or how to invoke from Kamailio? I see there is a sip_ping.pl script in voip-hacks, does anyone have copy-paste text version of that, all I can find is the PDF?
Thanks.
JR
JR Richardson writes:
Can someone point me in the right direction of a command line SIP Ping utility or how to invoke from Kamailio?
you can use sipsak as command line ping tool. tm module has t_uac function that you can invoke via mi interface. i do not have any scripts for you.
-- juha
Hey JR...
I use this:
#! /usr/bin/perl -w use IO::Socket; use POSIX 'strftime';
my ($msg,$remotehost,$callid,$socket,$date,$branch,$localip,$dest);
$remotehost = $ARGV[0] or die "FAIL (no host defined)\n";
if ($ARGV[1]) { $remoteport = $ARGV[1]; } else { $remoteport = "5060"; }
if ($ARGV[2]) { $localip = $ARGV[2]; } else { $localip = "127.0.0.1"; }
if ($ARGV[2]) { $dest = $ARGV[3]; } else { $dest = "ping"; }
$socket = IO::Socket::INET->new ( PeerAddr => $remotehost, PeerPort => $remoteport, Proto => 'udp', ) or die "FAIL Could not create socket: $!n"; $callid .= ('0'..'9', "a".."f")[int(rand(16))] for 1 .. 32; $date = strftime('%a, %e %B %Y %I:%M:%S %Z',localtime()); $branch="z9hG4bk" . time();
my $packet = qq(OPTIONS sip:$remotehost SIP/2.0 Via: SIP/2.0/UDP $localip:$remoteport;branch=$branch From: sip:$dest\@$localip To: sip:$remotehost Contact: <sip:$dest@$localip Call-ID: $callid@$localip CSeq: 102 Options User-Agent: sipcheck.pl Date: $date Allow: ACK, CANCEL Content-Length: 0 );
print $socket $packet;
eval { local $SIG{ALRM} = sub { die }; alarm 5; my $sock_addr = recv($socket,$msg,190,0); alarm 0; 1; } or die("FAIL\n");
if ($msg) { print "UP\n"; print "response is $msg\n"; } else { print "FAIL no msg received\n"; } close($socket);
---fred http://qxork.com
On Oct 15, 2010, at 11:14 AM, JR Richardson wrote:
Hi All,
Can someone point me in the right direction of a command line SIP Ping utility or how to invoke from Kamailio? I see there is a sip_ping.pl script in voip-hacks, does anyone have copy-paste text version of that, all I can find is the PDF?
Thanks.
JR
JR Richardson Engineering for the Masses
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Fri, Oct 15, 2010 at 10:22 AM, Fred Posner fred@teamforrest.com wrote:
Hey JR...
I use this:
#! /usr/bin/perl -w use IO::Socket; use POSIX 'strftime';
my ($msg,$remotehost,$callid,$socket,$date,$branch,$localip,$dest);
$remotehost = $ARGV[0] or die "FAIL (no host defined)\n";
if ($ARGV[1]) { $remoteport = $ARGV[1]; } else { $remoteport = "5060"; }
if ($ARGV[2]) { $localip = $ARGV[2]; } else { $localip = "127.0.0.1"; }
if ($ARGV[2]) { $dest = $ARGV[3]; } else { $dest = "ping"; }
$socket = IO::Socket::INET->new ( PeerAddr => $remotehost, PeerPort => $remoteport, Proto => 'udp', ) or die "FAIL Could not create socket: $!n";
$callid .= ('0'..'9', "a".."f")[int(rand(16))] for 1 .. 32; $date = strftime('%a, %e %B %Y %I:%M:%S %Z',localtime()); $branch="z9hG4bk" . time();
my $packet = qq(OPTIONS sip:$remotehost SIP/2.0 Via: SIP/2.0/UDP $localip:$remoteport;branch=$branch From: sip:$dest\@$localip To: sip:$remotehost Contact: <sip:$dest@$localip Call-ID: $callid@$localip CSeq: 102 Options User-Agent: sipcheck.pl Date: $date Allow: ACK, CANCEL Content-Length: 0 );
print $socket $packet;
eval { local $SIG{ALRM} = sub { die }; alarm 5; my $sock_addr = recv($socket,$msg,190,0); alarm 0; 1; } or die("FAIL\n");
if ($msg) { print "UP\n"; print "response is $msg\n"; } else { print "FAIL no msg received\n"; } close($socket);
---fred http://qxork.com
Thanks Fred, this works fine, I like the response, you get more info than the 'kamctl ping".
I'm looking more for a utility that I can run in the background and graph latency, that gives me specific time value so I can dump into MRTG.
Any ideas?
JR
On Oct 15, 2010, at 11:42 AM, JR Richardson wrote:
On Fri, Oct 15, 2010 at 10:22 AM, Fred Posner fred@teamforrest.com wrote:
Hey JR...
I use this:
#! /usr/bin/perl -w use IO::Socket; use POSIX 'strftime';
my ($msg,$remotehost,$callid,$socket,$date,$branch,$localip,$dest);
$remotehost = $ARGV[0] or die "FAIL (no host defined)\n";
if ($ARGV[1]) { $remoteport = $ARGV[1]; } else { $remoteport = "5060"; }
if ($ARGV[2]) { $localip = $ARGV[2]; } else { $localip = "127.0.0.1"; }
if ($ARGV[2]) { $dest = $ARGV[3]; } else { $dest = "ping"; }
$socket = IO::Socket::INET->new ( PeerAddr => $remotehost, PeerPort => $remoteport, Proto => 'udp', ) or die "FAIL Could not create socket: $!n";
$callid .= ('0'..'9', "a".."f")[int(rand(16))] for 1 .. 32; $date = strftime('%a, %e %B %Y %I:%M:%S %Z',localtime()); $branch="z9hG4bk" . time();
my $packet = qq(OPTIONS sip:$remotehost SIP/2.0 Via: SIP/2.0/UDP $localip:$remoteport;branch=$branch From: sip:$dest\@$localip To: sip:$remotehost Contact: <sip:$dest@$localip Call-ID: $callid@$localip CSeq: 102 Options User-Agent: sipcheck.pl Date: $date Allow: ACK, CANCEL Content-Length: 0 );
print $socket $packet;
eval { local $SIG{ALRM} = sub { die }; alarm 5; my $sock_addr = recv($socket,$msg,190,0); alarm 0; 1; } or die("FAIL\n");
if ($msg) { print "UP\n"; print "response is $msg\n"; } else { print "FAIL no msg received\n"; } close($socket);
---fred http://qxork.com
Thanks Fred, this works fine, I like the response, you get more info than the 'kamctl ping".
I'm looking more for a utility that I can run in the background and graph latency, that gives me specific time value so I can dump into MRTG.
Any ideas?
JR
-- JR Richardson Engineering for the Masses
Give this one a try... I think it's the text version of the pdf you were hoping for:
http://flylib.com/books/en/3.439.1.97/1/
---fred http://qxork.com
On Fri, Oct 15, 2010 at 10:50 AM, Fred Posner fred@teamforrest.com wrote:
On Oct 15, 2010, at 11:42 AM, JR Richardson wrote:
On Fri, Oct 15, 2010 at 10:22 AM, Fred Posner fred@teamforrest.com wrote:
Hey JR...
I use this:
#! /usr/bin/perl -w use IO::Socket; use POSIX 'strftime';
my ($msg,$remotehost,$callid,$socket,$date,$branch,$localip,$dest);
$remotehost = $ARGV[0] or die "FAIL (no host defined)\n";
if ($ARGV[1]) { $remoteport = $ARGV[1]; } else { $remoteport = "5060"; }
if ($ARGV[2]) { $localip = $ARGV[2]; } else { $localip = "127.0.0.1"; }
if ($ARGV[2]) { $dest = $ARGV[3]; } else { $dest = "ping"; }
$socket = IO::Socket::INET->new ( PeerAddr => $remotehost, PeerPort => $remoteport, Proto => 'udp', ) or die "FAIL Could not create socket: $!n";
$callid .= ('0'..'9', "a".."f")[int(rand(16))] for 1 .. 32; $date = strftime('%a, %e %B %Y %I:%M:%S %Z',localtime()); $branch="z9hG4bk" . time();
my $packet = qq(OPTIONS sip:$remotehost SIP/2.0 Via: SIP/2.0/UDP $localip:$remoteport;branch=$branch From: sip:$dest\@$localip To: sip:$remotehost Contact: <sip:$dest@$localip Call-ID: $callid@$localip CSeq: 102 Options User-Agent: sipcheck.pl Date: $date Allow: ACK, CANCEL Content-Length: 0 );
print $socket $packet;
eval { local $SIG{ALRM} = sub { die }; alarm 5; my $sock_addr = recv($socket,$msg,190,0); alarm 0; 1; } or die("FAIL\n");
if ($msg) { print "UP\n"; print "response is $msg\n"; } else { print "FAIL no msg received\n"; } close($socket);
---fred http://qxork.com
Thanks Fred, this works fine, I like the response, you get more info than the 'kamctl ping".
I'm looking more for a utility that I can run in the background and graph latency, that gives me specific time value so I can dump into MRTG.
Any ideas?
JR
-- JR Richardson Engineering for the Masses
Give this one a try... I think it's the text version of the pdf you were hoping for:
http://flylib.com/books/en/3.439.1.97/1/
---fred http://qxork.com
Good find, that's what I needed, it reports back the latency. You have to strip out the leading tabs from the cut and past for the script to work. I looked all over for that in text, you must have super-google.
Thanks a bunch, have a great weekend.
JR h-- JR Richardson Engineering for the Masses
15 okt 2010 kl. 17.42 skrev JR Richardson:
On Fri, Oct 15, 2010 at 10:22 AM, Fred Posner fred@teamforrest.com wrote:
Hey JR...
I use this:
#! /usr/bin/perl -w use IO::Socket; use POSIX 'strftime';
my ($msg,$remotehost,$callid,$socket,$date,$branch,$localip,$dest);
$remotehost = $ARGV[0] or die "FAIL (no host defined)\n";
if ($ARGV[1]) { $remoteport = $ARGV[1]; } else { $remoteport = "5060"; }
if ($ARGV[2]) { $localip = $ARGV[2]; } else { $localip = "127.0.0.1"; }
if ($ARGV[2]) { $dest = $ARGV[3]; } else { $dest = "ping"; }
$socket = IO::Socket::INET->new ( PeerAddr => $remotehost, PeerPort => $remoteport, Proto => 'udp', ) or die "FAIL Could not create socket: $!n";
$callid .= ('0'..'9', "a".."f")[int(rand(16))] for 1 .. 32; $date = strftime('%a, %e %B %Y %I:%M:%S %Z',localtime()); $branch="z9hG4bk" . time();
my $packet = qq(OPTIONS sip:$remotehost SIP/2.0 Via: SIP/2.0/UDP $localip:$remoteport;branch=$branch From: sip:$dest\@$localip To: sip:$remotehost Contact: <sip:$dest@$localip Call-ID: $callid@$localip CSeq: 102 Options User-Agent: sipcheck.pl Date: $date Allow: ACK, CANCEL Content-Length: 0 );
print $socket $packet;
eval { local $SIG{ALRM} = sub { die }; alarm 5; my $sock_addr = recv($socket,$msg,190,0); alarm 0; 1; } or die("FAIL\n");
if ($msg) { print "UP\n"; print "response is $msg\n"; } else { print "FAIL no msg received\n"; } close($socket);
---fred http://qxork.com
Thanks Fred, this works fine, I like the response, you get more info than the 'kamctl ping".
I'm looking more for a utility that I can run in the background and graph latency, that gives me specific time value so I can dump into MRTG.
Any ideas?
JR, if you don't already know SIPSAK, go download it. It's what I use in Nagios and many other scripts. Nils has done a great job with it.
/O