---
title: "Routing Policy"
geekdocDescription: "Description of the network routing policy"
weight: 40
---
With a global network and multiple peers, the burble.dn42 network typically has many alternative route paths for reaching a particular destination. The routing policy aims to keep route selection sane, and avoid sending traffic outside of a region where possible. 

## Policy Objectives

1. Direct routes for prefixes belonging to a peer should be given the highest priority.  
    - So that traffic to peer networks is routed over the burble.dn42 network directly to the peer and not via an external 3rd party
3. Routes to the anycast prefixes should be prioritised through stable, low latency peers.  
    - To ensure stability within the network and provide good routes for well known destinations (e.g. DNS and the DN42 wiki)
5. Where prefixes are tagged with a DN42 region, they should be routed locally or within the burble.dn42 network.     
    - To avoid sending traffic across regions when this could have been avoided.  
    - The AS path length is also increased between regions to pursuade external routers to also prefer local hosts.
7. Prioritise by shortest path, then lowest latency

## Policy Implementation

### bgp local_pref

The local_pref for routes is set on entry, and then propogated across the whole network. This forces the
network to prefer routes that, where possible, send traffic through the burble.dn42 network to a local peer,
rather than sending cross regional traffic through external peers (aka
[Cold Potato Routing](https://en.wikipedia.org/wiki/Hot-potato_and_cold-potato_routing)).

|Local Pref &nbsp; | Route Class |
|:---|:---|
| 3000 &nbsp; | burble.dn42 dynamic / anycast routes |
| 2000 &nbsp; | burble.dn42 internal networks |
| 1000 &nbsp; | Peer networks (AS path len = 1) |
| 500 &nbsp; | Route received in same DN42 region as it originated |
| 100 &nbsp; | Default |

### bgp med

The med attribute is used to implement a latency based metric across the network. Scripts are used
to gather the latency between nodes (using ping) and this is then incorporated in to the ansible
scripting that generates the peer configuration for the internal mesh. The peer configuration
sets the med to be the latency in ms between nodes (in milliseconds * 10). A penalty of 500 is added
for each hop to encourange direct routing between nodes.

```
med = (latency between nodes in ms * 10) + (500 per hop)
```

The med metric is exported to external peers to help them decide how to route traffic to the burble.dn42
network. 

## collector.dn42

The global route collector is treated as a special case and does not follow the normal routing policy.
The objective of the collector policy is to steer traffic directly to fr-rbx1 and reduce transit of GRC
traffic over the burble.dn42 network. This is aggressively implemented for certain low bandwidth nodes
to prevent any GRC traffic going through these nodes.

To accomplish this, each node announces the GRC prefix in to DN42 with different levels of path prepending
depending on the available bandwidth of that node. Some nodes with low bandwidth allocations do not
announce the GRC prefix at all.

| Node capability | Action Taken |
|:---|:---|
| fr-rbx1 | Prefix announced without any prepending |
| Other nodes with unlimited BW allowance | ASN prepended once |
| Nodes with BW limits | ASN prepended twice |
| Nodes with low BW limits | GRC prefix not announced |

As well as the external traffic engineering, the internal mesh policy also prevents transit of GRC
traffic via low bandwidth nodes.

