Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

martes, 28 de junio de 2016

How do G729 Encoders and Decoders work?

Each Digium G729 channel is composed of one encoder and one decoder, when your asterisk-based system is transcoding into another codec, it will use one encoder to transform audio from the other end point codec into G729 and one encoder to transfer from G729 to the other endpoint codec. 

it's important to mention that if Asterisk is not transcoding the codec (G729 into another coder Or any codec into G729) your G729 channels won't be used. This is known as pass-through.
How many G729 channels should I buy for my PBX?

Assuming that you are not recording or spying on the call, you phone will use one channel (One encoder / Decoder) per call. If you are recording calls, your channel per call could go up to 3 channels. 
We suggest you purchase as many channels as you expect to have concurrent calls and an additional 10% -30% for overhead purposes.  As an example: if you have a PBX with 20 phones and you don't expect to have more than five calls at the same time. Your G729 license should have 7 (5 + 2) channels. 

Bandwidth Utilisation for VoIP Calls

Andreas PsyllosBy Andreas Psyllos Google+ profile 
Posted on : December 20, 2012, Last modified on : July 18, 2014

Calculating the bandwidth used for VoIP may seem like a daunting task, however it is rather simple, especially after understanding simple some principles.
VoIP calls consist of two main parts:
  • The call management section is the part which gets the call going. It signals call initiation, ringing, disconnect, and other communications performed between the two endpoints in order to get the call going.
  • The second part is the audio, which is transmitted using RTP. Since the bandwidth consumed by SIP is insignificant, we shall focus on calculating the bandwidth consumed by audio in the rest of this article.
Since raw audio can be rather large, it needs to be encoded before it is sent on the network. This is done using a codec. Different codecs produce different audio quality, consume different levels of bandwidth, and some are more CPU intensive than others. Thus it is important that you select the right codec for your application.
Before we delve into the differences of the common codecs, let’s introduce another principle which would allow us to accurately calculate the bandwidth utilised. When you need to send data over the network, the data needs to be packaged. The “packaging” contains information which allows the data to be sent to the destination and to be rebuilt correctly. As you might imagine, the packaging does not come free – it adds to the bandwidth consumption.
There are different network packaging layers (required by the 7 layer OSI model). The encoded audio needs to be packaged into RTP packets. In turn, the RTP packets need to be packaged into UDP packets, which then need to be packaged into IP packets. Ethernet is the most common type of network, and this requires another wrapper.
Ethernet packet
We shall refer to these packages collectively as overhead. Irrelevant of the codec used, the overhead introduced in the packet is fixed. Below is the overhead introduced by each overhead item:
  • RTP – 4.8 kbps
  • UDP – 3.2 kbps
  • IP – 8 kbps
  • Ethernet (not using QOS) – 15.2 kbps
The total overhead is 31.2 kbps.


Now that we understand the basics, let’s proceed with explaining the differences between the common codecs which can be used to encapsulate the Audio in a VoIP call. The following table shows the audio quality expected, the CPU resources required to encode and decode the audio, the base size of the audio packets, and total bandwidth consumption after taking into consideration the overhead.
CodecAudio QualityCPU ResourcesBase SizeTotal Size (Base + Overhead)
G711GoodVery Low64 kbps95.2 kbps
G722Very GoodLow64 kbps95.2 kbps
GSMAcceptableAverage13 kbps44.2 kbps
G729AverageHigh8 kbps39.2 kbps
Note that the above bandwidth consumption is in kilobits per second. You will need to divide by 8 in order to get the equivalent in kilobytes per second. Using the above data, we can come up with the following stats:
CodecKilobits per secondKilobytes per secondKilobytes per minuteMegabytes per hour
Here are some notes and suggestions for the application of specific codecs:
  • The above are stats for one audio stream. A VoIP call will use one audio stream for each leg (or endpoint). Thus a call between two parties will use double the bandwidth shown above.
  • G729 is the codec which consumes the least bandwidth and has a relatively good audio quality. However that comes with two drawbacks:
    1. Its efficiency comes at a cost, CPU usage. It is more CPU intensive to encode audio in such a low size while maintaining the quality.
    2. G729 is a proprietary codec. Because of this, the number of simultaneous G729 channels cannot exceed half your 3CX Phone System simultaneous call license depending on the number of participants and type of calls.
  • Because of this, G729 should only be used when really required, such as for external calls to VoIP Providers, calls across a bridge, or for remote extensions (basically all calls being done over the internet). You can configure the PBX to fall back to GSM if G729 calls cannot be made.
  • Although G711 and G722 consume over twice as much bandwidth as the other codecs, most Local Area Networks are able to handle this bandwidth. Using the above table, a 1 hour call using G711 is equivalent to transferring a 41.8 MB file. If that causes an issue, you should consider upgrading your network

