Testing SIP server (Proxy, Registrar, B2BUA…) using SIPp. We use a remote connection (ssh) to connect to the client UAC from our server. All ssh connections could be without password in authentification. UAC generates calls. The Other side UAS is always running and respond. The reason why we run the script from the server is monitoring its performance via SAR. All testing is automated by cycle in script.
Packages & Libraries
Server:
SAR (System activity reporter)
apt-get install sysstat
Kamailio
manual registration users (sipp, uas) and add to AOR
SSH
apt-get install ssh
Client:
Killall
apt-get install killall5
SIPp call genarator
SSH
apt-get install ssh
Screen
apt-get install screen
Script
#!/bin/bash #test time duration [seconds] DURATION=300 # TCP or UDP transport DUT_IP=158.193.152.2 DUT_PORT=5060 UAC_IP=158.193.139.67 UAC_PORT=5060 SOURCE_XML_DIR="/root/scenario/uac/" SOURCE_XML_FILE="uac_s_auth.xml" SOURCE_XML_DATA="data.txt" #test call duration [second] CALL_DURATION=5000 # define of For cycle # from with step to for RATE in `seq 100 100 400` `seq 410 10 600` do ssh -i /root/.ssh/id_rsa root@${UAC_IP} screen -dmS root sipp.svn/sipp -sf ${SOURCE_XML_DIR}/${SOURCE_XML_FILE} -inf ${SOURCE_XML_DIR}/${SOURCE_XML_DATA} -i ${UAC_IP} -p ${UAC_PORT} ${DUT_IP}:${DUT_PORT} -trace_stat -trace_rtt -fd 1 -rtt_freq 1 -d ${CALL_DURATION} -t u1 -r ${RATE} -m `expr ${RATE} "*" ${DURATION}` # save SIPp satatistics ssh -i /root/.ssh/id_rsa root@${UAC_IP} screen -dmS root mv ${SOURCE_XML_DIR}/${SOURCE_XML_FILE}_*_.csv ${SOURCE_XML_DIR}/${RATE}.csv ssh -i /root/.ssh/id_rsa root@${UAC_IP} screen -dmS root mv ${SOURCE_XML_DIR}/${SOURCE_XML_FILE}_*_rtt.csv ${SOURCE_XML_DIR}/${RATE}-rtt.csv # save SAR statistics sar -u -r 1 $((DURATION+5)) > sar${RATE}.txt # kill running SIPp process, cause of failed calls after Call duration ssh -i /root/.ssh/id_rsa root@${UAC_IP} killall sipp # end of For cycle done
Topology
Scenario
Creating XML file for INVITE scenario with autentification and media:
UAC UAS | INVITE | |------------------>|------- | 100 (optional) | /\ |<------------------| ||SRD | 180 (optional) | \/ |<------------------|------- | 200 | |<------------------| | ACK | |------------------>| | | | RTP send (8s) | |==================>| | | | RFC2833 DIGIT 1| |==================>| | | | BYE | |------------------>|------- | | /\ | 200 | \/SDD |<------------------|-------
A scenario will always start with:
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE scenario SYSTEM "sipp.dtd"> <scenario name="UAC s autentifikaciou">
And end with:
</scenario>
Set retransmission time with value 500ms when call fail and starts one of the RTD(Response Time Duration) timer. In this case RTD means SRD(Session request delay).
<send retrans="500" start_rtd="1">
Inside the "send" command, you have to enclose your SIP message between the "<![CDATA" and the "]]>" tags. Everything between those tags is going to be sent toward the remote system. You may have noticed that there are strange keywords in the SIP message, like [field0], [remote_ip], …. Those keywords are used to indicate to SIPp that it has to do something with it. All keywords list is online at official SIPp page.
<![CDATA[ <INVITE sip:[field0]@[remote_ip]:[remote_port] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] From: "[field1]" <sip:[field1]@[field2]>;tag=[pid]SIPpTag00[call_number]To: <sip:[field0]@[remote_ip]:[remote_port]> Call-ID: [call_id] Contact: <sip:[field1]@[local_ip]>:[local_port]> CSeq: 801 INVITE Max-Forwards: 70 Allow: INVITE,CANCEL,ACK,BYE,NOTIFY,REFER,OPTIONS,INFO,MESSAGE Supported: replaces Content-Type: application/sdp User-Agent: ATA Content-Length: [len] v=0 o=CMI-SIPUA 61838 0 IN IP[local_ip_type] [local_ip] s=SIP CALL c=IN IP[media_ip_type] [media_ip] t=0 0 m=audio [auto_media_port] RTP/AVP 8 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-11,16 ]]> </send>
Tag <recv> indicates what SIP message is expected. Response means message code, auth means authentication. If this attribute is set to "true", then the "Proxy-Authenticate:" header of the message received is stored and is used to build the [authentication] keyword. You can put a "next" in any command element to go to another part of the script when you are done with sending the message. For optional receives, the next is only taken if that message was received.
<recv response="401" auth="true" next="auth_required" optional="true"/> <recv response="407" auth="true" next="auth_required"/> <label id="auth_required" />
Again message for ackonowledge with all keywords into
<send> <![CDATA[ ACK sip:[field0]@[remote_ip]:[remote_port] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch-2] [last_From:] [last_To:] [last_Call-ID:] Contact: <sip:[field1]@[local_ip]:[local_port]> CSeq: 801 ACK Max-Forwards: 70 User-Agent: ATA Content-Length: 0 ]]> </send>
<send retrans="500" start_rtd="1">
<![CDATA[ <INVITE sip:[field0]@[remote_ip]:[remote_port] SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] From: "[field1]" <sip:[field1]@[field2]>;tag=[pid]SIPpTag00[call_number] To: <sip:[field0]@[remote_ip]:[remote_port]> Call-ID: [call_id] Contact: <sip:[field1]@[local_ip]:[local_port]> CSeq: 802 INVITE [field3] Max-Forwards: 70 Allow: INVITE,CANCEL,ACK,BYE,NOTIFY,REFER,OPTIONS,INFO,MESSAGE Supported: replaces Content-Type: application/sdp User-Agent: ATA Content-Length: [len] v=0 o=CMI-SIPUA 61838 0 IN IP[local_ip_type] [local_ip] s=SIP CALL c=IN IP[media_ip_type] [media_ip] t=0 0 m=audio [auto_media_port] RTP/AVP 8 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-11,16 ]]> </send>
End first of the RTD timer.
<recv response="100" optional="true"> </recv> <recv response="180" optional="true" rtd="1"> </recv> <recv response="200" rrs="true"> </recv>
<send> <![CDATA[ ACK [next_url];transport=[transport];registering_acc=158_193_139_84 SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] [last_From:] [last_To:] [last_Call-ID:] [routes] Contact: <sip:[field1]@[local_ip]:[local_port]> CSeq: 802 ACK [field3] User-Agent: ATA Content-Length: 0 ]]> </send>
The nop command doesn't do anything at SIP level. It is only there to specify an action to execute. This text execute the play_pcap_audio/video action:
<nop> <action> <exec play_pcap_audio="pcap/g711a.pcap"/> </action> </nop> <pause milliseconds="8000"/> <nop> <action> <exec play_pcap_audio="pcap/dtmf_2833_1.pcap"/> </action> </nop> <pause/>
Starts second of the RTD timer. In this case RTD means SDD(Session disconnect delay).
<send retrans="500" start_rtd="2"> <![CDATA[ BYE [next_url];transport=[transport];registering_acc=158_193_139_84 SIP/2.0 Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch] [last_From:] [last_To:] [last_Call-ID:] [routes] Contact: <sip:[field1]@[local_ip]:[local_port]> CSeq: 803 BYE [field3] Max-Forwards: 70 User-Agent: ATA Content-Length: 0 ]]> </send>
End second of the RTD timer.
<recv response="200" crlf="true" rtd="2"> </recv> <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/> <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>