> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/telecom-concepts/label-routing.md).

# Label Routing

Label Routing is an algorithm that combines [Digit Analyzer](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/digit-analyzer/README.md) and the concept of [RouteSet](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/routelabel/README.md). It is implemented as a [RoutingScript](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/scriptable-routing-engine/README.md) in Toolpack Gateway.  This algorithm allows complex routing rules, as normally available with [RoutingScript](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/scriptable-routing-engine/README.md), but on a very large number of destination numbers.

### Concept

The concept behind label routing is quite simple.

1. A list of numbers (NPA-NXX) for a specific destination is assigned a [RouteSet](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/routelabel/README.md) name. This list can be very large
2. i.e., 514201,514202,514203, ... -> Montreal\_Qc
3. The list of routes for the destination is assigned the same [RouteSet](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/routelabel/README.md) name. This list usually is limited to the number of [network access points (NAP)](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/protocols/nap/README.md) in the system.
4. i.e., Bell, Rogers, Videotron -> Montreal\_Qc

Note: No matter how many destination numbers lead to a given destination, only a limited list of routes are selected. At this point, complex, yet efficient, routing rules can take place.

### Implementation

As previously mentioned, routeset (label) routing is implemented as a [RoutingScript](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/scriptable-routing-engine/README.md). It was written as an optional filter, and can be used in any existing scripts. This filter is a before\_filter, and reduces the amount of routes the routing script will work with.

### Performance

Typically, there are only a few hundred labels (e.g. countries/states/regions/providers/cities identifiers) but there are hundred thousands and millions of actual numbers pointing to those labels. Each label will correspond to a dynamic route associating it to a destination NAP. The biggest portion of the data comes from the digitmap files. These million digit maps are loaded into binary trees when a configuration is applied allowing longest match algorithm to be performed with constant delay regardless of the number of digit map entries in memory. The only performance impact is upon the "Apply configuration" time, not on the call processing flow. Here are a few samples of configuration loading time on a TMG3200 running release 2.7:

| \*\* Nb of digitmap entries \*\* | \*\* Uncompressed digitmap filesize \*\* | \*\* Apply configuration time (s) \*\* |
| -------------------------------- | ---------------------------------------- | -------------------------------------- |
| Not used                         | -                                        | \~6s                                   |
| 250k                             | 4.4MB                                    | \~7s                                   |
| 500k                             | 8.8MB                                    | \~8s                                   |
| 5M                               | 88MB                                     | \~17s                                  |

Note that digit map files can be gzipped to reduce size before importing them in the File Db.

### Configuration

* [Label routing for v3.2](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/tmedia-tdev-and-tsig-web-portal-3-2-call-route-settings/README.md#tablabel-routing)
* [Label routing for v3.0](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/tmedia-tdev-and-tsig-web-portal-3-0-call-routes-settings/README.md#label-routing)
* [Label routing for v2.10](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/tmedia-tdev-and-tsig-web-portal-2-10-call-routes-settings/README.md#label-routing)
* [Label routing for v2.9](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/web-portal-2-9-call-routes-settings/README.md#label-routing)
* [Label routing for v2.8](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/web-portal-2-8-call-routes-settings/README.md#label-routing)
* [Label routing for v2.7](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/tmedia-tsig-and-tdev-web-portal-2-7-tutorial-guide/README.md#label-routing)
* [Label routing for v2.6](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/tmedia-tsig-and-tdev-web-portal-2-7-tutorial-guide/README.md#label-routing)

### Useful links

* [Tmedia Routing](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/platforms/tmedia-routing/README.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/telecom-concepts/label-routing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
