BGP

The Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the internet. BGP is classified as a path-vector routing protocol, and it makes routing decisions based on paths, network policies, or rule sets configured by a network operator.

Configuration

Following is an example of a BGP configuration with one session.

{
    "interfaces": {
        "network": [
            {
                "interface": "eth1",
                "address": "10.0.1.2/24",
                "gateway": "10.0.1.1"
            }
        ]
    },
    "bgp": [
        {
            "local-address": "10.0.1.2",
            "peer-address": "10.0.1.1",
            "raw-update-file": "test.bgp",
            "local-as": 65001,
            "peer-as": 65001,
            "family": [ "ipv4-unicast",  "ipv6-unicast" ]
        }
    ]
}
{ "bgp": {} }

Attribute

Description

network-interface

BGP local interface (source interface).
Default: first network interface from configuration

local-address

BGP local IPv4/6 address (source address).
Default: network interface address

local-as

BGP local AS.
Default: 65000 Range: 0 - 4294967295

peer-address

Mandatory BGP peer IPv4/6 address.

peer-as

BGP peer AS.
Default: local AS Range: 0 - 4294967295

hold-time

BGP hold-time in seconds.
Default: 90 Range: 0 - 65535

id

BGP identifier.
Default: 1.2.3.4

tos

BGP IP TOS.
Default: 0 Range: 0 - 255

ttl

BGP IP TTL.
Default: 255 Range: 0 - 255

reconnect

Reconnect BGP session automatically.
Default: true

start-traffic

Start global traffic after RAW update finished.
If enabled, the control command traffic-start is automatically
executed as soon as the BGP RAW update has finished.
Default: false

teardown-time

BGP teardown time in seconds.
Default: 5 Range: 0 - 65535

raw-update-file

BGP RAW update file.

family

BGP families to be send in open message.
Default: ipv4/6-unicast, ipv4/6-labeled-unicast
Values:
ipv4-unicast, ipv6-unicast,
ipv4-multicast, ipv6-multicast,
ipv4-labeled-unicast, ipv6-labeled-unicast,
ipv4-vpn-unicast, ipv6-vpn-unicast,
ipv4-vpn-multicast, ipv6-vpn-multicast,
ipv4-flow, ipv6-flow, evpn

extended-nexthop

BGP extended-nexthop families to be send in open message.
Default: None
Values: ipv4-unicast, ipv4-vpn-unicast

BGP Sessions

BGP session are opened with the capabilities for the following address families:

  • IPv4 unicast

  • IPv4 labeled unicast

  • IPv6 unicast

  • IPv6 labeled unicast

This can be changed using family configuration option.

Limitations

BGP authentication is currently not supported but already planned as an enhancement in one of the next releases.

RAW Update Files

The BNG Blaster can inject BGP messages from a pre-compiled RAW update file into the defined sessions. A RAW update file is not more than a pre-compiled binary stream of BGP messages, typically but not limited to update messages.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++++
.
.
.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++++

Those files can be created using the included BGP RAW update generator script bgpupdate or manually using libraries like scapy or converters from PCAP or MRT files.

The configured raw-update-file under the BGP session is loaded during BNG Blaster startup phase and send it as soon as the session is established.

The bgp-raw-update command allows to send further updates during the session lifetime.

$ sudo bngblaster-cli run.sock bgp-raw-update file update1.bgp

This allows loading a full table after the BGP session has started and manually trigger a series of changes using incremental updates files.

All BGP RAW update files are loaded once and can then be used for multiple sessions. Meaning if two or more sessions reference the same file identified by file name, this file is loaded once into memory and used by multiple sessions.

Therefore for incremental updates, it may make sense to pre-load via bgp-raw-update-files configuration.

{
    "bgp": [
        {
            "local-address": "10.0.1.2",
            "peer-address": "10.0.1.1",
            "raw-update-file": "start.bgp",
            "local-as": 65001,
            "peer-as": 65001
        }
    ],
    "bgp-raw-update-files": [
        "update1.bgp",
        "update2.bgp"
    ]
}

