Automatic call generator

Created by A. Martínez on 2019-02-04

4z.com

Table des matières

Automatic call generator. 1

Motivation. 1

Installation. 1

Execution. 1

The config file. 1

End of document. 1

 

 

Motivation

This document aims at installing and configuring an automatic call generator in order to make calls via terminal. Its name is PJSIP/PJSUA.

PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. It combines signaling protocol (SIP) with rich multimedia framework and NAT traversal functionality into high level API that is portable and suitable for almost any type of systems ranging from desktops, embedded systems, to mobile handsets.

Installation

Install the required dependencies.

 

1.   apt install python-dev gcc make gcc binutils build-essential

 

Get the source tarball from the project’s website.

 

1.   wget http://www.pjsip.org/release/2.6/pjproject-2.7.tar.bz2

2.   tar -xjf pjproject-2.7.tar.bz2

3.   cd pjproject-2.7 

 

Modify the “config_site.h” so that pjsip can do 200 calls at the same time (default are 32). This file should be empty, just add the following lines (if not, just delete everything, and add these lines). If you want to raise this number (200 calls), you can just change the parameter value.

 

1.   #define PJ_IOQUEUE_MAX_HANDLES      400

2.   //#define FD_SETSIZE_SETABLE      1

3.   #define __FD_SETSIZE            400

4.   //#define PJSIP_MAX_TRANSPORTS        32

5.   //#define PJSIP_MAX_RESOLVED_ADDRESSES    32

6.   #define PJSUA_MAX_ACC           200

7.   #define PJSUA_MAX_CALLS     200

8.   #define PJSUA_MAX_PLAYERS       200

 

Build pjsip.

 

1.   export CFLAGS="$CFLAGS -fPIC"

2.   ./configure

3.   make dep

4.   make

5.   make install

 

Copy the binary file to /usr/local/bin.

 

1.   cp pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu /usr/local/bin/pjsua

 

Execution

We want pjsua to behave as a SIP client like the usual hardphones or softphones, but in this case, via terminal interface in order to do simultaneous calls from/to many accounts/numbers.

Let us register with pjsua as a regular user in a server. This is just the standard procedure done by hardphones and softphones.

 

1.   pjsua --id sip:2017@51.75.31.95 --registrar sip:51.75.31.95 --realm=* --username=2017 --password=223322

 

We pass to the pjsua function the line arguments needed to register in server, basically, the IP, the user, and the password, of the SIP account we want to use to do calls.

Right after, we get to the application menu. This menu  permits to do useful things such as add accounts, add a calling buddy (number/account to be called), make calls, hang up calls, et cetera. It is very user-friendly.

 

 

To invoke a command, simply type its invoking character, and then, the application menu will ask for the rest of the necessary information to execute it.

We can add accounts and numbers to be called from the application menu with no problems, however, it is practical to give this kind of information to pjsip from command line arguments.

 

1.   pjsua --id sip:2017@51.75.31.95 --registrar sip:51.75.31.95 --realm=* --username=2017 --password=223322 --null-audio --max-calls=200 --add-buddy sip:500001@51.75.31.95

 

In the previous command, we are directly adding a number to be called from command line, with the “--add-buddy” argument. The “--null-audio” command prevents sound libraries issues, and the “--max-calls” argument indicates the maximum numbers of calls permitted (it can never be above the number defined in the “config_site.h” file, which was modified before compilation). We can utilize the “--add-buddy” argument the times we need in order the add possible numbers to be called in our “Buddy list”

 

Then, from the application menu, we type “m” to do a call:

 

 

The program shows our buddy list. In this case, we have just one. We select 1, and the call will start.

 

 

We can see the call in the SIP server.

 

 

To hang up all ongoing calls, type “ha=all”.

 

Now, if we want to do 10 calls at the same time to this buddy, type “M”.

 

 

The program will ask the number of calls we want to have at the same time. Then, the process is the same as described for a single call.

You can see the 10 calls in the server.

 

 

 

If you want to make calls from different users, use the “--next-acount” parameter. Let us show its use in the following example:

 

1.   pjsua --id sip:2015@51.75.31.95 --registrar sip:51.75.31.95 --realm=* --username=2015 --password=223322 --next-account --id sip:2016@51.75.31.95 --registrar sip:51.75.31.95 --realm=* --username=2016 --password=223322 --next-account --id sip:2017@51.75.31.95 --registrar sip:51.75.31.95 --realm=* --username=2017 --password=223322  --null-audio --max-calls=200 --add-buddy sip:500001@51.75.31.95

 

With this command, you can add the accounts you need, just separating them with the mentioned parameter. If you issue the “l” command in the application menu, you will see the current accounts. To change the account, issue “>”, and then, select the account ID. The asterisk (*), will show you which is the account selected.

 

 

Let us make calls at the same time, from the different accounts. It is as simple as before: select the account, and then “m” to make call.

 

 

You can see in the server the calls from different accounts (2015, 2016, and 2017).

 

The config file

There is a very efficient way to load information in pjsip: the config file.

The config file allows to load massively accounts and buddies to be called. It is simply a text file where you add the command line arguments that pjsip needs. Let us pose an example:

 

1.   --id sip:2015@51.75.31.95

2.   --registrar sip:51.75.31.95

3.   --realm=*

4.   --username=2015

5.   --password=223322

6.   --next-account

7.   --id sip:2016@51.75.31.95

8.   --registrar sip:51.75.31.95

9.   --realm=*

10. --username=2016

11. --password=223322

12. --next-account

13. --id sip:2017@51.75.31.95

14. --registrar sip:51.75.31.95

15. --realm=*

16. --username=2017

17. --password=223322 

18. --null-audio

19. --max-calls=200

20. --add-buddy sip:500001@51.75.31.95

 

 

 Then, just load it utilizing “--config-file” argument:

 

1.   pjsua --config-file example_config_file.cfg

 

 

End of document