Understanding Number Translation

Understanding Number Translation
S
Written by Sergiiy
Updated 1 year ago

Practical Role of Number Translation


Number translation plays very important role in today’s VoIP world by allowing network with different and often conflicting numbering conventions to communicate. In ideal world there would be only one numbering standard, and everybody would adhere to it, but unfortunately this is not the case in real world.

Even as long as plain old PSTN is considered, almost each country has its own incompatible standards for dialing local, long distance and international numbers. Over the years people got used to it, so that any VoIP provider who wants to provide services to customers in different countries will face the need to somehow compensate for those differences and provide consistent numbering plan in the system, still letting users dial numbers in the way they have used to.

Just like users, many VoIP carriers for various reasons require from their customers to send calls to them using some “weird” numbering plans (country-specific plans, technical prefixes, etc). To allow dealing with all those real-world scenarios, the Softswitch provides flexible number translation mechanism, whose task is to compensate for difference in dialing habits of individual users and allow adhering with Vendor’s requirements. The diagram below illustrates how different CLD number translations are applied during a typical call.

  1. The customer dials number in his SIP Phone. He enters the phone number in the same format he uses on conventional phone. The number is delivered to the Softswitch, which performs authentication as a result identifying corresponding Account in the system. In the example above, customer who is physically located in Vancouver, Canada wants to call number 123456 in Dnepropetrovsk, Ukraine.
  2. After identifying the calling Account the Softswitch translates number using CLD Translation Rule specific for this account. In the example above this process results in the international dialing prefix 011 to be removed. The CLD becomes 380-56-123456 – number in the E.164 format.
  3. The Softswitch then passes resulting number into routing logic, which builds list of possible destinations (Connections) for terminating the call to. In the example above, two such Connections has been identified – the Connection “A” and the Connection “B”.
  4. The called number in E.164 format is passed to the routing engine along with the set of Connections that can accept this call along with CLD Translation Rules corresponding to each of those Connections. Routing engine tries to send call to each of those Connections until it is either connected or there are no more Connections to try. In the example above, in the process of trying to reach the final destination for the call the Softswitch first tries to send it to Connection A, which corresponds to gateway connected to the PSTN in the same area where the destination number is. Therefore, applying CLD Translation Rule for Connection A removes country code and local area code from the E.164 number and it becomes simply 123456 (4a). For some reason, the call is not going through, so that the Softswitch picks up the next Connection, Connection B, from the routing list. The Connection B corresponds to the gateway connected to the PSTN in the same country, but in different area code. Again, before sending the call to that gateway the Softswitch takes CLD in E.164 format and allies corresponding CLD Translation Rule, which in this case removes country code (380) and replaces it with long-distance access code (80). The CLD becomes 80-56-123456.

How Number Translation Works


The Softswitch is built with assumption that all numbers inside the system are in the E.164 format, that is, country code followed by the area code followed by the local number followed by the optional extension number. However, as previous section explains in the real world the calls will be coming in some user-specific, which needs to be converted into E.164 and also Vendors are likely to expect some different format of CLDs sent to them.

For the purpose of doing Account-specific to E.164 and then E.164 to Vendor-specific conversions the system provides three different features allowing translating called or calling number at different stages of the call propagation through the switch. There are 6 basic types of number translation available in the Softswitch:

  • Incoming Destination Number Translation in Authentication Rule. Configured at authentication rule level, applied to called number after matching specific authentication rule and before per-Account Number Translation. Configured via CLD Translation Rule parameter in Authentication Rules of Account or via CLD Translation Rule parameter in DID preferences (since 4.5 version)
  • Incoming Calling Number Translation in Authentication Rule. Configured at authentication rule level, applied to calling number after matching specific authentication rule and before per-Account Number Translation. Configured via CLI Translation Rule parameter in Authentication Rules of Account or via CLI Translation Rule parameter in Authentication Rules of DID.
  • Incoming per-Account Destination Number Translation. Configured at per-account basis, applied to called number before any call rating and routing decisions are made. Configured via per-Account CLD Translation Rule Account parameter.
  • Incoming per-Account Calling Number Translation. Configured at per-account basis, applied to calling number before any call rating and routing decisions are made. Configured via two per-Account parameters: CLI and Force CLI. If Force CLI is ON then CLI of all incoming calls matched to that Account will be replaced with value of the CLI parameter.
  • Outgoing Destination Number Translation. Configured at per-connection basis, applied to called number obtained after applying incoming called number translation rule and after the rating and routing decisions are made but before a call is send to this particular connection. Configured via CLD Translation Rule parameter for each Connection or Outbound CLD in Trunks.
  • Outgoing Calling Number Translation. Configured at per-connection basis, applied to an original calling number before a call is send to this particular connection. Configured via per-Connection CLI Translation Rule parameter.

Translation Rule Syntax

Translation rules are specified either as the replacement numbers or as a set of regular expressions with Python syntax in the following two forms:

  • s/<match what>/<replace with>/
  • s/<match what>/<replace with>/g


The former will match/replace a single matched occurrence or pattern, while the latter – all of them. Several expressions may be used in one translation rule; in this case they need to be separated by semicolon (“;”).

There are several “special” symbols in <match what> which allow you to define matching rules, for example ^ matches the beginning of the string, while $ - matches the end, so that for example ^1 will only match 1 as the first character of the string, while 9$ will only match 9 as a last character.

For example, the following translation rule can be used to strip the leading 011 prefix from the number:

  • s/^011//


Translation rule will add 53872 prefix:

  • s/^/53872/


While the next rule will result in the number replaced with 123456 in all cases unconditionally.

  • 123456

Translate all non-10 digit CLIs into a new one, and bypass the CLIs with a different length:

  • s/^.{0,9}$/0123456789/

Exclude + from the front of the number:

  • s/^[+]//

Add 1 to any sequence of 10 symbols:

  • s/^(.{10})$/1\1/

Check if number contains a "space" OR "-" (dash) OR "." (dot) and replace all with "block":

  • s/^.*([ ]|\-|\.).*$/block/

Find space in number and remove it:

  • 's/[ ]//'

If number does not start with 14 prefix, then replace it with "BLOCK":

  • 's/^(?!(14)).*$/BLOCK/'

Random number generation:

To replace the original value with 5 random characters each of which can be 0, 1, 2, 3 and 6:

  • s/.*/${R:[0-3,6]5}/

To get the translated number with some constant prefix and the body with the numbers from some range:

Example:

prefix +17266

body - any number from 00000001 to 99999999

  • s/.*/+17266${R:[0-9]7}/

Generate 1 of 6 random numbers

  • s/.*/${R:[a-f]1}/; s/^a/+919995346432/; s/^b/+919995000100/; s/^c/+919846000012/; s/^d/+919746532512/; s/^e/+919783252017/; s/^f/+919230456789/;

Did this answer your question?