Asterisk, and other worldly endeavours.

A blog by Leif Madsen

Load testing SIP registrations with SIPp

Today I had a need to go and load a bunch of registrations into Asterisk for a bug I was working on. Since I’ve had this need a couple of times now, and I keep going and having to redevelop it, I think I’ll just write about it here, and then when I need it again, I can just look it up. Maybe this will be useful for someone else as well.

First of all, this is all based on the post I found on the SipX wiki. You can read the page I based this all off of here. Lots of good info there. All I’m really adding of value is the PHP scripts I used to generate the peers in the database, and the register_client.csv file.

First, lets load a bunch of peers into Asterisk. I’m loading peers numbered 101 –> 199.


if (!$link = mysql_connect('localhost','asterisk','asterisk')) {
	echo "Could not connect\n";

if (!mysql_select_db('asterisk',$link)) {
	echo "Could not get into database\n";

for($counter = 100; $counter <= 199; $counter++) {
	$sql = "INSERT INTO sipfriends (type,name,username,secret,context,canreinvite,nat,host,mailbox,dtmfmode,disallow,allow) VALUES ('friend','$counter','$counter','welcome','start','no','yes','dynamic','$counter@default','rfc2833','all','ulaw')";
	echo $sql."\n";
	$result = mysql_query($sql,$link);
	if (!$result) {
		echo "DB error " . mysql_error();



Next, we need to generate the register_client.csv file in order to tell SIPp which peers to authenticate, and how.


$myFile = "register_client.csv";
$fh = fopen($myFile, w);

for ($counter = 100; $counter <= 199; $counter++) {
	$data = "$counter;;&#91;authentication username=$counter password=welcome&#93;;\n";
	fwrite($fh, $data);



And finally, here is the line used to send a bunch of registrations to Asterisk. If you want to do a load test, you may need to adjust the numbers so it does a better job of “blasting” the end point you want to test.

sipp -sf register_client.xml -inf register_client.csv -r 10 -trace_err -trace_stat -nd -fd 1 -i <source_ip> <destination_ip>

If you have any questions, just ask, and I’ll try to comment here. This post is potentially light on specifics since these are notes for my future reference.

Written by Leif Madsen

2009/07/29 at 11:34 am

Posted in Asterisk

Tagged with , , , ,

6 Responses

Subscribe to comments with RSS.

  1. I was just looking for something like this last night, how timely of you!


    2009/07/29 at 11:46 am

  2. i want to test up to 5 million . what can i do?


    2010/12/03 at 3:15 pm

  3. Hello,

    I have my script written in php and I want to test it over SIPp …what should I do?



    2012/01/16 at 6:32 am

    • While I don’t provide support on these posts (they are more for my own notes to look back in case I need it again, and for those who can help themselves), but regardless, unfortunately you haven’t really provided enough information to know what it is that you are trying to do, or how I could help.

      Leif Madsen

      2012/01/16 at 8:14 am

  4. How to execute script ….Should I put some code in php or I can do did with some command in SIPp?


    2012/01/16 at 6:34 am

Comments are closed.

%d bloggers like this: