Thursday 13 September 2012

Digit Manipulation on Voice Gateway

You might encounter situation where you need to control the actual digits contained in the telephone numbers that enter or leave the gateway. You might need to add the area code to a call that is routed out of the public switched telephone network (PSTN), or remove a site code from an intracompany call, for instance. Digit manipulation encompasses adding, subtracting, and changing telephone numbers. You can manipulate calling numbers, called numbers, and redirecting numbers. You can use techniques that are applied to incoming or outgoing calls, or globally to all calls. You can manipulate telephone numbers before a dial peer is matched, or afterward.

 You can perform digit manipulation only on H.323, SIP gateway, Cisco CallManager Express and routers that are using Survivable Remote Site Telephony (SRST).Several different digit manipulation techniques exist, each of which controls telephone numbers in a different way and can be applied at specific points in the call flow. I am going to cover techniques one by one.

Digit stripping
VoIP dial peers transmit all digits in the called number by default. However, POTS dial peers remove, or strip, any outbound digits that explicitly match their destination pattern. For example if users dial 9 to reach an outside number and you don’t want the number 9 sent to the PSTN as part of the called  number. When you configure the destination pattern of a POTS dial peer as 9T, the 9 is matched, so it is stripped and remaining will transmit. In case of 911 or 999 number you want to send all digits to PSTN   then you have to disable the default behavior of the dial-peer. Like no digit-strip
!
Dial-peer voice 1 pots
No digit-strip
Destination-pattern 911
Port 0/0/0:15
!
Forward Digit
Forward digit provides you more control on called numbers which are going to PSTN.  Below are the
Available options in forward-digit

Forward-digits all option allow you to send all called digits to PSTN

Dial-peer voice 1 pots
Destination-pattern 911
Port 0/0/0:15
Forward-digits all (this will forward all digits to PSTN)
!
Forward-digits  Number option gives control on number of digits to be forwarded to PSTN
Dial-peer voice 2 pots
Destination-pattern 9[2-9]……
Port 0/0/0:15
Forward-digits 7 (this will forward 7 digits to PSTN starting from 2-9)
!
Forward-digits extra option tells the gateway to forward any digits that are longer than the length of the destination pattern.
(let’s say you dialed 95554000, forward-digits extra tell the gateway to forward the extra digit 4000 to PSTN)
!
Dial-peer voice 2 pots
Destination-pattern 9555
Port 0/0/0:15
Forward-digits extra
!

Prefix Digit
Prefix digit gives the flexibility to add prefix in the called number. When a user dials the international number 900971501234567, the digits are manipulated before being sent to the PSTN. The original digits 9 and 00 are stripped, and a 00 is prefixed to the remaining number. This way PSTN will receive the number 00971501234567.
Dial-peer voice 3 pots
Destination-pattern 900T
Port 0/0/0:15
Prefix 00
!
Number Expansion
Number expansion is another way to add digits to called number or translate the called number into another number. Hence number expansion is applied globally to the gateway. But keep in mind that Number expansion digit manipulation occurs before any outbound dial peer is matched. 

Let’s say you want to translate 4 digit number (4444) to mobile number 90501234567 then you have to use the num-exp command
!
Num-exp  4444  90501234567
!
For verification use the show dialplan number command
!
Show dialplan number  4444
Macro Exp: 90501234567
!

Voice Translation Rules and Profiles
We can get more granular digit manipulation using translation profile which contains translation rules. The techniques which were discussing before can alter only called number or dialed number identification server (DNIS) digits. Translation profile is much powerful. You can do digit manipulation of called number, calling number or redirected number.

Using voice translation profiles for digit manipulation required three steps.

  1. Create Translation rule. Maximum 15 translation per rule
  2. Create Translation Profile, within translation profile you can user one calling number rule, one called number rule and one redirect number rule
  3. Apply the voice translation profile to all VoIP calls globally, a dial peer, a voice port, a trunk group, a source IP group, or an interface.
