Sunday, February 8, 2015

SIPp Call generator using wxPython

#-------------------------------------------------------------------------------
# Name:             CallGenerator
# Purpose:          To initate call generator using SIPp
#
# Author:           vallikkv
#
# Created:           02-11-2014
# Last Modified:     10-11-2014
# Copyright:        (c) vallikkv 2014
# Licence:           V2.0
#-------------------------------------------------------------------------------

import wx
import subprocess
import threading
import fileinput, socket, os

class MyFrame(wx.Frame):
    """ Dervice new class of Frame"""
    def __init__ (self, parent, title):
         wx.Frame.__init__(self,parent,title=title,size=(410,355))
         panel = wx.Panel(self)


         # CreatingTextbox for Extension/Queue number input
         self.filename = wx.TextCtrl(panel,pos=(175,50),size=(100,25))
         self.serveraddress = wx.TextCtrl(panel,pos=(175,90),size=(100,25))
         self.calltime = wx.TextCtrl(panel, pos=(175,130),size=(100,25))
         self.callerNum = wx.TextCtrl(panel, pos=(175,10),size=(100,25))

         #Label
         callerlabel = wx.StaticText(panel, label="Caller ID: ", pos =(55,15))
         labelname = wx.StaticText(panel, label="Queue Number: ", pos =(55,55))
         serverlabel = wx.StaticText(panel, label="Server IP: ", pos =(55,95))
         Calls = wx.StaticText(panel, label="Call timeout in secs: ", pos =(55,135))

         # Creating button which collects the Queuenumber and written it in the csv file and start the sipp.
         startbutton = wx.Button(panel, label="Start", pos=(100,200), size=(80,25)) #Creating Start button
         self.Bind(wx.EVT_BUTTON,self.StartClicked, startbutton) #Binding Start button with Startclicked  method

         closebutton = wx.Button(panel, label="Close",pos=(250,200),size=(80,25)) #Creating Close button to close the app
         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, closebutton)
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

         self.Queueinput1 = str(self.filename.GetValue())


    def OnCloseMe(self, event):
        self.Close(True)

    def OnCloseWindow(self, event):
        self.removefiles()
        self.Destroy()

    def csvfilecreation(self):
        print "Calling csvfilecreation method"
        self.Queueinput = str(self.filename.GetValue())
        self.serverip = str(self.serveraddress.GetValue())
        self.callerid = str(self.callerNum.GetValue())
        #Creating CSV File based on the queue
        queuefile=open(r"C:\Program Files (x86)\Sipp_3.1\Sample"+self.Queueinput+".csv", 'w+')
        queuefile.write("SEQUENTIAL\n"+self.callerid+";"+self.serverip+";[authentication username="+self.callerid+" password=connect];"+self.Queueinput+";")
        queuefile.close

    def InputQueue(self):
        self.inputvalue = str(self.filename.GetValue())
        return self.inputvalue

    def updatetimeincsv(self):
        print "Updating timeout in xml"
        oldxml=open(r"C:\Program Files (x86)\Sipp_3.1\xml.xml",'r')
        newxml=open(r"C:\Program Files (x86)\Sipp_3.1\Sample"+self.Queueinput+".xml", 'w+')
        for line in oldxml:
            newxml.write(line.replace('<pause milliseconds="60000" />','<pause milliseconds="'+str(int(self.Timeout)*1000)+'" />'))
        newxml.close()
        oldxml.close()

    def updatecsvfileinbat(self):
        os.chdir(r"C:\Program Files (x86)\Sipp_3.1")
        print "Calling updatecsvfileinbat method"
        self.hostip=socket.gethostbyname(socket.gethostname())
        updatecsv=open(r'C:\Program Files (x86)\Sipp_3.1\SampleCall'+self.Queueinput+'.bat','w+')
        updatecsv.write(":start\nsipp.exe "+self.serverip+" -sf Sample"+self.Queueinput+".xml -inf Sample"+self.Queueinput+".csv"+" -m 1  -l 1  -i "+self.hostip+"\nsleep 10\ngoto start")

    def StartClicked(self, event):
        print 'Calling StartClicked Method'
        MyFrame.calltimeout(self)
        MyFrame.csvfilecreation(self)
        MyFrame.updatecsvfileinbat(self)
        MyFrame.updatetimeincsv(self)
        MyFrame.ThreadStart(self)


    def ThreadStart(self):
        print "Calling Threadstart Method"
        #myinstance=The()
        Sippscript = threading.Thread(target=self.sippthread)
        Sippscript.daemon=True
        Sippscript.start()


    def stopthread(self):
        while self.threads:
            thread = self.thread[0]
            thread.stop()
            self.threads.remove(thread)

    def sippthread(self):
        """ New Child Thread for Sipp"""
        self.filepath=r'C:\Program Files (x86)\Sipp_3.1\SampleCall'+self.Queueinput+'.bat'
        print "Chile tread"
        print self.filepath
        os.startfile(self.filepath)

    def calltimeout(self):
        print "Calling calltimeout Method"
        self.Timeout= str(self.calltime.GetValue())
        print self.Timeout

    def clear(self):
        self.clear()

    def removefiles(self):
        os.chdir(r"C:\Program Files (x86)\Sipp_3.1")
        for file in os.listdir("."):
            if os.path.isfile(file) and file.startswith("Sample"):
                try:
                    os.remove(file)
                except Exception,e:
                    print e


if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None, "CallGenerator")
    frame.Show()
    app.MainLoop()

Friday, November 15, 2013

How to send RTP in sipp?

How to send RTP in sipp?

1. Create a RTP pcap file (Use wireshark to create it) and put in the sipp installation folder.
     i.e pcap/<file name>

2. Now refer the pcap file name in the xml file of your scenario (INVITE.xml)

<nop>
<action>
<exec play_pcap_audio="pcap/File name.pcap"/>
</action>
</nop>


Add this in between the ACK and BYE of the xml file.

3. Run the sipp, you can hear the RTP Voice in the call.


Saturday, August 17, 2013

Linux sipp client registration.

I have already wrote a post about SIPP installation in a linux machine. 
Now we can run sipp client on that linux machine and register with an asterisk server running in another machine.

a) Download Register xml ann CSV files from my other posts and copied it to the SIPP folder of the linux machine.

b) Open the Register CSV file using an editor and edit below entires based on your need.


18222 - SIP client (UAC) extension number
192.168.10.100  - SIP PBX IP address (here i used asterisk server ip address)

c) Now go to the sipp folder and execute command

'/sipp 192.168.10.100 -sf REGISTER_client.xml -inf Register_client.csv -m 1'




How to install sipp in linux?

How to install sipp in linux?

1. Download the stable linux verison from the sipp source web.


Example: I downloaded "sipp-3.3.tar.gz" file and copied it to the ROOT folder of my linux machine.



2. Execute command "gunzip sipp-XXX.tar.gz" command, here i used command 'gunzip sipp-3.3.tar.gz'


3. Then execute command 'tar -xvf sipp-xxx.tar' command, here i used command 'tar -xvf sipp.3.3.tar' to extrac the sipp tar file.


4. The folder sipp.xxx contains all th extracted  files and available in the same location.  Go to the folder 'cd sipp-xxx'


5. Now execute the command 'make'  - Just executig 'make' command without any extensions means we are using SIPP without TLS and Authentication support.

  a) Execute command 'make ossl' for TLS & Authentication support.
  b) Execute command 'make pcapplay' for PCAP Play & No authentication support.
  c) Execute command 'make pcapplay_ossl' for PCAP Play & Authentication support.


 Oh no !!! I had faced above error while executing 'make' command

6. I had executed the command 'yum install ncurses-dlevel ncurses' to install ncurses package (Note:- Linux machine should be connected with internet for yum update )



7. I've executed the 'make' command again to complete the sipp installation.


Monday, December 12, 2011

SIPp commands for INVITE, REGISTER

Sipp commands

For Register:
sipp 192.168.1.106 -sf REGISTER_client.xml -inf REGISTER_client.csv -m 1 -l 1 -trace_msg -trace_err

For INVITE:
sipp 10.20.20.51 -sf REGISTER_INVITE_client.xml -inf REGISTER_IN.csv -m 1 -l 1