Introduction to Codecs

A codec is a device or software capable of encoding or decoding a digital data stream or signal. Audio codecs can code or decode a digital data stream of audio. Video codecs enable compression or decompression of digital video.

CUBE uses codecs to compress digital voice samples to reduce bandwidth usage per call. This chapter describes the basics of encoding digital voice samples using codecs and how to configure them.

Why CUBE Needs Codecs

CUBE uses codecs to compress digital voice samples to reduce bandwidth usage per call. Refer to Table 2 to see the relationship between codec and bandwidth utilization.

Configuring codecs on a device (configured as CUBE) allows the device to act as a demarcation point on a VoIP network and allows a dial peer to be established only if the desired codec criteria are satisfied. Additionally, preferences can be used to determine which codecs are selected over others.

If codec filtering is not required, CUBE also supports transparent codec negotiations. This enables negotiations between endpoints with CUBE leaving the codec information untouched.

The illustrations below show how codec negotiation is performed on CUBE. Two VoIP clouds need to be interconnected. In this scenario, both VoIP 1 and VoIP 2 networks have G.711 a-law configured as the preferred codec.

Figure 1. Codec Negotiation on CUBE

In the first example, the CUBE router is configured to use the G.729a codec. This can be done by using the appropriate codec command on both VoIP dial peers. When a call is set up, CUBE will accept only G.729a calls, thus influencing the codec negotiation.

In the second example, the CUBE dial peers are configured with a transparent codec and this leaves the codec information contained within the call signaling untouched. Because both VoIP 1 and VoIP 2 have G.711 a-law as their first choice, the resulting call will be a G.711 a-law call.

Restrictions for Voice-Class Codec Transparent

  • While using the voice-class codec transparent, only the offer is passed transparently (without filtering). Codec filtering is done on the SDP present in answer and the first codec is passed to other side.

  • CUBE does not support Early-Offer to Delayed-Offer (EO-DO) call flows.


    Note


    You can use 'pass-thru content sdp', if you do not want to involve CUBE in the codec negotiation.


Voice Media Transmission

When a VoIP call is established, using the signaling protocols, the digitized voice samples need to be transmitted. These voice samples are often called the voice media. Voice media protocols found in a VoIP environment are the following:

  • Real-Time Transport Protocol (RTP)—RTP is a Layer 4 protocol that is encapsulated inside UDP segments. RTP carries the actual digitized voice samples in a call.
  • Real-Time Control Protocol (RTcP)—RTcP is a companion protocol to RTP. Both RTP and RTcP operate at Layer 4 and are encapsulated in UDP. RTP and RTCP typically use UDP ports 16384 to 32767, though these ranges may vary according to hardware platform. However, RTP uses the even port numbers in that range, whereas RTcP uses the odd port numbers. While RTP is responsible for carrying the voice stream, RTcP carries information about the RTP stream such as latency, jitter, packets, and octets sent and received.
  • Compressed RTP (cRTP)—One of the challenges with RTP is its overhead. Specifically, the combined IP, UDP, and RTP headers are approximately 40 bytes in size, whereas a common voice payload size on a VoIP network is only 20 bytes, which includes 20 ms of voice by default. In that case, the header is twice the size of the payload. cRTP is used for RTP header compression and can reduce the 40-byte header to 2 or 4 bytes in size (depending on whether UDP checksums are in use), as shown in the figure below.
    Figure 2. Compressed RTP
  • Secure RTP (sRTP)—To help prevent an attacker from intercepting and decoding or possibly manipulating voice packets, sRTP supports encryption of RTP packets. In addition, sRTP provides message authentication, integrity checking, and protection against replay attacks.

    VPN technology like IP Security (IPSec) may be used to protect traffic between sites. Encrypting sRTP traffic at the source of transmission results in encrypting already encrypted traffic, adding significant overhead and bandwidth needs. So it is recommended that sRTP is used for voice traffic, and that this traffic is excluded from IPSec encapsulation. sRTP uses lesser bandwidth, has the same level of security, and can be used by devices at any location because the payload is originated and terminated at the voice endpoint. Because endpoints can be mobile, the security follows the phone.