Voice Translation Rule
!
Voice translation-rule 1
rule precedence  /matchrule/  /replacerule/
rule 1 /4444/ /5555/

Voice_GW#test voice translation-rule 1 4444
Matched with rule 1
Original number: 4444                     Translated number: 5555
Original number type: none      Translated number type: none
Original number plan: none      Translated number plan: none


Regular Expression Special Characters
Character
Meaning
.
Matches any single character
[]
Matches one number within the brackets; for example, the expression [234] would match either 2, 3, or 4
[^]
Matches a number except one within the bracket
-
Indicates a range of numbers when used within brackets
^
When used before a string, denotes the beginning of a string
$
Denotes the end of a string
*
Matches 0 or more occurrences of the previous expression
+
Matches 1 or more occurrences of the previous expression
?
Matches 0 or 1 occurrence of the previous expression (use Ctrl-v ? to enter in the IOS)
()
Groups digits into sets
\
Changes the meaning of the following character
&
Brings all the matched digits into the replacement string
rule 2 /^555/ /444/
 If you wanted to match 555 only when it appeared at the beginning of a string, you could use the caret character.
To match a string containing only 555, add the dollar sign at the end and the caret at the beginning:
rule 2 /^555$/ /444/

!

Let’s say we have a requirement to add a prefix in calling number from PSTN so users can dialer numbers  from received/miss calls list.
!
voice translation-rule 1
 rule 1 /^\(.*\)/ /9\1/
Breaking the match portion of Rule 1 
·         The caret (^) designates the beginning of a string.
·         In \(.*\), the backslashes change the parentheses from literal characters to set-delimiters. The characters within the set are .*, which matches any character that is repeated zero or more times.
The following list breaks down the replacement portion of the rule
·         9 add the initial literal characters.
·         In the \1 part of the expression, the backslash changes the meaning of the digit 1. It is no longer a literal number instead, it points to the first set in the matching part of the rule. The first set is (.*). Thus, any digits matching that set are inserted after 9.
We are applied the translation-rule 1 in the translation-profile using calling option and after the applied the translation-profile to physical port for all incoming calls from PSTN
!
voice translation-profile addinPrefix 
translate calling 1
!
voice-port 0/0/0:15
translation-profile incoming addinPrefix
!
Let’s assume that PSTN service provider sends 7digit called number of DID on PRI interface but we are using 4digit extension number on IP Phones. Digit manipulation required on voice gateway to achieve the successful call flow.
!
DID 3374xxx and IP Phone extension 4xxx
!
Voice Translation-rule 1
 Rule 1 /^3374/ /4/
!
Voice Translation-profile DIDTranslate called 1
!
voice-port 0/0/0:15
 translation-profile incoming DID!

Troubleshooting Digit Manipulation
When you are troubleshooting digit manipulation, first verify the configuration. Test the digit manipulations as much as possible before deploying them in a live network. If they do not work as expected, check to make sure that they are correctly configured and that other rules do not interfere.
·         test voice translation-rule rule-number phone-number Shows the results of a translation rule, enabling you to test it to ensure that it does what you planned
·         debug voice translation Shows the translations happening
·         show dialplan number number Verifies number expansion and which dial peers a phone number matches
·         debug voip ccapi inout Shows inbound and outbound dial peers being matched
·         show num-exp[number] Displays the number expansion rules configured
·         show dial-peer voice [tag] Displays any CLID, translation profiles, call blocking, disconnect cause, digit stripping, forwarding, or prefixing that is configured on the dial peer
·         show voice translation-rule [number | sort [ascending|descending]] Lists the translation rules that are configured on the router and all translation patterns configured for each one
·         show voice translation-profile [name | sort [ascending|descending]] Lists the translation profiles configured on the router and all translation rules associated with each one
·         debug isdn q931 Shows the called and calling numbers sent out a PRI link for troubleshooting CLID commands
·         csim start phone-number Simulates a phone call from the router; can be used with debugs

2 comments: