Initial version.

One single start point: run_test.sh
Each test on its directory. Normalized filenames.
vseva/3.0
Victor Seva 13 years ago
commit 7249bab0d1

@ -0,0 +1,131 @@
#!/usr/bin/env python
import io, sys, re
from yaml import load
from pprint import pprint
try:
from yaml import CLoader as Loader
except:
from yaml import Loader
class Test:
""" Class to create TAP output """
_step = []
_errflag = False
def comment(self, msg):
""" Add a comment """
self._step.append({'result': None, 'msg_ok': msg})
def ok(self, msg = None):
""" Add a ok result """
self._step.append({'result': True, 'msg_ok': msg})
def error(self, msg_err):
""" Add an error result"""
self._step.append({'result': False, 'msg_err': msg_err})
self._errflag = True
def test(self, value_expected, value, msg_err, msg_ok = None):
""" Test two values and add the result"""
result = (value_expected == value)
self._step.append({'result': result, 'msg_err': msg_err, 'msg_ok': msg_ok})
if not result:
self._errflag = True
def isError(self):
return self._errflag
def _num_tests(self):
"""get the num of tests"""
test = 0
for s in self._step:
if (s['result'] is not None):
test = test + 1
return test
def __str__(self):
"""get the TAP output"""
output = "1..%s\n" % self._num_tests()
test = 1
for s in self._step:
if (s['result'] is None):
output += '# %s\n' % s['msg_ok']
continue
elif (s['result']):
if (s['msg_ok'] is not None):
output += "ok %d - %s\n" % (test, s['msg_ok'])
else:
output += "ok %d\n" % test
else:
output += "not ok %d - %s\n" % (test, s['msg_err'])
test = test + 1
return output
def check_flow(scen, check, test):
""" checks the flow and the vars inside"""
for i in range(len(scen)):
(sk, sv) = scen[i].popitem()
try:
(ck, cv) = check[i].popitem()
except:
test.error('wrong flow. Expected: %s but is nothing there' % sk)
continue
if(sk != ck):
test.error('wrong flow. Expected: %s but is %s' % (sk, ck))
continue
if sv is None:
test.ok('flow[%s] no var to check' % sk)
continue
else:
test.ok('flow[%s]' % sk)
for k in sv.iterkeys():
if(not cv.has_key(k)):
test.error('Expected var %d on flow[%s]' % (k,sk))
else:
test.test(sv[k], cv[k], 'flow[%s] expected %s == %s but is %s' % (sk, k, sv[k], cv[k]), 'flow[%s] %s' % (sk, k))
if(len(check)>len(scen)):
l = []
for i in check:
for k in i.keys():
l.append(k)
test.error('Expected to end but there are more flows %s' % l)
def check_sip(scen, msg, test):
for rule in scen:
result = re.search(rule, msg)
if result is not None:
test.ok('%s match' % rule)
continue
test.error('%s not match' % rule)
def check_sip_out(scen, msgs, test):
num_msgs = len(msgs)
for i in (range(len(scen))):
if(i<num_msgs):
check_sip(scen[i], msgs[i], test)
else:
test.error("sip_out[%d] does not exist" % i)
if(len(sys.argv)!=3):
print 'Usage: check.py scenario.yml test.yml'
sys.exit(1)
with io.open(sys.argv[1], 'r') as file:
scen = load(file, Loader=Loader)
file.close()
with io.open(sys.argv[2], 'r') as file:
check = load(file, Loader=Loader)
file.close()
test = Test()
test.comment('check flow')
check_flow(scen['flow'], check['flow'], test)
test.comment('check sip_in')
check_sip(scen['sip_in'], check['sip_in'], test)
test.comment('check sip_out')
check_sip_out(scen['sip_out'], check['sip_out'], test)
print test
if test.isError():
sys.exit(1)

@ -0,0 +1,26 @@
#!/usr/bin/perl -wCSD
use strict;
use warnings;
use YAML::Tiny;
my $yaml = YAML::Tiny->new;
my $file = "/etc/ngcp-config/config.yml";
$yaml = YAML::Tiny->read($file) or die "File $file could not be read";
if ($#ARGV eq 0 && lc($ARGV[0]) eq "off")
{
$yaml->[0]->{kamailio}{lb}{debug} = 'no';
$yaml->[0]->{kamailio}{proxy}{debug} = 'no';
$yaml->[0]->{checktools}{sip_check_enable} = 1;
}
else
{
$yaml->[0]->{kamailio}{lb}{debug} = 'no';
$yaml->[0]->{kamailio}{proxy}{debug} = 'yes';
$yaml->[0]->{checktools}{sip_check_enable} = 0;
}
open(my $fh, '>', "$file") or die "Could not open $file for writing";
print $fh $yaml->write_string() or die "Could not write YAML to $file";

@ -0,0 +1,62 @@
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Std;
use Sipwise::Provisioning::Billing;
our %CONFIG = (
admin => 'administrator',
password => 'administrator',
);
die usage() unless ($#ARGV == 0);
sub main {
my ($bprov) = @_;
call_prov( $bprov, 'create_domain',
{
domain => $ARGV[0]
}
);
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($bprov, $function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'admin',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($@) {
if(ref $@ eq 'SOAP::Fault') {
die "Billing\::$function failed: ". $@->faultstring;
} else {
die "Billing\::$function failed: $@";
}
}
return $result;
}
sub usage {
die "Usage:\n$0 <domain>\n".
"\ne.g.: $0 sip.sipwise.com\n";
}
my $bprov = Sipwise::Provisioning::Billing->new();
main($bprov);

@ -0,0 +1,115 @@
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Std;
use Sipwise::Provisioning::Billing;
our %CONFIG = (
admin => 'administrator',
password => 'administrator',
);
our %BILLING = (
# product => 'handle',
billing_profile => 'default',
);
sub usage {
die "Usage:\n$0 -v <#accounts> -s <#subscribers> -d <domain> -u <userbase> -c <cc> -a <ac> -n <startnumber> [-p <password>]\n".
"\ne.g.: $0 -v 200 -s 5 -d sip.sipwise.com -u test -a 720 -n 555000\n\n".
"Options:\n".
" -v <#accounts> how many voip accounts to create\n".
" -s <#subscribers> number of subscribers per voip account\n".
" -d <domain> existing domain for subscribers\n".
" -u <userbase> prefix number with this string for SIP usernames\n".
" -c <cc> country code for subscriber numbers\n".
" -a <ac> area code for subscriber numbers\n".
" -n <startnumber> lowest number in available numberblock\n".
" -p <password> static password for all users\n";
}
my %opts;
getopts('v:s:d:u:c:a:n:p:', \%opts);
die usage() unless defined $opts{v} and defined $opts{s} and defined $opts{d}
and defined $opts{u} and defined $opts{a} and defined $opts{n}
and defined $opts{c};
sub main {
my ($bprov) = @_;
print "$0 ". scalar(localtime time) . " starting\n";
print "\nCreating $opts{v} accounts with $opts{s} subscribers each.\n";
print "Numbers go from +$opts{c}-$opts{a}-$opts{n} to +$opts{c}-$opts{a}-".($opts{n} + ($opts{v} * $opts{s} - 1))."\n";
print "$0 ". scalar(localtime time) . " working\n";
my $foo = $opts{n};
my $i = 0;
my $mod = $opts{s};
$mod *= int(100/$mod) if $mod < 100;
for(1 .. $opts{v}) {
my @subscribers;
for(1 .. $opts{s}) {
push @subscribers, { username => $opts{u} . $foo,
domain => $opts{d},
password => defined $opts{p} ? $opts{p} : $opts{u} . $foo,
cc => $opts{c},
ac => $opts{a},
sn => $foo,
admin => $_ == 1 ? 1 : 0,
};
$foo++;
$i++;
}
call_prov( $bprov, 'create_voip_account',
{
data => {
%BILLING,
subscribers => \@subscribers,
}
}
);
print "Created $i subscribers.\n" unless $i % $mod;
}
print "Created $i subscribers.\n" if $i % 100;
print "$0 ". scalar(localtime time) . " finished\n";
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($bprov, $function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'admin',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($@) {
if(ref $@ eq 'SOAP::Fault') {
die "Billing\::$function failed: ". $@->faultstring;
} else {
die "Billing\::$function failed: $@";
}
}
return $result;
}
my $bprov = Sipwise::Provisioning::Billing->new();
main($bprov);

@ -0,0 +1,62 @@
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Getopt::Std;
use Sipwise::Provisioning::Billing;
our %CONFIG = (
admin => 'administrator',
password => 'administrator',
);
die usage() unless ($#ARGV == 0);
sub main {
my ($bprov) = @_;
call_prov( $bprov, 'delete_domain',
{
domain => $ARGV[0]
}
);
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($bprov, $function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'admin',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($@) {
if(ref $@ eq 'SOAP::Fault') {
die "Billing\::$function failed: ". $@->faultstring;
} else {
die "Billing\::$function failed: $@";
}
}
return $result;
}
sub usage {
die "Usage:\n$0 <domain>\n".
"\ne.g.: $0 sip.sipwise.com\n";
}
my $bprov = Sipwise::Provisioning::Billing->new();
main($bprov);

@ -0,0 +1,60 @@
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use YAML;
use Cwd 'abs_path';
use Data::Dumper;
use GraphViz;
my $g = GraphViz->new();
if($#ARGV!=1)
{
die "usage: show_flow.pl file.yml destfile.png\n";
}
my $filename = abs_path($ARGV[0]);
my $outfilename = $ARGV[1];
my $ylog = YAML::LoadFile($filename);
my @prevs = ();
my $name = '';
my $action = '';
my $prev;
my $cont = 1;
$g->add_node(name => 'END', shape =>'box');
foreach my $i (@{$ylog->{'flow'}})
{
foreach my $key (keys %{$i})
{
#print "$key\n";
if(($action, $name) = ($key =~ m/(exit|start|end)\|(\w+)/))
{
if ($action eq "start")
{
$prev = $prevs[-1];
if ($prev)
{
$g->add_node(name => $name);
$g->add_edge( $prev => $name, label => $cont++);
}
else
{
$g->add_node(name => $name, shape=> 'diamond');
}
push(@prevs, $name);
}
else
{
pop(@prevs); # this is me.
$prev = $prevs[-1];
if ($action eq "end") { $g->add_edge($name => $prev, label => $cont++); }
else { @prevs = (); $g->add_edge($name => 'END', label => $cont++); }
}
}
}
}
$g->as_png($outfilename);
#EOF

@ -0,0 +1,6 @@
#!/bin/sh
#ngcpcfg build /etc/kamailio/proxy/
invoke-rc.d kamailio-proxy stop
rm -rf /var/log/ngcp/kamailio-proxy.log
invoke-rc.d rsyslog restart
invoke-rc.d kamailio-proxy start

@ -0,0 +1,28 @@
#!/bin/bash
BASE_DIR="/usr/local/src/log_parser"
while getopts 'ct' opt; do
case $opt in
c) SKIP=1;;
t) TEST=1;;
esac
done
if [ -z $SKIP ]; then
${BASE_DIR}/config_debug.pl
ngcpcfg apply
fi
rm -rf ${BASE_DIR}/result/*
for t in $(find ${BASE_DIR}/scenarios/ -depth -maxdepth 1 -mindepth 1 -type d ); do
echo "Run: $(basename $t)"
if [ -z $TEST ]; then
bash ${BASE_DIR}/scenarios/check.sh $(basename $t)
fi
done
if [ -z $SKIP ]; then
${BASE_DIR}/config_debug.pl off
ngcpcfg apply
fi

@ -0,0 +1,2 @@
SEQUENTIAL
testuser1003;4311003;[authentication username=testuser1003 password=testuser];127.0.0.1
1 SEQUENTIAL
2 testuser1003;4311003;[authentication username=testuser1003 password=testuser];127.0.0.1

@ -0,0 +1,2 @@
SEQUENTIAL
testuser1002;[authentication username=testuser1002 password=testuser];127.0.0.1
1 SEQUENTIAL
2 testuser1002;[authentication username=testuser1002 password=testuser];127.0.0.1

@ -0,0 +1,122 @@
#!/bin/bash
# $1 kamailio msg parsed to yml
# $2 destination png filename
function graph
{
if [ -f $1 ]; then
${BASE_DIR}/graph_flow.pl $1 $2
fi
}
# $1 unit test yml
# $2 kamailio msg parsed to yml
# $3 destination tap filename
function check_test
{
if [ ! -f $1 ]; then
echo "File $1 does not exists"
return
fi
if [ ! -f $2 ]; then
echo "File $2 does not exists"
return
fi
echo -n "Testing $1 againts $2 -> $3"
${BASE_DIR}/check.py $1 $2 > $3
if [[ $? -ne "0" ]]; then
echo " not ok"
else
echo " ok"
fi
}
# $1 domain
function create_voip
{
${BASE_DIR}/create_domain.pl $1
${BASE_DIR}/create_subscribers.pl -v 1 -s 3 -d $1 -u testuser -c 43 -a 1 -n 1001 -p testuser
}
# $1 prefs yml file
function create_voip_prefs
{
if [ -f $1 ]; then
${BASE_DIR}/set_subscribers_preferences.pl $1
fi
}
# $1 domain
function delete_voip
{
${BASE_DIR}/delete_domain.pl $1
}
# $1 sipp xml scenario file
function run_sipp
{
# test LOG_DIR
# we dont want to remove "/*" don't we?
if [ -z ${LOG_DIR} ]; then
echo "LOG_DIR empty"
exit 1
fi
rm -rf ${LOG_DIR}
mkdir -p ${LOG_DIR}
${BASE_DIR}/restart_log.sh
# let's fire sipp scenario
${BASE_DIR}/sipp.sh $1
status=$?
# copy the kamailio log
cp ${KAM_LOG} ${LOG_FILE} ${LOG_DIR}/kamailio.log
if [[ $status -ne 0 ]]; then
echo "error in sipp"
find ${SCEN_CHECK_DIR}/ -type f -name 'sipp_scenario*errors.log' -exec mv {} ${LOG_DIR} \;
exit 2
fi
echo "Parsing ${LOG_DIR}/kamailio.log"
${BASE_DIR}/ulog_parser.pl ${LOG_DIR}/kamailio.log ${LOG_DIR}
}
while getopts 'c' opt; do
case $opt in
c) SKIP=1;;
esac
done
shift $(($OPTIND - 1))
if [[ $# != 1 ]]; then
echo "usage: $0 check_name"
exit 1
fi
NAME_CHECK="$1"
BASE_DIR="/usr/local/src/log_parser"
LOG_DIR="${BASE_DIR}/log/${NAME_CHECK}"
RESULT_DIR="${BASE_DIR}/result/${NAME_CHECK}"
KAM_LOG="/var/log/ngcp/kamailio-proxy.log"
SCEN_DIR="${BASE_DIR}/scenarios"
SCEN_CHECK_DIR="${SCEN_DIR}/${NAME_CHECK}"
DOMAIN="127.0.0.1"
if [ -z $SKIP ]; then
delete_voip ${DOMAIN} # just to be sure nothing is there
create_voip ${DOMAIN}
create_voip_prefs ${SCEN_CHECK_DIR}/prefs.yml
run_sipp ${SCEN_CHECK_DIR}/sipp_scenario.xml
delete_voip ${DOMAIN}
fi
# let's check the results
mkdir -p ${RESULT_DIR}
for t in ${SCEN_CHECK_DIR}/*_test.yml; do
msg=$(echo $t|sed 's/_test\.yml/\.yml/')
check_test $t ${LOG_DIR}/$(basename $msg) ${RESULT_DIR}/$(basename $t .yml).tap
graph $msg ${RESULT_DIR}/$(basename $msg .yml).png
done
#EOF

@ -0,0 +1,27 @@
# REGISTER scenario
flow:
- start|MAIN:
- start|ROUTE_NET_INFO:
- end|ROUTE_NET_INFO:
- start|ROUTE_PRX_REQUEST:
- start|ROUTE_INVITE:
- start|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- end|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- exit|ROUTE_AUTH:
sip_in:
- '^INVITE'
- 'Contact: sip:testuser2@'
- 'CSeq: 1 INVITE'
- 'Max-Forwards: 16'
- 'Content-Type: application/sdp'
sip_out:
- [
'^SIP/2.0 100 Trying',
'CSeq: 1 INVITE'
]
- [
'^SIP/2.0 407 Proxy Authentication Required',
'CSeq: 1 INVITE'
]

@ -0,0 +1,80 @@
# REGISTER scenario
flow:
- start|MAIN:
- start|ROUTE_NET_INFO:
- end|ROUTE_NET_INFO:
- start|ROUTE_PRX_REQUEST:
- start|ROUTE_INVITE:
- start|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- end|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_AUTH:
- end|ROUTE_FIND_CALLER:
- start|ROUTE_LOAD_CALLER_PREF:
- start|ROUTE_CLEAR_CALLER_PREF:
- end|ROUTE_CLEAR_CALLER_PREF:
- end|ROUTE_LOAD_CALLER_PREF:
- start|ROUTE_GET_CALLER_CLI:
- end|ROUTE_GET_CALLER_CLI:
- start|ROUTE_GET_FORWARDER_CLI:
- return|ROUTE_GET_FORWARDER_CLI:
- start|ROUTE_CHECK_USERPROV_CLI:
- start|ROUTE_CHECK_CLI_ALLOWED:
- end|ROUTE_CHECK_CLI_ALLOWED:
- end|ROUTE_CHECK_USERPROV_CLI:
- start|ROUTE_CLIR:
- end|ROUTE_CLIR:
- start|ROUTE_FIND_CALLEE:
- start|ROUTE_CLEAR_CALLEE_PREF:
- end|ROUTE_CLEAR_CALLEE_PREF:
- start|ROUTE_NCOS:
- end|ROUTE_NCOS:
- start|ROUTE_NCOS:
- end|ROUTE_NCOS:
- start|ROUTE_BLOCK_OUT:
- end|ROUTE_BLOCK_OUT:
- start|ROUTE_LOAD_CALLEE_PREF:
- start|ROUTE_BLOCK_IN:
- end|ROUTE_BLOCK_IN:
- end|ROUTE_LOAD_CALLEE_PREF:
- start|ROUTE_INVITE_TO_INT:
- start|ROUTE_ACC_FAILURE:
- start|ROUTE_ACC_CALLER:
- end|ROUTE_ACC_CALLER:
- start|ROUTE_ACC_CALLEE:
- end|ROUTE_ACC_CALLEE:
- end|ROUTE_ACC_FAILURE:
- start|ROUTE_EARLY_REJECT:
- start|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_ADD_CALLINFO_REPLY:
- exit|ROUTE_EARLY_REJECT:
sip_in:
- '^INVITE'
- 'Contact: sip:testuser2@'
- 'CSeq: 2 INVITE'
- 'Max-Forwards: 16'
- 'Content-Type: application/sdp'
- 'Proxy-Authorization: Digest username="testuser2"'
sip_out:
- [
'^SIP/2.0 100 Trying',
'CSeq: 2 INVITE',
'From: <sip:testuser2@'
]
- [
'^SIP/2.0 101 Connecting',
'CSeq: 2 INVITE',
'From: <sip:testuser2@',
'P-NGCP-Authorization: testuser2',
'P-NGCP-Authorized: 1'
]
- [
'^SIP/2.0 480 Offline',
'CSeq: 2 INVITE',
'From: <sip:testuser2@',
'P-NGCP-Authorization: testuser2',
'P-NGCP-Authorized: 1'
]

@ -0,0 +1,76 @@
# REGISTER scenario
flow:
- start|MAIN:
- start|ROUTE_NET_INFO:
- end|ROUTE_NET_INFO:
- start|ROUTE_PRX_REQUEST:
- start|ROUTE_INVITE:
- start|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- end|ROUTE_LOAD_CALLEE_DOMAIN_PREF:
- start|ROUTE_FIND_CALLER:
- start|ROUTE_AUTH:
- start|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_AUTH:
- end|ROUTE_FIND_CALLER:
- start|ROUTE_LOAD_CALLER_PREF:
- start|ROUTE_CLEAR_CALLER_PREF:
- end|ROUTE_CLEAR_CALLER_PREF:
- end|ROUTE_LOAD_CALLER_PREF:
- start|ROUTE_GET_CALLER_CLI:
- end|ROUTE_GET_CALLER_CLI:
- start|ROUTE_GET_FORWARDER_CLI:
- return|ROUTE_GET_FORWARDER_CLI:
- start|ROUTE_CHECK_USERPROV_CLI:
- start|ROUTE_CHECK_CLI_ALLOWED:
- end|ROUTE_CHECK_CLI_ALLOWED:
- end|ROUTE_CHECK_USERPROV_CLI:
- start|ROUTE_CLIR:
- end|ROUTE_CLIR:
- start|ROUTE_FIND_CALLEE:
- start|ROUTE_CLEAR_CALLEE_PREF:
- end|ROUTE_CLEAR_CALLEE_PREF:
- start|ROUTE_NCOS:
- end|ROUTE_NCOS:
- start|ROUTE_NCOS:
- end|ROUTE_NCOS:
- start|ROUTE_BLOCK_OUT:
- end|ROUTE_BLOCK_OUT:
- start|ROUTE_LOAD_CALLEE_PREF:
- start|ROUTE_BLOCK_IN:
- end|ROUTE_BLOCK_IN:
- end|ROUTE_LOAD_CALLEE_PREF:
- start|ROUTE_INVITE_TO_INT:
- start|ROUTE_ACC_FAILURE:
- start|ROUTE_ACC_CALLER:
- end|ROUTE_ACC_CALLER:
- start|ROUTE_ACC_CALLEE:
- end|ROUTE_ACC_CALLEE:
- end|ROUTE_ACC_FAILURE:
- start|ROUTE_EARLY_REJECT:
- start|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_ADD_CALLINFO_REPLY:
- exit|ROUTE_EARLY_REJECT:
sip_in:
- '^INVITE'
- 'Contact: sip:testuser2@'
- 'CSeq: 2 INVITE'
- 'Max-Forwards: 16'
- 'Content-Type: application/sdp'
- 'Proxy-Authorization: Digest username="testuser2"'
sip_out:
- [
'^SIP/2.0 100 Trying',
'CSeq: 2 INVITE',
'From: <sip:testuser2@'
]
- [
'^SIP/2.0 101 Connecting',
'CSeq: 2 INVITE',
'From: <sip:testuser2@'
]
- [
'^SIP/2.0 480 Offline',
'CSeq: 2 INVITE',
'From: <sip:testuser2@'
]

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<scenario name="Sipwise NGCP Benchmark UAC Caller">
<send retrans="500" start_rtd="1" start_rtd="2">
<![CDATA[
INVITE sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 1 INVITE
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
]]>
</send>
<recv response="100" rtd="1" optional="true">
</recv>
<recv response="407" rtd="2" auth="true"/>
<send>
<![CDATA[
ACK sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]:[remote_port] SIP/2.0
[last_Via:]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<send retrans="500" start_rtd="3">
<![CDATA[
INVITE sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 2 INVITE
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
[field1 file="caller.csv"]
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="180" optional="true">
</recv>
<recv response="183" optional="true">
</recv>
<recv response="480" rrs="true" rtd="3">
</recv>
<send>
<![CDATA[
ACK sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]:[remote_port] SIP/2.0
[last_Via:]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<send retrans="500" start_rtd="3">
<![CDATA[
INVITE sip:[field1 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field1 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 2 INVITE
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
[field1 file="caller.csv"]
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8
a=rtpmap:8 PCMA/8000
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="180" optional="true">
</recv>
<recv response="183" optional="true">
</recv>
<recv response="480" rrs="true" rtd="3">
</recv>
<send>
<![CDATA[
ACK sip:[field1 file="callee.csv"]@[field3 file="callee.csv"]:[remote_port] SIP/2.0
[last_Via:]
From: <sip:[field0 file="caller.csv"]@[field2 file="caller.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field1 file="callee.csv"]@[field3 file="callee.csv"]>[peer_tag_param]
Call-ID: [call_id]
CSeq: 1 ACK
Contact: sip:[field0 file="caller.csv"]@[local_ip]:[local_port]
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200, 500, 1000"/>
<!-- <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/> >
</scenario>

@ -0,0 +1,25 @@
# REGISTER scenario
flow:
- start|MAIN:
$fU: testuser1003
$tU: testuser1003
- start|ROUTE_NET_INFO:
$fU: testuser1003
$tU: testuser1003
- end|ROUTE_NET_INFO:
- start|ROUTE_AUTH:
- exit|ROUTE_AUTH:
sip_in:
- '^REGISTER'
- 'Contact: sip:testuser1003@'
- 'Content-Length: 0'
- 'Expires: 600'
sip_out:
- [
'^SIP/2.0 100 Trying',
'Content-Length: 0'
]
- [
'^SIP/2.0 401 Unauthorized',
'Content-Length: 0'
]

@ -0,0 +1,30 @@
# REGISTER scenario
flow:
- start|MAIN:
$fU: testuser1003
$tU: testuser1003
- start|ROUTE_NET_INFO:
$fU: testuser1003
$tU: testuser1003
- end|ROUTE_NET_INFO:
- start|ROUTE_AUTH:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_AUTH:
sip_in:
- '^REGISTER'
- 'Contact: sip:testuser1003@'
- 'Content-Length: 0'
- 'Expires: 600'
- 'Authorization: Digest username="testuser1003"'
sip_out:
- [
'^SIP/2.0 100 Trying',
'Content-Length: 0'
]
- [
'^SIP/2.0 200 OK',
'Content-Length: 0',
'P-NGCP-Authorization: testuser1003@',
'P-NGCP-Authorized: 1'
]

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Sipwise NGCP Benchmark UAS Registration">
<send>
<![CDATA[
REGISTER sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 1 REGISTER
Contact: sip:[field0 file="callee.csv"]@[local_ip]:50603
Expires: 600
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<recv response="100"
optional="true">
</recv>
<recv response="401" auth="true"/>
<send>
<![CDATA[
REGISTER sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 2 REGISTER
[field2 file="callee.csv"]
Contact: sip:[field0 file="callee.csv"]@[local_ip]:50603
Expires: 600
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="200">
</recv>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
</scenario>

@ -0,0 +1,27 @@
# REGISTER scenario
flow:
- start|MAIN:
$fU: testuser1003
$tU: testuser1003
- start|ROUTE_NET_INFO:
$fU: testuser1003
$tU: testuser1003
- end|ROUTE_NET_INFO:
- start|ROUTE_REG_REQUEST:
- start|ROUTE_REG_HANDLE:
- start|ROUTE_AUTH:
- exit|ROUTE_AUTH:
sip_in:
- '^REGISTER'
- 'Contact: sip:testuser1003@'
- 'Content-Length: 0'
- 'Expires: 600'
sip_out:
- [
'^SIP/2.0 100 Trying',
'Content-Length: 0'
]
- [
'^SIP/2.0 401 Unauthorized',
'Content-Length: 0'
]

@ -0,0 +1,84 @@
# REGISTER scenario
flow:
- start|MAIN:
$fU: testuser1003
$tU: testuser1003
- start|ROUTE_NET_INFO:
$fU: testuser1003
$tU: testuser1003
- end|ROUTE_NET_INFO:
- start|ROUTE_REG_REQUEST:
- start|ROUTE_REG_HANDLE:
- start|ROUTE_AUTH:
- start|ROUTE_ADD_CALLINFO_REPLY:
- return|ROUTE_ADD_CALLINFO_REPLY:
- end|ROUTE_AUTH:
- start|ROUTE_PREFERENCES:
- exit|ROUTE_PREFERENCES:
$xavp(callee_dom_prefs):
- dummy:
- callee
$xavp(callee_peer_prefs):
- dummy:
- callee
$xavp(callee_real_prefs):
- dummy:
- callee
$xavp(callee_usr_prefs):
- dummy:
- callee
$xavp(caller_dom):
- dummy:
- caller
$xavp(caller_dom_prefs):
- dummy:
- caller
$xavp(caller_peer_prefs):
- dummy:
- caller
$xavp(caller_real_prefs):
- ac:
- 1
account_id:
- 43
allowed_ips_grp:
- 1
- 2
cc:
- 43
cli:
- 4311003
dummy:
- caller
man_allowed_ips_grp:
- 0
$xavp(caller_usr_prefs):
- ac:
- 1
account_id:
- 43
allowed_ips_grp:
- 1
cc:
- 43
cli:
- 4311003
dummy:
- caller
sip_in:
- '^REGISTER'
- 'Contact: sip:testuser1003@'
- 'Content-Length: 0'
- 'Expires: 600'
- 'Authorization: Digest username="testuser1003"'
sip_out:
- [
'^SIP/2.0 100 Trying',
'Content-Length: 0'
]
- [
'^SIP/2.0 403 Unauthorized IP detected',
'Content-Length: 0',
'P-NGCP-Authorization: testuser1003@',
'P-NGCP-Authorized: 1'
]

@ -0,0 +1,2 @@
testuser1003@127.0.0.1:
allowed_ips: [ "1.2.3.4" ]

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="Sipwise NGCP Benchmark UAS Registration">
<send>
<![CDATA[
REGISTER sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 1 REGISTER
Contact: sip:[field0 file="callee.csv"]@[local_ip]:50603
Expires: 600
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<recv response="100"
optional="true">
</recv>
<recv response="401" auth="true"/>
<send>
<![CDATA[
REGISTER sip:[field0 file="callee.csv"]@[field3 file="callee.csv"] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>;tag=[pid]SIPpTag00[call_number]
To: <sip:[field0 file="callee.csv"]@[field3 file="callee.csv"]>
Call-ID: [call_id]
CSeq: 2 REGISTER
[field2 file="callee.csv"]
Contact: sip:[field0 file="callee.csv"]@[local_ip]:50603
Expires: 600
Max-Forwards: 70
Content-Length: 0
]]>
</send>
<recv response="100" optional="true">
</recv>
<recv response="403">
</recv>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
</scenario>

@ -0,0 +1,71 @@
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use Getopt::Std;
use Sipwise::Provisioning::Billing;
use Cwd 'abs_path';
use YAML;
my %CONFIG = (
admin => 'administrator',
password => 'administrator',
);
sub main;
sub usage;
sub call_prov;
die usage() unless ($#ARGV == 0);
my $bprov = Sipwise::Provisioning::Voip->new();
main;
sub main {
my $filename = abs_path($ARGV[0]);
my $prefs = YAML::LoadFile($filename);
for my $key (keys $prefs)
{
my @fields = split /@/, $key;
my $pref = { username => $fields[0], domain => $fields[1], preferences => $prefs->{$key} };
print "Setting $key prefs\n";
print Dumper $pref;
call_prov( 'set_subscriber_preferences', $pref);
}
exit;
}
sub call_prov {
# scalar, scalar, hash-ref
my ($function, $parameter) = @_;
my $result;
eval {
$result = $bprov->handle_request( $function,
{
authentication => {
type => 'admin',
username => $CONFIG{admin},
password => $CONFIG{password},
},
parameters => $parameter,
});
};
if($@) {
if(ref $@ eq 'SOAP::Fault') {
die "Billing\::$function failed: ". $@->faultstring;
} else {
die "Billing\::$function failed: $@";
}
}
return $result;
}
sub usage {
die "Usage:\n$0 prefs.yml\n";
}

@ -0,0 +1,23 @@
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use YAML;
use Cwd 'abs_path';
use Data::Dumper;
if($#ARGV!=0)
{
die "usage: show_flow.pl file.yml\n";
}
my $filename = abs_path($ARGV[0]);
my $ylog = YAML::LoadFile($filename);
foreach my $i (@{$ylog->{'flow'}})
{
foreach my $key (keys %{$i})
{
print "$key\n";
}
}
#EOF

@ -0,0 +1,14 @@
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Usage: sipp.sh scenario.xml"
exit 1
fi
if [ ! -f $1 ]; then
echo "No $1 file found"
exit 1
fi
BASE_DIR=$(dirname $1)
IP="127.0.0.1"
PORT="50603"
sipp -inf ${BASE_DIR}/../callee.csv -inf ${BASE_DIR}/../caller.csv -sf $1 -i $IP \
-nd -t ul -p $PORT $IP -m 1 -timeout 15 -timeout_error -trace_err

@ -0,0 +1,106 @@
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use JSON;
use YAML;
use File::Spec;
use Cwd 'abs_path';
use Data::Dumper;
my $filename = "/var/log/ngcp/kamailio-proxy.log";
my $output_dir = "log";
my $path;
my $data = {
msgid => '',
callid => '',
flow => [],
sip_in => '',
sip_out => [],
};
sub save_data
{
if(!$data->{'msgid'})
{
print "data with no msgid\n";
print Dumper $data;
exit;
}
else
{
if (!$data->{'sip_out'}) { print "no sip_out\n"; }
$path = File::Spec->catfile( $output_dir, (sprintf "%04i", $data->{'msgid'}).".yml");
YAML::DumpFile($path, $data);
#print "$data->{'msgid'} saved\n";
}
$data = {
msgid => '',
callid => '',
flow => [],
sip_in => '',
sip_out => [],
};
}
if($#ARGV>=2)
{
die "usage: $#ARGV log_parser.pl [kamailio_log] [dest_dir]\n";
}
given($#ARGV)
{
when (1) { $filename = $ARGV[0]; $output_dir = $ARGV[1]; }
when (0) { $filename = $ARGV[0]; }
}
$filename = abs_path($filename);
$output_dir = abs_path($output_dir);
my $log;
my $line;
my $out;
open($log, "<$filename") or die "Couldn't open kamailio log, $!";
while($line = <$log>)
{
my ($pid, $mode, $route, $msgid, $msgid_t, $pid_t, $json, $msg, $pjson, $callid, $method);
# Jun 25 14:52:16 spce proxy[11248]: DEBUG: debugger [debugger_api.c:427]: dbg_cfg_dump(): msg out:{
if(($msg) = ($line =~ m/.+msg out:{(.+)}$/))
{
do
{
$msg =~ s/#015#012/\n/g;
push($data->{'sip_out'}, $msg);
$line = <$log>;
if(!$line) { $line = '' }
}while(($msg) = ($line =~ m/.+msg out:{(.+)}$/));
#print "msg_out\n";
}
if(($pid, $mode, $route, $msgid, $method) = ($line =~ m/.+proxy\[(\d+)\]: DEBUG: <script>: (\w+) of route (\w+) - (\d+) (.*)$/))
{
if($route eq "MAIN")
{
#if ($mode eq "start") { print "$msgid start MAIN\n"; }
if(($data->{'msgid'}) && ($data->{'msgid'} ne $msgid)) {
#print "$msgid!=$data->{'msgid'} MAIN->save\n";
save_data();
}
$data->{'msgid'} = $msgid;
}
$line = <$log>;
if(($pid_t, $json) = ($line =~ m/.+proxy\[(\d+)\]: DEBUG: debugger \[debugger_api\.c:\w+\]: dbg_dump_json\(\): (\{.*\})$/))
{
$pjson = from_json($json);
push($data->{'flow'}, { $mode."|".$route => $pjson });
if ($route eq "MAIN" && $mode eq "start")
{
($msg) = $method;
if(($callid) = ($msg =~ m/.+Call-ID: ([^#]+)#015#012.+$/si)) { $data->{'callid'} = $callid; }
$msg =~ s/#015#012/\n/g;
if($mode eq "start") { $data->{'sip_in'} = $msg; }
}
}
}
} #while
if($data->{'msgid'} ne '') { save_data(); }
close($log);
#EOF
Loading…
Cancel
Save