Saturday 25 October 2014

SIPp Installation

      To install SIPp on a Fedora System follow the steps given below :

1. Checkout the sipp code from the SIPp svn. On the sourceforge download page click on the Code Tab and copy the http access svn link :

[root@localhost rishabh]$ svn checkout http://svn.code.sf.net/p/sipp/code/ sipp-code
A    sipp-code/doc
A    sipp-code/doc/trunk
.
.

This will create a folder called sipp-code in the current directory.


2. Now navigate to the directory "sipp-code/sipp/trunk"

[root@localhost rishabh]# cd sipp-code/sipp/trunk
[root@localhost trunk]#


3. Compile SIPp. Sipp can be compiled with the following options :
    a. OPEN-SSL support : required if SIPp need to be run over TLS
    b. PCAP-play support
    c. SCTP support

Here I will compile SIPp with all the above options. To do this run the command

     "autoreconf -ivf; ./configure --with-pcap --with-sctp --with-openssl; make".
  
I compiled SIPp on a freshly installed Fedora machine and encountered the following errors :

        a. Error : bash: autoreconf: command not found...
            Solution : Install autoconf with the command : "yum install autoconf"
      
        b. Error : Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
            Solution :  Install automake with the command "yum install automake"
      
        c. Error : configure: error: ncurses library missing
            Solution : Install ncurses library with the command "yum install ncurses-devel.i686"
      
        d. Error : configure: error: <openssl/md5.h> header missing
            Solution : Install openssl and openssl-devel with the commands "yum install openssl" and "yum install openssl-devel.i686"

        e. Error : configure: WARNING: <netinet/sctp.h> header missing, but this is acceptable on Mac OS X Lion
            Solution : Install lksctp libraries with the command "yum install lksctp-tools-devel.i686".

        f.  Error : configure: error: <pcap.h> header missing  
            Solution : Install pcap libraries with command "yum install libpcap-devel.i686"

        g. Error : ./depcomp: line 772: exec: g++: not found  
            Solution : Install g++ with the command "yum install gcc-c++"


4. Next run "make install"