domingo, 26 de junio de 2016

Updating or Upgrading Asterisk

Saltar al final de los metadatos
Ir al inicio de los metadatos

Keeping the System Up-to-date

Definition of Updates and Upgrades

Updates involve installing a new minor version. That is, moving from 11.X.X to 11.X.X vs moving from 11 to 12. New minor versions include bug fixes, some of which may be security related. Typically, there should not be features or new functionality included in a minor version except when the fixing of a bug requires it.
Upgrades involve installing a new major version. For example, moving from 11 to 12. New major versions can include bug fixes, new features and functionality, changes to old features or functionality, deprecation of functionality or change in support status.
Updates and upgrades should only be performed when necessary
  • Reason to Update
    • Your install is affected by a bug or security vulnerability and you believe the new minor version will fix your issue.
  • Reason to Upgrade
    • You require new features or enhancements only available in a new major version and are ready for the work involved in upgrading.
When considering an update or upgrade you should be familiar with the Asterisk support life-cycle. It is useful to know the support status of the version you may be moving to.

Researching a New Asterisk Version

Included with Asterisk releases are a few files that are useful for researching the version you are considering for update or upgrade. These can be found in the root of the Asterisk source directory.
  1. UPGRADE.txt - Documents any changes that you need to know about when moving between major versions. Especially changes that break backwards compatibility.
  2. CHANGES - Documents new or enhanced functionality between versions listed in the file.
  3. ChangeLog - A log showing all changes (bug fixes, new features, security fixes,etc) between released versions. It can be useful if you are searching for a specific fix or change, but this could be overly verbose for looking at changes between two major versions.

Performing Updates

  1. Research the new minor version you intend to update to.
  2. Be sure you have a backup of any essential data on the system.
  3. If you determine one of those changes will be beneficial for you, only then proceed with an update.
  4. Download the new version and install Asterisk.

Performing Upgrades

  1. Research the new major version you are considering for an upgrade.
  2. Be sure you have a backup of any essential data on the system.
  3. If you determine the new functionality or changes will be beneficial then proceed with the upgrade.
  4. On a test system, a non-production system, download and install the new version.
  5. Migrate backups of configuration, databases and other data to the new Asterisk install.
  6. Test this new system, or simulate your production environment before moving this new system into production.
    1. Especially test any areas of Asterisk where behavior changes have been noted in the UPGRADE.txt or CHANGES files. APIs, like AGI, AMI or ARI connecting to custom applications or scripts should be thoroughly tested. You should always try to extensively test your dialplan.

Third Party Modules

When updating or upgrading Asterisk you should also check for updates to any third party modules you use. That is, modules that are not distributed with Asterisk. Those third party modules may require updates to work with your new version of Asterisk.

Update and Upgrade Tips

Updates and upgrades could include changes to configuration samples.  Sample files will not be updated unless you run "make samples" again or copy the new sample files from the source directory. Be careful not to overwrite your current configuration.
Keep old menuselect.makeopts files (see Asterisk source directory) and use them when building a new version to avoid customizing menuselect again when building a new version. This may only work for updates and not upgrades.
If you forget to re-build all Asterisk modules currently installed on the system then you may be prompted after compilation with a warning about those modules. That can be resolved by simply re-building those modules or re-installing them if you obtain them in binary form from a third party.

miércoles, 22 de junio de 2016

agent state with presentation

#!/usr/bin/php -q

$agi = new AGI();
$cid = $agi->parse_callerid();