Incremental updates not listed here will be loaded dynamically as soon as referenced by the first session.

BGP RAW Update Generator

The BGP RAW update generator is a simple tool to generate BGP RAW update streams for use with the BNG Blaster.

$ bgpupdate --help
usage: bgpupdate [-h] [-a ASN] -n ADDRESS [-N N] -p PREFIX [-P N] [-m LABEL]
                [-M N] [-l LOCAL_PREF] [-f FILE] [-w] [-s STREAMS]
                [--stream-tx-label LABEL] [--stream-tx-inner-label LABEL]
                [--stream-rx-label LABEL] [--stream-rx-label-num N]
                [--stream-threads N] [--stream-pps N]
                [--stream-interface IFACE] [--stream-append] [--end-of-rib]
                [--append] [--pcap FILE] [--log-level {warning,info,debug}]

The BGP RAW update generator is a simple tool to generate BGP RAW update
streams for use with the BNG Blaster.

optional arguments:
-h, --help            show this help message and exit
-a ASN, --asn ASN     autonomous system number
-n ADDRESS, --next-hop-base ADDRESS
                        next-hop base address (IPv4 or IPv6)
-N N, --next-hop-num N
                        next-hop count
-p PREFIX, --prefix-base PREFIX
                        prefix base network (IPv4 or IPv6)
-P N, --prefix-num N  prefix count
-m LABEL, --label-base LABEL
                        label base
-M N, --label-num N   label count
-l LOCAL_PREF, --local-pref LOCAL_PREF
                        local preference
-f FILE, --file FILE  output file
-w, --withdraw        withdraw prefixes
-s STREAMS, --streams STREAMS
                        generate BNG Blaster traffic stream file
--stream-tx-label LABEL
                        stream TX outer label
--stream-tx-inner-label LABEL
                        stream TX inner label
--stream-rx-label LABEL
                        stream RX label
--stream-rx-label-num N
                        stream RX label count
--stream-threads N    stream TX threads
--stream-pps N        stream packets per seconds
--stream-interface IFACE
                        stream interface
--stream-append       append to stream file if exist
--end-of-rib          add end-of-rib message
--append              append to file if exist
--pcap FILE           write BGP updates to PCAP file
--log-level {warning,info,debug}
                        logging Level

The python BGP RAW update generator is a python script that uses scapy to build BGP messages. Therefore this tool can be easily modified, extend or used as a blueprint for your own tools to generate valid BGP update streams.

The following example shows how to generate a BGP update stream with IPv4 and labeled IPv6 prefixes (6PE).

  • 100000 x IPv4 prefixes over 1000 next-hops

  • 50000 x IPv6 prefixes over 1000 next-hops with 1000 different labels (label per next-hop)

  • 50000 x IPv6 prefixes over 1000 next-hops with label 2

bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -p 10.1.0.0/24 -P 100000
bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -m 20001 -M 1000 -p fc66:1::/48 -P 50000 --append
bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -m 2 -p fc66:2::/48 -P 50000 --append --end-of-rib

Per default, the file is replaced but the option –append allows it to append to an existing file. The last update to a file should include the option –end-of-rib (optional).

The option –streams <file> (-s) automatically generates corresponding traffic streams for all prefixes. Per default, this file is replaced but the option –stream-append allows appending to an existing file.

bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -p 10.1.0.0/24 -P 100000 -s streams.json
bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -m 20001 -M 1000 -p fc66:1::/48 -P 50000 --append -s streams.json --stream-append
bgpupdate -f test.bgp -a 65001 -l 100 -n 10.0.0.1 -N 1000 -m 2 -p fc66:2::/48 -P 50000 --append --end-of-rib -s streams.json --stream-append

There are several options supported to further define the traffic streams like PPS and expected RX labels.