Sigapy: a failed attempt to create a product in Paraguay

A little more than a year ago, I created a service which main intention was to provide my fellow Paraguayans living abroad, an easy way to call home using their smartphones. It was not like Viber or Tango app, you could actually call to land lines and mobile phones, and of course between Sigapy users.

There’s no specialized service like this in Paraguay, and I wanted to fill that void with something new and easy to use, and so Sigapy was born. It was conceived as an academical project but soon it started to appear exploitable as a commercial service, but the environment for this kind of business in Paraguay isn’t the best (actually, it’s horrible) and I had to shut it down for my own juridical sake.

Today, I decided someone else can give it a try, because it’s a more or less mature product and can easily be adapted to someone else’s needs.

Check out the videos and the landing page I created. The videos are in Spanish, but the flow can be understood by anyone.



UPDATE: with this project, I won a place in the 4th generation of startups of Wayra Mexico. More updates to come in the future posts :).

NGS, or Next Generation Support, is a project that I created to participate in the TADHack event. It is about improving the user experience we have when we call to customer support, and it takes advantage of the new telco technologies we have today, to create a product that tries to fix a rather common issue which is the bad quality in customer support systems.

What NGS has to offer?

  1. Everyone has a smartphone, and there’s an app for everything, why not for a specialized customer support?
  2. It’s really annoying to navigate through the IVR menus. It’s easier to directly go to the option you want, with a click.
  3. It can be completely free, the only thing you need is an Internet connection.
  4. The customer would be able to call from literally anywhere in the world, using Internet, no toll-free numbers at all.
  5. Call center agents can know exactly who’s calling, where is he located, and what does he want, and with this info a better customer experience can be offered.
  6. The customer can take advantage of the current technology, with HD voice quality, chatting, video calling, screen sharing, etc.
  7. The customer can know exactly who is behind the phone, with a picture, an email, a full name, and he can rate the experience he had with the agent.
  8. In summary, improved customer experience from every angle you can think of.

Opensource communication technologies I used

  1. Kamailio
  2. rptengine: this one belongs to the Kamailio project but deserves special mention because it powers the media relaying. Extremely important
  3. SIPjs
  4. Freeswitch
  5. CSipSimple: compiled in library mode, it allowed me to use PJLIB to create SIP apps for Android.

I posted below, a few screenshots of the software, and I’m planning to add more and release the code during this month.

This is a work in progress. The project has only 3 weeks of being alive, at the time this post was written.

Screenshot_2014-06-05-20-33-52 Screenshot_2014-06-05-20-34-00 Screenshot_2014-06-05-20-34-17 Screenshot_2014-06-05-20-34-21 Screenshot_2014-06-05-20-34-32 Screenshot_2014-06-05-20-34-39 Screenshot_2014-06-05-20-35-59 Screenshot_2014-06-05-20-36-15 Screenshot Screenshot-1



Cnxcc prepaid module: workshop on Kamailio World

This is a short tutorial on how to test the cnxcc module with live traffic and from any softphone. These are the things that you need:

Register from any softphone:
* server:
* username: anything between 5000-9999. Actually anything will work, but I’d rather use those numbering ranges
* password: anything. It is not required
* credit: you will get 1$ credit every time you register. If you place a call and run out of credit, just register again and you will get +1$ on your account.

Place a call: you can actually call to any number with the following pattern: “^09\d{8}$”. This basically means that you can call to a number starting with “09”, that has 8 digits afterwards. Example: 0981223344

You will run out of credit: after a little more than 10 seconds, you will run out of credit and your call will be terminated. Don’t worry, you will receive a SIP MESSAGE on you UA, if it supports it, telling you what just happened.

Recharge your line: if you want more credit, just re-REGISTER from your UA

Check you credit: by texting “credit” to destination “service“, from your UA that supports SIP MESSAGE.

Check the web: you can actually hang up somebody else’s call, or your call, from the web interface. It looks nice and you can log in using “guest” as username and “123456” password.

Call each other: you have the option to call other registered users, but for this, you have to know the number of the other person, or guess it randomly 😉

Duplicated username: you may have chosen the same username that someone else did. If that’s the case, your call will last less than 10 seconds if you call simultaneously, or not even start if someone already exhausted the credit. In the latter case, you will receive a SIP MESSAGE telling you that you have no credit left ;).

These are the files involved in this project. I hope you find them useful.

The demo has no media relay configured, so, you won’t have audio unless you are calling each other on the same network.



WebRTC with Kamailio

I noticed lots of queries about this subject, and I created a Kamailio sample script that could help those who are in trouble when working on this.

This post is planned to be explanatory, with some level of detail, but I don’t really have time nowadays so I’m gonna throw it in its current state, hoping to find the time to do it properly soon enough.

  • This script is configured to run behind NAT, port TCP 10080 and TCP/UDP 5090 are exposed to the Internet
  • You have to create valid users using, preferably, “kamctl add …”
  • RTP ports should be open in range 30k-35k, inclusive
  • I used jssip as webrtc SIP UA:
  • Always disable video before placing a call from jssip UA
  • Always use Chrome. Firefox won’t work, and I’m not sure about other browsers
  • I tested calls between:
    • jssip to csipsimple
    • csipsimple to jssip
    • csipsimple to csipsimple

