-
Notifications
You must be signed in to change notification settings - Fork 2
Routing
Marcelo Gornstein edited this page Jul 30, 2014
·
31 revisions
Here's a brief description of the first steps in a call lifecycle. The term trunk is used intensively here, so you might want to also read the Trunks wiki entry.
- New call in a trunk.
- The name of the trunk is used to find a trunk in the system.
- Since #165, a trunk is first looked up by ip:
- If one is found, that trunk is chosen.
- If multiple are found, all dialrules are applied to get a destination DID. When a valid DID is found in the database, that organization_id is picked up, and that trunk is selected.
- If none is found, then the trunk name is looked up.
- If none is found, the call ends with error unknown_incoming_trunk.
- If multiple matching trunks are found (this should never happen), the call ends with error too_many_matching_trunks.
- If the trunk does not belong to an organization, the call ends with error trunk_without_organization.
- If the trunk belongs to a disabled carrier, the call ends with error carrier_disabled (since #79).
- If the trunk belongs to a carrier other than local, and the carrier's organization is different from the trunk's organization, the call ends with error invalid_carrier_organization.
- If the trunk's organization does not exist, the call ends with error unknown_source_organization.
- If the call is from a subscriber, and the trunk belongs to an organization different than from the subscriber's organization, the call ends with error invalid_subscriber_organization.
- If found, the incoming dialrules of the trunk (ani) are used to translate the ani to E164.
- If the ani can't be translated to E164, the call ends with error cant_translate_incoming_ani
- If found, the incomig dialrules of the trunk (dnis) are used to translate the dnis to E164.
- If the dnis can't be translated to E164, the call ends with error cant_translate_incoming_dnis
- If the call is from a subscriber, and the subscriber belongs to an organization different than from the did's organization, the call ends with error invalid_did_organization.
- If the call is from a subscriber, and the routing plan chosen belongs to an organization different than from the subscriber's organization, the call ends with error invalid_routing_plan_organization.
- If the trunk belongs to a client, the ani in e164 format is used to search for a did in the system:
- The call ends with error client_using_unknown_did if none is found.
- If a did is found, but it's owned by a different subscriber, the call ends with ani_in_wrong_trunk.
- If the trunk belongs to a client, the numbering plan dial rules are used to translate the dnis into E164.
- If the dnis can't be translated to E164, the call ends with error cant_translate_dnis_by_numplan.
- For on net calls, the plan assigned to the target dnis will be checked to know if it allows incoming calls, if not, the call ends with incoming_calls_not_allowed_for_client.
- For on net calls, when an incoming call should be charged but there's no tariff for that specific combination of ani/dnis, the call ends with unknown_tariff_for_incoming_call.
- For on net calls, when the target subscriber and the target did have different organizations, the call will end with invalid_organization_for_target_did.
- For on net calls, any routes are picked up (any organization).
- For off net calls, only routes that belong to the subscriber organization are looked for.
- All off net calls from trunks that don't belong to a subscriber or an internal trunk, are denied with the error unknown_source_for_offnet_call.
- All calls where the subscriber can't be identified correctly, ends with error unknown_source_for_offnet_call.
- If the call is on net, but the destination did is not assigned to a trunk, the call ends with cant_route_to_local_unallocated_did.
- For off net calls, routes are selected based on the routing plan of the originating did. See [Below](#selecting routes) for the details.
See Hangup Causes.
Every DID is assigned a routing plan. A routing plan is just a sorted collection of route categories. Route categories are basically tags, used to group routes. A route plan usually looks like this
premium - normal - low
Meaning that routes will be searched for, and tried in that particular order (i.e: first, all the available premium routes, then, all the normal ones, and then the ones in the low category).
For every one of those categories, all available routes are selected (just 1 per trunk carrier (since #117), the one that best matches the destination), and then sorted by LCR.