Juha
Heinanen
FhG FOKUS

2003
FhG FOKUS
$Revision: 1.1 $
$Date: 2006/12/11 18:52:26 $

# LCR Module

## Overview

Least cost routing (LCR) module implements two related capabilities:

- LCR may sequentially forward requests to one or more gateways using the load_gws and next_gw functions.
- LCR may sequentially forward contacts if they don't share the the same qvalues. Use the functions load_contacts and next_contacts to access and select a contact.

Gateway selection is based on caller's RPID URI (if available in caller's RPID AVP after authentication) or From URI and user part of Request-URI (telephone number). Gateway patterns matching RPID or From URI and telephone number are ordered for forwarding purposes as follows:

- According to longest user part match
- According to priority
- Randomly

Each gateway belongs to a gateway group either alone or among other gateways. All gateways in a group share the same priority. Gateway and routing information is kept in two tables: gw and lcr.

When a gateway is selected, Request-URI is rewritten with information from gw table: URI scheme, prefix, IP address, port, and transport protocol. Valid URI scheme values are:

- NULL = sip
- 1 = sip
- 2 = sips.

If a prefix is specified it will be prepended to the Request-URI user part.

Currently valid transport protocol values are:

- NULL = none
- 1 = udp
- 2 = tcp
- 3 = tls

Table lcr contains any prefix to be applied to the user part of Request-URI, the From URI, the gateway group id, and the priority. The From URI can contain special characters % and _ matching any number of any characters and any one character, respectively.

In addition to gw and lcr tables there is third table gw_grp that is used for administrative purposes only. In this table you may map names to the gateway group ids.

## Dependencies

The module depends on the following modules. These modules must be loaded before the LCR module

- tm module
- mysql module