[root@localhost trunk]# make install
make[1]: Entering directory `/home/rishabh/sipp-code/sipp/trunk'
 /usr/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c sipp '/usr/local/bin'
make[1]: Nothing to be done for `install-data-am'.
make[1]: Leaving directory `/home/rishabh/sipp-code/sipp/trunk'
[root@localhost trunk]#


5. To check if SIPp was installed correctly give the command "sipp -v". It will show the version of SIPp installed

[root@localhost trunk]# sipp -v

 SIPp v3.4-early-TLS-SCTP-PCAP, version unknown, built Oct 24 2014, 22:29:11.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as
 published by the Free Software Foundation; either version 2 of
 the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public
 License along with this program; if not, write to the
 Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

 Author: see source files.

[root@localhost trunk]#

SIPp

      SIPp is a command line, linux based, SIP traffic genarator. It has the capability of generating SIP traffic customized to user needs in order to test out SIP Proxies, B2BUAs, SIP media servers, SIP/x gateways etc. It features :

    1. TCP/TLS and UDP support over multiple sockets or multiplexed with retransmission management
    2. Dynamic display of statistics about running tests (call rate, round trip delay, and message statistics)
    3. Periodic CSV statistics dumps
    4. Dynamically adjustable call rates.

      SIPp uses XML files that provide the exact flow of SIP messages to be sent/received at the User Agents. these XML files are highly configurable to allow the user to simulate obscure scenarios effortlessly. The tool is especially useful for load testing as well as RFC compliance testing. 

Monday 15 September 2014

Power over Ehternet (PoE) - Powering UP VOIP phones

What it is ?     


      Power over Ethernet or POE, is a system capable of transmitting electrical power + data over a single ethernet cable. In this sense it is similar to a USB cable which also does the same thing by supplying both a data as well as power connection to low power devices like keyboards/mice etc. However, the maximum length of USB cables is about 5 meters and they provide 2.5 W of power. POE, on the other hand allows longer cable lengths and more power(IEEE 802.3at-2009 POE standard, provides up to 25.5 W of power). POE operation can be obtained with a Category-3 cable for less power, however the IEEE standard requires CAT-5 cables or higher for high power levels.

      POE is nowadays widely used to power VOIP Phones, IP Cameras and Wireless access points.

Usage with VOIP Phones - Avaya 4621SW/9641G

 

       With VOIP phones like Avaya 4621SW or 9641G, PSE (Power Sourcing Equipment) capable switches are required for the phones to pull power from. Without a POE capable switch the phone will not be able to boot up. Such a switch is called an endspan. However such switches may not be readily available. In that case an intermediary device is required between a non POE capable switch and a POE powered device(PD). Such a device is called a midspan. An example of a midspan device is a POE injector.

A POE injector typically takes two inputs :

1. Power (48V DC generally)
2. Ethernet Cable (CAT-5 generally, from a switch)

      It is able to provide a single output in the form of a CAT-3/4/5 cable that is capable of transmitting both power and data. Such a POE injector can be easily used to power up the Avaya phones listed above. The POE injector I used, was capable of supplying 15.4 W power over a distance of 100 meters over a CAT-5 cable and came at a cheap cost of about $20.

Thursday 13 March 2014

Monte Carlo Simulation - Estimation of Pi

What it is?


      Monte Carlo simulation is a problem solving technique which is used to approximate the solution for those problems which are infeasible or impossible to compute deterministically. It involves doing multiple trial runs or simulations for the problem at hand with suitable random values and observing the fraction of the values obeying some property or properties.


      As a simple example we try to calculate the value of π though a Monte Carlo Simulation. Consider the following figure where a circle is inscribed in a square. The side of the square is 2r units, and the radius of the circle is r units.
 
                                                     


        Now consider a single quadrant of the figure.

                                             

      Here,
 
                     

      So,
         


The Procedure


       Using Monte Carlo simulation we would calculate the value of π as follwos :


    1.  Consider the figure to be on a Cartesian plane.
    2.  Generate a large number of points.
    3.  Count the number of points lying inside the quadrant (n in the program below, this will represent the area of the shaded region). And count the total number of points (representing the area of the square)
    4.  Compute the value of π using the above formula. (4 * n / a)
    5.  To get better accuracy repeat steps 1-4 multiple times and take the average.

      Here is a perl program for this implementation :


$avg=0;
$no_of_times=10;
for($i=0;$i<$no_of_times;$i++)
{
        $a=int rand(1000000);
        $n=0;
        for($j=0;$j<$a;$j++)
        {
                $x=rand(1);
                $y=rand(1);
                if($x*$x + $y*$y <=1)
                {
                        $n++;
                }
        }
        $pi= 4.0*$n/$a;
        print "pi=$pi for $a tries\n";
        $avg+=$pi;
}
$avg/=$no_of_times;
print "pi=$pi\n";



The output is :


rishabh@ubuntu:~$ perl pi.pl 
pi=3.14276506439668 for 772633 tries
pi=3.14294672233944 for 542216 tries
pi=3.14328773838267 for 575283 tries
pi=3.14186626844556 for 203572 tries
pi=3.13502251907228 for 32639 tries
pi=3.13983316710037 for 800082 tries
pi=3.14055617007238 for 309186 tries
pi=3.13979483067174 for 818056 tries
pi=3.13903009074211 for 819355 tries
pi=3.1448481668525 for 365928 tries
Final value of pi=3.1448481668525
rishabh@ubuntu:~$ 


      The above program is just an example for demonstrating Monte Carlo Simulation. It is generally used in cases which are too complicated to solve analytically. It gives us the ability to examine more complex systems than we otherwise can. With Monte Carlo methods, a large system can be sampled in a number of random configurations, and that data can be used to describe the system as a whole.


Percolation Threshold



       Consider the problem of calculating the percolation threshold. 

Definitions :
 
Percolation : Consider a system as a 2-d grid composed of empty and filled sites. We say that the system percolates if there is a path from an empty site in the top row to one on the  bottom row through a set of empty sites in the grid.

For example consider the following systems :
System 1 does not percolate.
System 2 percolates.

   

    
      The Problem :  We are interested in the value of the site vacancy percentage(i.e. percolation threshold) for a system. If the site vacancy percentage is greater than this value then the system almost certainly percolates while if the site vacancy percentage is lesser then the system almost certainly does not percolate

      To determine this we can use Monte Carlo Simulation :

1.    Initialize all sites to be blocked.
2.    Repeat the following until the system percolates(Use union find algorithm):
       a.    Choose a site (row i, column j) uniformly at random among all blocked sites.
       b.    Open the site (row i, column j).
3.    The fraction of sites that are opened when the system percolates provides an estimate of the percolation threshold.

Repeat the above multiple times and take an average to get a more accurate result. It is generally around 0.593.

                                  
                  

Application of Percolation threshold :


1.  Given a composite systems comprised of randomly distributed insulating and metallic materials: what fraction of the materials need to be metallic so that the composite system is an electrical conductor?

2.  Given a porous landscape with water on the surface (or oil below), under what conditions will the water be able to drain through to the bottom (or the oil to gush through to the surface)?

3.  Given a network, how many nodes can be removed till the network looses connectivity? (Determination of network robustness and fragility).

 

Other applications of Monte Carlo Simulation :


1.  Finance : Monte Carlo methods are used in finance to value and analyze (complex) instruments, portfolios and investments by simulating the various sources of uncertainty affecting their value, and then determining their average value over the range of resultant outcomes.

2.  Searching for the best move in a game using a technique called Monte-Carlo tree search. Possible moves are organized in a search tree and a large number of random simulations are used to estimate the long-term potential of each move.

3.  In telecommunications, when planning a wireless network, design must be proved to work for a wide variety of scenarios that depend mainly on the number of users, their locations and the services they want to use. Monte Carlo methods are typically used to generate these users and their states. The network performance is then evaluated and, if results are not satisfactory, the network design goes through an optimization process.