Page tree

Applies to VoipNow Professional, VoipNow 3, VoipNow 3.5 and newer!

Overview

A successful codec negotiation is an essential condition for a successful call between two parties. At the same time, an audio stream cannot be established between two parties unless a mutually supported codec is found and used. The supported codecs are published during the SIP setup of the call; they are mentioned in the SDP part of the INVITE/200 OK exchange.

In VoipNow's case, the voice passes through Asterisk so an extra negotiation takes place.

Codec negotiation in VoipNow

As mentioned above, because the audio path includes Asterisk, an extra negotiation occurs. The SIP signalling also passes through Kamailio.

In the case of a call from the internal (private) network to the outside (public) network, the flow of the SIP signalling is as follows: Internal caller >> Kamailio >> Asterisk >> Kamailio >> External callee.

Here is a Wireshark capture of the flow (click to enlarge):

The following parties are involved:

Caller: extensionA 0003*023 (public number 2023) with IP 192.168.1.227

VoipNow with IP 10.150.20.13 with Kamailio on port 5060 and asterisk on port 5050

Calee: phone number 3004 with IP 10.150.20.14

Let's look at some of the codec settings:

The caller is a Yealink device with the following codecs activated:

The device publishes these codecs in the SDP of the INVITE sent from 192.168.1.227:

This INVITE reaches Kamailio and then is forwarded to Asterisk. The codecs remain unchanged and Asterisk recognizes the codecs supported by the caller.

Next, Asterisk initiates an INVITE towards the callee at address 10.150.20.14. It does so through a SIP channel using the following codecs:

The INVITE containing all the codecs enabled on the channel looks like this:

The INVITE is sent to Kamailio which forwards it to the calle at 10.150.20.14 without changing the codecs. At this point, the callee is informed about the codecs supported by VoipNow.

The callee will now answer the call with an 200 OK message. This message will contain an SDP mentining the codecs it supports:

Now both VoipNow and the callee at 3004 know the codecs supported by the other parties. As you can see, the only common codec supported by both parties is G711 u-law (PCMU). This means G711 will be used for the voice stream between VoipNow and the callee:

Now it's time for Asterisk to send the 200 OK to the caller to let him know that the call was answered. This 200 OK message will also contain the codecs supported by VoipNow for the communication with the caller.

Note that these codecs do not have to be the same as for the other leg of the call.

These codecs are defined under the Provisioning and SIP menu of the 0003*023 extension:

The resulting 200 OK SDP will look like this:

Now both the caller (Yealink at 192.168.1.227) and VoipNow know the codecs supported by the other party. In this case, we have two common codecs, G711 u-law and G711 a-law (PCMU and PCMA). PCMU has a higher priority (it comes before PCMA in the SDP codec list), so it will be used for the voice stream between the caller and VoipNow:

The voice call is finally established with 4 streams, all on G711 u-law: Caller <<->> VoipNow and Voipnow <<->> Callee, both bidirectional.

The two legs of the call can use different streams. This means that Asterisk will perform transcoding (which also uses a bit more CPU)

Other considerations

The codecs that you can check/uncheck in for the extensions can be selected from Unified Communications >> Zero Priority >> SIP area.

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.