This is the link to the script

Install mediaproxy-ng on Debian based systems

This is a variation of my original post on how to install mediaproxy-ng on rpm based operating systems.

This one goes for the Debian/Ubuntu users, which are a plenty out there.

1. Clone the repository

git clone

2. Install compilation dependencies

apt-get install build-essential iptables-dev debhelper libcurl4-openssl-dev libglib2.0-dev libglib2.0-0 libxmlrpc-c++4 libxmlrpc-c++4-dev linux-kbuild-3.2 linux-headers-3.2.0-4-common linux-headers-$(uname -r) module-assistant

3. Go to mediaproxy-ng directory and build the Debian packages

cd mediaproxy-ng/ && dpkg-buildpackage -d

4. Go back to the parent directory. It should contain a series of .deb files. Install them all

dpkg -i *.deb

5. If everything went OK, a message similar to this should appear on the console:

DKMS: install completed.
mediaproxy-ng not yet configured. Edit /etc/default/ngcp-mediaproxy-ng-daemon first.
Setting up ngcp-mediaproxy-ng-kernel-source (2.3.5) ...
Setting up ngcp-mediaproxy-ng (2.3.5) ...
Setting up ngcp-mediaproxy-ng-dbg (2.3.5) ...

That is pretty much it, quick and straightforward, maybe because the Sipwise guys love Debian more than any other Linux distribution 😉

Asterisk as a transcoder for Kamailio

Using Asterisk as a SBC or transcoder may not be the right choice, especially if you follow the saying “use the right tool for the job”, and Asterisk is not precisely the right tool on these cases.

When you have options like FreeSwitch and SEMS, Asterisk seems to be disproportional and awkward to use, but it is so widely known that sacrificing flexibility to avoid investing time in learning a new technology (in case you don’t know FS or SEMS already) seems like a good alternative.

Having said that, let’s assume the following rules for our setup:

  • Our local network only accepts G722 codec between users, because, we enforce HD quality calls and we have lots of bandwidth at our disposal.
  •  We offer a local numbering plan and we can call between users of the network.
  • We also offer external calls to PSTN. For this purpose, we have a gateway that supports only PCMA/PCMU and G729. We don’t have the licence to do G729 in all of our softphones reason why we use PCM to reach our gateway from the softphones.
  • Asterisk will act as a transcoder, translating from G722 to PCMA/PCMU and backwards.
  • Asterisk will only take part of the SIP conversation when Kamailio detects that we are dialing to a number that does not belong to our internal numbering plan.

And from the SIP perspective

  • Kamailio is listening on port 5075 and serving on the net, using the IP
  • Asterisk is listening on port 5080.
  • The PSTN gateway is located at
  • Kamailio is accepting every registration request without any kind of authentication.
  • Username format is not being enforced, so I would recommend that you use something similar to 1000, 1100, etc.
  • I’m from Paraguay, and locally we dial “+5959” to access the mobile network. Change this pattern to your dialing prefix so that it makes sense to your gateway.

Basically, the magic on the Kamailio side happens approximately here:


request_route {
# per request initial checks

	# NAT detection

	# CANCEL processing
	if (is_method("CANCEL")) {
		if (t_check_trans()) {

	# handle requests within SIP dialogs

	### only initial requests (no To tag)


		sl_send_reply("405", "Method not allowed");

	# authentication

	# record routing for dialog forming requests (in case they are routed)
	# - remove preloaded route headers
	if (is_method("INVITE|SUBSCRIBE"))

	# handle registrations

	if ($rU==$null) {
		# request with no Username in RURI
		sl_send_reply("484","Address Incomplete");

	if (!is_method("INVITE")) {

	if ($rU =~ "^5959") {
		if (route(IS_FROM_SBC))



	# enforce g722 codec in all calls
	if (!sdp_with_codecs_by_name("G722")) {
		sl_send_reply("488", "Use G722!");

	# make sure g722 is the only code offered

route[IS_FROM_SBC] {
	if ($si =~ SBC_IP && $sp == SBC_PORT) 
		return 1;
		return 0;

route[TO_SBC] {

	xlog("L_INFO", "Going to SBC");

	# set the destination URI to our SBC
	$du = "sip:" + SBC_IP + ":" + SBC_PORT; 

	# We store the original request URI.
	append_hf("X-RURI: $ru\r\n");


route[FROM_SBC] {

	# At this point, the SDP offer should be fixed with the right codec information
	xlog("L_INFO", "Coming from SBC");

	if (is_present_hf("X-RURI")) {
		$ru = $hdr(X-RURI);
		xlog("L_INFO", "New URI is [$ru]");
	else {
		xlog("Weird, I couldn't find X-RURI hdr");



And, on the Asterisk side we have got two things to modify:

  1. sip.conf: we have to add our Kamailio instance as a trusted peer, with no authentication and with the right codec definition
  2. extensions.ael: yes, I use AEL instead of the common extensions.conf, mostly because I hate extensions.conf syntax. If you chose to use .conf, no problem. It should work using whatever you choose.


context=public                  ; Default context for incoming calls. Defaults to 'default'




context transcoder {

        _.      => {


                if ("${EXTEN}" != "h") {
                        SipAddHeader(X-RURI: ${RURI});

The full list of files are available on my github, here.

Installing mediaproxy-ng

This is a small guide on how to install mediaproxy-ng from sources on RPM based systems like CentOS.

Naming convention

All these “ng” stuff are really confusing and sometimes it’s hard to distinguish the pieces among them.

  • rtpproxy: it’s a media relaying software for RTP packets. It runs as a service and needs to be controlled and instructed using it’s own protocol.
  • rtpproxy module: it’s the Kamailio module that controls the rtpproxy service, from the configuration scripts.
  • rtpproxy-ng module: it’s the next generation (ng) module for Kamailio, based on the rtpproxy module. It serves as a replacement for that old module on newer systems.
  • mediaproxy: it’s another media relaying software, similar to rtpproxy, but older.
  • mediaproxy-ng: despite of its name, it is not the next-generation mediaproxy, but instead, the next generation of the rtpproxy (the service, not the module). From Kamailio, it can be controlled from both the rtpproxy and the rtpproxy-ng modules.

Before you begin: I’m using a x86 virtual machine. This means that you have to change the package names from i686 to x86_64 when necessary.

1. Kernel upgrade: you may not need to do this, so I recommend skipping this step unless you end up with an error like “undefined symbol” when trying to load the kernel module in the last step. In my particular case, I had to do it with my CentOS 6.0 VM.

yum upgrade kernel -y && reboot

2. Install development tools: several tools are needed to perform this step. Instead of manually listing them one by one, I would rather save some typing time by just installing the whole package 😉

yum groupinstall 'Development Tools'

3. Download the sources: from github

git clone

4. Install kernel development headers: this is going to be a kernel module, we need them.

yum install kernel-devel-$(uname -r)

5. A few other dependencies

yum install glib2-devel.i686 pcre-devel.i686 libcurl-devel.i686 libcurl.i686 xmlrpc-c.i686 zlib-devel.i686 iptables-devel.i686

6. Install mediaproxy-ng

cd /usr/src/mediaproxy-ng/daemon

7. Copy the resulting binary to the PATH: the Makefile doesn’t provide a rule for installing the binary.

cp mediaproxy-ng /usr/bin/

8. Compile and install the iptables extension

cd ../iptables-extension
cp /lib/xtables/

9. Compile and install the kernel module

cd ../kernel-module/
cp xt_MEDIAPROXY.ko /lib/modules/$(uname -r)/updates/
depmod -a
modprobe xt_MEDIAPROXY

10. Finally, if everything went fine, you should be able to see something like this:

# lsmod | grep -i mediaproxy
xt_MEDIAPROXY 16512 0
ipv6 264702 39 xt_MEDIAPROXY,ip6t_REJECT,nf_conntrack_ipv6

Csipsimple: a custom version


Ever heard of it? It’s an Android SIP client, the best to my opinion, that ports the PJSIP stack to Android devices and adds to it a really good-looking user interface.

Four months ago, I started studying Android programming and the love for it didn’t take long to come. Learning it was relatively easy because of my background on Java, but it is a complicated platform with so much diversity that it will take long before I could say that I fully understand everything.

Creating a custom version of Csipsimple has been in my TO-DO list since more than a year. I first tried to rebrand it but I had no idea how to do it and I even downloaded the code and took a look on it. It was Chinese to my eyes.

Finally, I decided to study Android and the result of it is a work in progress which is looking quite good and promising to be a great product for ng-voice, the company I work for.

Below are a few screenshots of the product, and with this link you can get to the github project with a full list of features and things that makes the softphone different than the original csipsimple.

Login Screen
Login Screen
Customer information screen
Customer information screen


VUC: Kamailio

VUC is a very famous conference for VOIP users that is streamed every week on Friday. Today, a great group of Kamailio developers were gathered together for an update regarding the upcoming release of Kamailio 4.1.

For me, it was the first time meeting most of the guys in the conference although I know them through the interactions in the SR-DEV mailing list. It was a great experience indeed.

My participation was mostly related to the cnxcc module that I contributed some months ago, and that will be released along with some other modules for the 4.1 version.

There’s a video of the session that you can watch. The important part of me talking about the module starts here.

After watching it I noticed my pronunciation needs some major improvements (well, my English in general :D), specially with the words ending with consonants. Bear with me please, English is my third language ;).

I leave you with the video link below, in case you want to watch very smart people talking about Kamailio 😉