IAX2 ping tool

  1. !/usr/bin/perl -w
  2. udp ping tool

use IO::Socket;
$target = shift; #"192.168.0.255";
$target_port = 4569;

socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp"));

  1. Build Packet ...
  2. Names from ethereal filter of registration packet

$src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc...
$dst_call = "0000";
$timestamp = "00000000";
$outbound_seq = "00";
$inbound_seq = "00";
$type = "06"; #IAX_Control
$iax_type = "1e"; #POKE
$msg = pack "H24", $src_call . $dst_call . $timestamp . $outbound_seq . $inbound_seq . $type . $iax_type;

  1. Send UDP packet

$ipaddr = inet_aton($target);
$sendto = sockaddr_in($target_port,$ipaddr);

send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $target : $target_port : $!\n";

  1. Listen for responses... listen for TIMEOUT seconds and report all responders (works for broadcast pings)

$MAXLEN = 1024;
$TIMEOUT = 5;

eval {
local $SIG{ALRM} = sub { die "alarm time out"; };
alarm $TIMEOUT;

while (1) {
$recvfrom = recv(PING, $msg, $MAXLEN, 0) or die "recv: $!";
($port, $ipaddr) = sockaddr_in($recvfrom);
$respaddr = inet_ntoa($ipaddr);
print "Response from $respaddr : $port\n";
}

};

  1. !/usr/bin/perl -w
  2. udp ping tool

use IO::Socket;
$target = shift; #"192.168.0.255";
$target_port = 4569;

socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp"));

  1. Build Packet ...
  2. Names from ethereal filter of registration packet

$src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc...
$dst_call = "0000";
$timestamp = "00000000";
$outbound_seq = "00";
$inbound_seq = "00";
$type = "06"; #IAX_Control
$iax_type = "1e"; #POKE
$msg = pack "H24", $src_call . $dst_call . $timestamp . $outbound_seq . $inbound_seq . $type . $iax_type;

  1. Send UDP packet

$ipaddr = inet_aton($target);
$sendto = sockaddr_in($target_port,$ipaddr);

send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $target : $target_port : $!\n";

  1. Listen for responses... listen for TIMEOUT seconds and report all responders (works for broadcast pings)

$MAXLEN = 1024;
$TIMEOUT = 5;

eval {
local $SIG{ALRM} = sub { die "alarm time out"; };
alarm $TIMEOUT;

while (1) {
$recvfrom = recv(PING, $msg, $MAXLEN, 0) or die "recv: $!";
($port, $ipaddr) = sockaddr_in($recvfrom);
$respaddr = inet_ntoa($ipaddr);
print "Response from $respaddr : $port\n";
}

};

Created by: nezer, Last modification: Thu 13 of Oct, 2005 (15:16 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+