foreach($extension_list as $key=> $extension) {

 $output = shell_exec("asterisk -x \" core show hint $extension\" | awk '{print $4}' | awk 'NR==1'");

 $state = substr("$output", -5);

  $state=trim ($state);

if($state=="Idle") {




$total_of_agents= count($arr);




foreach($extension_list as $key=> $extension) {

 $output = shell_exec("asterisk -x \" core show hint $extension\" | awk '{print $4}' | awk 'NR==1'");

 $state = substr("$output", -5);

  $state=trim ($state);

if($state=="Idle") {




rand caller id

  1. [from-internal-custom]
  2. exten=>_771NXXNXXXXXX,1,Gosub(rand-cid,${EXTEN:3:3},1)
  3. same=>n,Dial(SIP/rapidvox/${EXTEN})
  4. same=>n,Hangup()
  6. [rand-cid]
  7. exten =>804,1,Set(CALLERID(num)=18043025726)
  8. same=>n,Return(${CALLERID(num)})
  10. exten =>267,1,Set(CALLERID(num)=12673025726)
  11. same=>n,Return(${CALLERID(num)})
  14. exten =>951,1,Set(CALLERID(num)=19513025726)
  15. same=>n,Return(${CALLERID(num)})

  1. exten =>_x.,1,Set(CALLERID(num)=18002361010)
  2. same=>n,Return(${CALLERID(num)})

martes, 21 de junio de 2016

extension state script

foreach($extension_list as $key=> $extension) {

 $output = shell_exec("asterisk -x \" core show hint $extension\" | awk '{print $4}' | awk 'NR==1'");
 $state = substr("$output", -5);
  $state=trim ($state);

if($state=="Idle") {
echo "agent $key $state\n";


else {

echo " $key   $output\n";



lunes, 20 de junio de 2016

getting DID from invite

exten => s,1,Noop(Fixing DID using information from SIP TO header)
exten => s,n,Set(pseudodid=${SIP_HEADER(To)})
exten => s,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => s,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => s,n,Set(pseudodid=${CUT(pseudodid,+,2)})
exten => s,n,Set(isuk=${REGEX("^44.*" ${pseudodid})})
exten => s,n,Set(pseudodid=${IF(${isuk}?0${pseudodid:2}:${pseudodid}))
exten => s,n,Set(pseudocid=${CALLERID(num)})
exten => s,n,Set(pseudocid=${CUT(pseudocid,+,2)})
exten => s,n,Set(isuk=${REGEX("^44.*" ${pseudocid})})
exten => s,n,Set(pseudocid=${IF(${isuk}?0${pseudocid:2}:${pseudocid}))
exten => s,n,Set(CALLERID(num)=${pseudocid})
exten => s,n,Set(CALLERID(name)=${pseudocid})
exten => s,n,Goto(from-trunk,${pseudodid},1)

domingo, 12 de junio de 2016

Bandwidth consumption

Business PBX Solutions
ProviderSolution Details
Bicom VoIP Become an ITSP Now!
  • Become a serious competitor in VoIP Immediately
  • FULL Consultancy, Installation, Training & Support
  • Sell Hosted IP PBXs, Biz Lines, Call Centre
  • Turnkey Provisioning at your data center
3CX Software PBX for Windows
  • Windows Software Solution
  • Easy to Install and Manage
  • Auto Configures Phones & Trunks
  • Android, iOS, Windows & Mac clients
VOIP Bandwidth consumption naturally depends on the codec used.

When calculating bandwidth, one can't assume that every channel is used all the time. Normal conversation includes a lot of silence, which often means no packets are sent at all. So even if one voice call sets up two 64 Kbit RTP streams over UDP over IP over Ethernet (which adds overhead), the full bandwidth is not used at all times.

A codec that sends a 64kb stream results in a much larger IP network stream. The main cause of the extra bandwidth usage is IP and UDP headers. VoIP sends small packets and so, many times, the headers are actually much larger than the data part of the packet.

IAX2 trunking helps with the IP overhead, but only when you are sending more than 2 or so calls between the same Asterisk servers. John Todd has done some useful practical testing, named IAX2 trunking: codec bandwidth comparison notes and results.

The bandwidth used depends also on the datalink (layer2) protocols. Several things influence the bandwidth used, payload size, ATM cell headers, VPN headers, use of header compression and IAX2 Trunked. You can see the influence of some of this factors using the Asteriskguide bandwidth calculator.

Teracall has the table which shows how the codec's theoretical bandwidth usage expands with UDP/IP headers:

Codec BR NEB
G.711 64 Kbps 87.2 Kbps
G.729 8 Kbps 31.2 Kbps
G.723.1 6.4 Kbps 21.9 Kbps
G.723.1 5.3 Kbps 20.8 Kbps
G.726 32 Kbps 55.2 Kbps
G.726 24 Kbps 47.2 Kbps
G.728 16 Kbps 31.5 Kbps
iLBC 15 Kbps 27.7 Kbps

BR = Bit rate
NEB = Nominal Ethernet Bandwidth (one direct

viernes, 10 de junio de 2016

Adding Listen, Whisper, and Barge to FreePBX or Asterisk

Adding Listen, Whisper, and Barge to FreePBX or Asterisk

If you are running a call center on FreePBX or Asterisk, most likely you will want the ability to listen in on agents calls, also known as joining multiple calls, or connected two calls to a manager, or other variations of barging in on a bridged channel.
For the purpose of this article, we will define manager as the callee who is the spying channel, agent who is the spied-on channel, and client who is the bridged channel / 3rd party. We define listen, whisper, and barge as follows:
Listen: Monitor an agents call. The manager can hear both the agent and client channels, but no-one can hear the manager.
Whisper:  Whisper to the agent. The manager can hear both the agent and client channels, and the agent can also hear the manager, but the client can only hear the agent, hence “whisper.”
Barge: Barge in on both channels. The manager channel is joined onto the agent and client channels, and all parties can hear each other. Be warned, if the original agent leaves the call, the call is dropped. This is not a 3-way call.
(However you can barge in, and when comfortable, initiate a 3way call to your extension so you can continue the call without the agent. This procedure varies from client to client (soft/hard phones))
One more note: We can also provide 3-way calling [live transfer] services on the server side, however this is outside the scope of this document. Please contact us for details.

miércoles, 8 de junio de 2016

Setting up the CISCO 7940 with SIP/Asterisk


This is another guide that was born out of extreem frustration. After spending weeks trying to get my CISCO 7940g to work with Asterisk, I decided to document the event for future generations.

The phones can be picked up cheap on eBay and also work nicely with Asterisk after some fiddling. However, there are a few points to bear in mind:

  • The phones are designed for enterprise VoIP deployments. If you buy one they are unlikely to come with a power supply as they expect to be deploying into a PoE environment. You can either buy a 48V PSU for the phone although it's probably cheaper to get a standard PoE injector. Also the phones rely upon infrastructure. To get the phones working it needs to get files from a TFTP server. You also need a web server to serve things like custom logos and a phone directory if you want to use those features.
  • The phones are designed to work with CISCO Call Manager and use the SCCP protocol rather than SIP. Asterisk has support for SCCP though it's said that you are better off using SIP. CISCO do a SIP firmware for the 7940g. This requires you to upgrade to a new firmware.

  • Rebooting the phone

    The first thing you probably want to know is how to reboot the phone. Hold down "*", "6" and "settings". The settings button is the bottom right of the group of four buttons around a circular, green question mark button. It has a box with a tick in it on the button.

    Upgrading to SIP firmware

    I don't want to cover this in too much detail as it's repeatadly documented all over the Internet. There are a few points to bear in mind:

  • The firmware is upgraded using config files and firmware images on the TFTP server. This process and the files used changes from version to version. Also you cannot directly upgrade from old firmware to the latest firmware. Version 6.3 is a significan release and I think you need to go to one of the 7 releases before you can upgrade to version 8.
  • Also please be aware that you have to download the firmware files from CISCO and for this you require a CISCO login. You can get this by putting the phone on CISCO support for about $40 a year.
  • Beat in mind that you need to downloadn the SIP firmware not the SCCP firmwar!
  • There have been many reports of not being able to get 8.10 to boot. I certinaly can't and decided to use 8.9 instead

  • Configuring the phone to connect to Asterisk or another SIP provider

    Let's start by assuming that you have managed to get a firmware upgrade to the lastest version of the SIP firmware. Now you need to configure the phone. When the phone boots, it downloads the firmware from the TFTP server and also pulls down some config files. You need the following files on the TFTP server (assuming you are using 8.9):
  • P0S3-08-9-00.loads
  • P0S3-08-9-00.sb2
  • P003-08-9-00.bin
  • P003-08-9-00.sbn
  • SIPDefault.cnf
  • SIP<mac>.cnf
  • There are two configuration files to use. SIPDefault contains settings that apply to all phones. SIP<mac>.cnf contains settings that apply to a single phone, indentified by MAC address. The following is an example of the minimal configuration needed to get the phone to register to either Asterisk or another SIP provider:


    #image_version shows the firmware image to get from the TFTP server. Note this shouls start P0S and not P00.
    image_version: P0S3-08-9-00

    #Proxy server address should probably be more accuratly be called the SIP server
    proxy1_address: x.x.x.x
    #proxy_register tell it to connect to the SIP server (why would you want to set this to 0?!
    proxy_register: 1


    #The following lines contain the authenication details
    line1_name: line1
    line1_authname: "line1"
    line1_displayname: "line1"
    line1_password: "supersecret"

    So now you should be able to boot your phone and make and receive calls. Good for you!

    Setting the time

    This is a bit of a mission. You set the NTP server and timezone but also have to set the details of when Daylight Saving Time starts and finishes. Fortunatly the rules are available here and it seems that DST is stardardised across the EU. The following example goes in SIPDefault.cnf and should get you going for the UK. Change the time zone for Europe. Change something else for the rest of the world
    sntp_server: "pool.ntp.orgt"
    sntp_mode: unicast
    time_zone: GMT
    dst_offset: 1
    dst_start_month: March
    dst_start_day_of_week: Sun
    dst_start_week_of_month: 8
    dst_start_time: 01
    dst_stop_month: Oct
    dst_stop_day_of_week: Sun
    dst_stop_week_of_month: 8
    dst_stop_time: 02
    dst_auto_adjust: 1
    time_format_24hr: 1
    date_format : D/M/Y

    Phone directory

    The CISCO phone directory is stored in an XML file that can hold 32 numbers. You can either get the phone directory XML file directly or use a form to send a search criteria to a script that returns matching results. Firstly you have to assign a button to the phone directory. There are various programmable buttons on the phone that you could use but since one is marked "directory" it makes sense to use that. First you add an entry to the SIPDefault.cnf, telling it what to do when the directory button is pressed. In the example below, pressing the button will GET directory.xml via HTTP:


    #The directory_url contains a URL to the directory XML file
    directory_url: ""

    directory.xml could just contain a phonebook in XML, like the example directory file below. This is fine if you don't want to search and don't have more than 32 entries. If you do, you have to do things a little differently. You can add the following to directory.xml:
        <Title>Phone book</Title>
        <Prompt>Prompt text.</Prompt>
    Now, when you press the directory button, you will be presented with a search screen. You can enter a name and press search. It will then try to GET / from the HTTP server. Thus you will have to write a script that searches for the string in your phone directory and returns the results using the CISCO XML format below. This is obviously a lot more work but hey, these are enterprise phones!

    Example directory file

    <Prompt>Who you gonna call?</Prompt>

    Voicemail number

    The 7940 has a voicemail button that dials your viocemail. Sound clever? It's just a config directive that tells it which number to dial when thebutton is pressed. Add the following to your SIPDefault.cnf:messages_uri: "8500"
    So, when you hit the message button it dials 8500, which, as we all know is the default main voicemail number for Asterisk. We can also go a step further and create a number that dials the voice mail. Change the number in the mesasges_uri to 8501 and create the following extention in extentionss.conf:
    exten => 8501,1,VoicemailMain(${CALLERID(number)})
    exten => 8501,n,Hangup

    This means that when you press the message button it will dial 8501 which Asterisk will call voicemail and pass the number of your phone to the Voicemail. This will go stagiht to that mailbox number without having to enter it. If the voicemail box for that phone does not match the phone's callerID num, you could pass it statically, of course.

    Message Waiting Indicator

    Asterisk can turn on and off the Message Waiting Indicator on phones. This is simply a case of adding "mailbox " to the phone definition in the sip.conf file. Then, when there is a new message in that mailbox, it will turn on the MWI on the phone. When there is no voicemail it will be turned off.