Voice Activity Detection

Voice Activity Detection (VAD) is a technology that works with the human nature of voice conversations, mainly that one person listens while the other talks. VAD classifies traffic as speech, unknown, and silence. Speech and unknown payloads are transported, but silence is dropped. This accounts for approximately 30 percent savings in bandwidth over time.

VAD can significantly reduce the amount of bandwidth required by a media stream. However, VAD has a few negative attributes that need to be considered. Because no packets are sent during silence, the listener can get the impression that the talker has been disconnected. Another characteristic is that it takes a moment for VAD to recognize the speech as having started again, and as a result, the first part of the sentence can be clipped. This can be annoying to the listening party. Music on Hold (MoH) and fax can also cause VAD to become ineffective because the media stream is constant.

VAD is enabled by default in CUBE dial peers as long as the codec selected supports it. VAD can be disabled at the VoIP dial peer using the no vad command. Some codecs, such as G.729b and G.729ab, support Comfort Noise Generation (CNG). When VAD is enabled, white noise is played to the listener during times when no packets are received. This leads the listener to believe that background noise is being heard. Cisco IP Phones and most gateways support CNG.

G.729 Annex-B and G.723.1 Annex-A include an integrated VAD function, but otherwise performs the same as G.729 and G.723.1, respectively.


Note


VAD to NO-VAD calls are not supported by CUBE.


VoIP Bandwidth Requirements

The amount of bandwidth required varies by the codec and the transmission media. Two events require bandwidth. The media stream itself requires bandwidth between 17 to 106 kbps depending on codec, header compression, and Layer 2 and 3 headers. In addition, call signaling must be taken into account. While bandwidth required by call signaling is much smaller, it can cause problems on a network due to irregular requirements.

Table 1. Protocol Header Size Assumptions
Protocol Header size
IP 20 bytes
UDP 8 bytes
RTP 12 bytes
cRTP Reduces size of IP, UDP, RTP to 2 or 4 bytes

The table below gives calculations for the default voice payload sizes in Cisco CallManager or CUBE. For additional calculations, including different voice payload sizes and other protocols, use the TAC Voice Bandwidth Codec Calculator (registered customers only). For an explanation of each of the column headings, see the table below.

Table 2. Codec and Bandwidth Information
Codec & Bit Rate (kbps) Codec Sample Size (Bytes) Codec Sample Interval (ms) Mean Opinion Score (MOS) Voice Payload Size (Bytes) Voice Payload Size (ms) Payload Size (ms) Packets Per Second (PPS) Bandwidth MP or FRF.12 (kbps) Bandwidth w/cRTP MP or FRF.12 (kbps) Bandwidth Ethernet (kbps)
G.711 (64 kbps) 80 10 4.1 160 20 50 82.8 67.6 87.2
G.729 (8 kbps) 10 10 3.92 20 20 50 26.8 11.6 31.2
G.723.1 (6.3 kbps) 24 30 3.9 24 30 33.3 18.9 8.8 21.9
G.723.1 (5.3 kbps) 20 30 3.8 20 30 33.3 17.9 7.7 20.8
G.726 (32 kbps) 20 5 3.85 80 20 50 50.8 35.6 55.2
G.726 (24 kbps) 15 5 60 20 50 42.8 27.6 47.2
G.728 (16 kbps) 10 5 3.61 60 30 33.3 28.5 18.4 31.5
G722_64k(64 kbps) 80 10 4.13 160 20 50 82.8 67.6 87.2
ilbc_mode_20(15.2 kbps) 38 20 NA 38 20 50 34.0 18.8 38.4
ilbc_mode_30(13.33 kbps) 50 30 NA 50 30 33.3 25.867 15.73 28.8
Table 3. Explanation of Terms
Codec Bit Rate (kbps) Based on the codec, this is the number of bits per second that need to be transmitted to deliver a voice call. (codec bit rate = codec sample size / codec sample interval).
Codec Sample Size (Bytes) Size (Bytes) Based on the codec, this is the number of bytes captured by the digital signal processor (DSP) at each codec sample interval. For example, the G.729 coder operates on sample intervals of 10 ms, corresponding to 10 bytes (80 bits) per sample at a bit rate of 8 kbps. (codec bit rate = codec sample size / codec sample interval).
Codec Sample Interval (ms) This is the sample interval at which the codec operates. For example, the G.729 coder operates on sample intervals of 10 ms, corresponding to 10 bytes (80 bits) per sample at a bit rate of 8 kbps. (codec bit rate = codec sample size / codec sample interval).
MOS MOS is a system of grading the voice quality of telephone connections. With MOS, a wide range of listeners judge the quality of a voice sample on a scale of one (bad) to five (excellent). The scores are averaged to provide the MOS for the codec.
Voice Payload Size (Bytes) The voice payload size represents the number of bytes (or bits) that are filled into a packet. The voice payload size must be a multiple of the codec sample size. For example, G.729 packets can use 10, 20, 30, 40, 50, or 60 bytes of voice payload size.
Voice Payload Size (ms) Payload Size (ms) The voice payload size can also be represented in terms of the codec samples. For example, a G.729 voice payload size of 20 ms (two 10 ms codec samples) represents a voice payload of 20 bytes [ (20 bytes * 8) / (20 ms) = 8 kbps ]
PPS PPS represents the number of packets that need to be transmitted every second in order to deliver the codec bit rate. For example, for a G.729 call with voice payload size per packet of 20 bytes (160 bits), 50 packets need to be transmitted every second [50 pps = (8 kbps) / (160 bits per packet) ]

Supported Audio and Video Codecs

CUBE is required to support the codec used between endpoints. g729r8 is supported by default. All other codecs have to be configured. The following codecs are supported:

Table 4. Audio Codecs Supported on CUBE
Codec Keyword Codec

aacld

AACLD 90000 bps
clear-channel

Clear Channel 64000 bps (No voice capabilities: data transport only)

g711alaw

G.711 A Law 64000 bps

g711ulaw G.711 u Law 64000 bps
g722-48

G722-48K 64000 bps - Only supported for H.320<->H.323 calls

g722-56

G722-56K 64000 bps - Only supported for H.320<->H.323 calls

g722-64

G722-64K 64000 bps

g723ar53

G.723.1 ANNEX-A 5300 bps (contains built-in VAD that cannot be disabled)

Not supported on PVDM3.

g723ar63

G.723.1 ANNEX-A 6300 bps (contains built-in VAD that cannot be disabled)

Not supported on PVDM3.

g723r53

G.723.1 5300 bps

Not supported on PVDM3.

g723r63

G.723.1 6300 bps

Not supported on PVDM3.

g726r16

G.726 16000 bps

g726r24

G.726 24000 bps

g726r32

G.726 32000 bps

g728

G.728 16000 bps

g729br8

G.729 ANNEX-B 8000 bps (contains built-in VAD that cannot be disabled)

g729r8 G.729 8000 bps
gsmamr-nb

GSM AMR-NB 4750 to 12200 bps (contains built-in VAD that cannot be disabled)

ilbc

iLBC 13330 or 15200 bps

isac

iSAC 10 to 32 kbps (variable bit-rate)

mp4a-latm

MP4A-LATM upto 128 kbps

transparent

Transparent; uses the endpoint codec

opus

Opus upto 510 kbps

Table 5. Video Codecs Supported on CUBE
Codec Keyword Codec
h261

Video Codec H261

h263

Video Codec H263

h263+

Video Codec H263+

h264

Video Codec H264

mpeg4

Video Codec MPEG-4 ISO/IES 14496-2

How to Configure Codecs

Configuring Audio and Video Codecs at the Dial Peer Level

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. dial-peer voice number voip
  4. Enter one of the following to configure an audio codec:
    • codec codec [bytes payload-size fixed-bytes ]
    • codec isac [mode {adaptive | independent} [bit-rate value framesize { 30 | 60 } [fixed] ]
    • codec ilbc [mode frame-size [bytes payload-size]]
    • codec mp4-latm [profile tag]
    • codec opus [profile tag]
  5. Do the following to configure a video codec:
    • video codec codec
  6. (Optional) Do one of the following to configure RTP payload type:
    • rtp payload-type cisco-codec-isac number
    • rtp payload-type cisco-codec-ilbc number
    • rtp payload-type cisco-codec-video-h263+ number
    • rtp payload-type cisco-codec-video-h264 number
    • rtp payload-type opus number
  7. end

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:

Device> configure terminal  

Enters global configuration mode.

Step 3

dial-peer voice number voip

Example:

Device(config)# dial-peer voice 1 voip  

Enters dial peer configuration mode for the specified VoIP dial peer.

Step 4

Enter one of the following to configure an audio codec:

  • codec codec [bytes payload-size fixed-bytes ]
  • codec isac [mode {adaptive | independent} [bit-rate value framesize { 30 | 60 } [fixed] ]
  • codec ilbc [mode frame-size [bytes payload-size]]
  • codec mp4-latm [profile tag]
  • codec opus [profile tag]

Example:

For g711alaw Codec
Device(config-dial-peer)# codec g711alaw

Example:

For ISAC Codec
Device(config-dial-peer)# codec isac mode independent

Configures an audio codec at the dial peer level.

  • g729r8, 20-byte payload is configured by default.

Step 5

Do the following to configure a video codec:

  • video codec codec

Example:

For Video Codec
Device(config-dial-peer)# video codec h261

Configures a video codec at the dial peer level.

Step 6

(Optional) Do one of the following to configure RTP payload type:

  • rtp payload-type cisco-codec-isac number
  • rtp payload-type cisco-codec-ilbc number
  • rtp payload-type cisco-codec-video-h263+ number
  • rtp payload-type cisco-codec-video-h264 number
  • rtp payload-type opus number

Example:

Device(config-dial-peer)# rtp payload-type opus 114
(Optional)
Configures the RTP payload type.

Step 7

end

Example:

Device(config-dial-peer)# end

Returns to privileged EXEC mode.

Configuring Audio Codecs Using a Codec Voice Class and Preference Lists

Preferences can be used to determine which codecs will be selected over others.

A codec voice class is a construct within which a codec preference order can be defined. A codec voice class can then be applied to a dial peer, which then follows the preference order defined in the codec voice class.

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. voice class codec tag
  4. Do the following for each audio codec you want to configure in the voice class:
    • codec preference value codec-type[profile profile-tag ]
    • codec preference value codec-type[bytes payload-size fixed-bytes ]
    • codec preference value isac [mode {adaptive | independent} [bit-rate value framesize { 30 | 60 } [fixed] ]
    • codec preference value ilbc [mode frame-size [bytes payload-size]]
    • codec preference value mp4-latm [profile tag]
  5. exit
  6. dial-peer voice number voip
  7. voice-class codec tag offer-all
  8. end

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:

Device> configure terminal  

Enters global configuration mode.

Step 3

voice class codec tag

Example:

Device(config)# voice class codec 10 

Enters voice-class configuration mode for the specified codec voice class.

Step 4

Do the following for each audio codec you want to configure in the voice class:

  • codec preference value codec-type[profile profile-tag ]
  • codec preference value codec-type[bytes payload-size fixed-bytes ]
  • codec preference value isac [mode {adaptive | independent} [bit-rate value framesize { 30 | 60 } [fixed] ]
  • codec preference value ilbc [mode frame-size [bytes payload-size]]
  • codec preference value mp4-latm [profile tag]

Configure a codec within the voice class and specifies a preference for the codec. This becomes part of a preference list

Step 5

exit

Example:

Device(config-class)# exit 

Exits the current mode.

  • Enter your password if prompted.

Step 6

dial-peer voice number voip

Example:

Device(config)# dial-peer voice 1 voip  

Enters dial peer configuration mode for the specified VoIP dial peer.

Step 7

voice-class codec tag offer-all

Example:

Device(config-dial-peer)# voice-class codec 10

Applies the previously configured voice class and associated codecs to a dial peer.

  • The offer-all keyword allows the device to offer all codecs configured in a codec voice class.

Step 8

end

Example:

Device(config-dial-peer)# end

Returns to privileged EXEC mode.

Configuring Video Codecs Using Codec Voice Class

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. voice class codec tag
  4. video codec codec
  5. exit
  6. dial-peer voice number voip
  7. voice-class codec tag offer-all
  8. end

DETAILED STEPS

  Command or Action Purpose

Step 1

enable

Example:

Device> enable 

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:

Device> configure terminal  

Enters global configuration mode.

Step 3

voice class codec tag

Example:

Device(config)# voice class codec 10 

Enters voice-class configuration mode for the specified codec voice class.

Step 4

video codec codec

Example:

video codec h261
Configures a video codec within the voice class.

Step 5

exit

Example:

Device(config-class)# exit 

Exits the current mode.

  • Enter your password if prompted.

Step 6

dial-peer voice number voip

Example:

Device(config)# dial-peer voice 1 voip  

Enters dial peer configuration mode for the specified VoIP dial peer.

Step 7

voice-class codec tag offer-all

Example:

Device(config-dial-peer)# voice-class codec 10

Applies the previously configured codec voice class and associated codecs to a dial peer.

  • The offer-all keyword allows the device to offer all codecs configured in the codec voice class.

Step 8

end

Example:

Device(config-dial-peer)# end

Returns to privileged EXEC mode.

Verifying an Audio Call

SUMMARY STEPS

  1. show call active voice [compact]

DETAILED STEPS


show call active voice [compact]

Displays a compact version of call information for voice calls in progress.

Example:

Device# show call active voice compact

 <callID>  A/O FAX T<sec> Codec       type        Peer Address       IP R<ip>:<udp>
Total call-legs: 2
        23 ANS     T3     mp4a-latm   VOIP        Psipp          9.45.33.11:57210
        24 ORG     T3     mp4a-latm   VOIP        P123           9.45.33.11:57210

Example:

Device# show call active voice compact

<callID>   A/O FAX T<sec> Codec    type    Peer Address    IP R<ip>:<udp> 
Total call-legs: 2
58 ANS     T11          g711ulaw   VOIP     Psipp 2001:......:230A:6080
59 ORG     T11          g711ulaw   VOIP     P5000110011       10.13.37.150:6090

Configuration Examples for Codecs

Example: Configuring a Codec at Dial-Peer Level


Device(config)# dial-peer voice 5550199 voip
Device(config-dial-peer)# incoming called-number 5550199
Device(config-dial-peer)# codec g711ulaw
Device(config-dial-peer)# end

Example: Configuring a Codec Preference List and Applying it to a Dial Peer


Device(config)# voice class codec 100
Device(config-dial-peer)# codec preference 1 g711ulaw
Device(config-dial-peer)# exit
Device(config)# dial-peer voice 10 voip
Device(config-dial-peer)# voice-class codec 100
Device(config-dial-peer)# end

Example: Configuring a Codec Profile, Codec Preference List and Applying it to a Dial Peer for Opus Codec


router(config)#codec profile 79 opus
router(conf-codec-profile)#fmtp "fmtp:114 maxplaybackrate=16000; sprop-maxcapturerate=16000; maxaveragebitrate=20000; stereo=1; sprop-stereo=0; useinbandfec=0; usedtx=0"
router(conf-codec-profile)#exit

router(config)#voice class codec 80
router(config-class)#codec preference 1 opus profile 79
router(config-class)#exit

router(config)#dial-peer voice 604 voip
router(config-dial-peer)#rtp payload-type opus 126
router(config-dial-peer)#voice-class codec 80 offer-all
router(config-dial-peer)#exit