ns-BGP 2.0


ns-BGP is an implementation of BGP-4 in ns-2 network simulator. ns-BGP was developed by porting the BGP-4 model of SSFNet to ns-2. SSFNet is a Java-based simulator for modeling large communication networks. The implementation of the BGP-4 model in the SSFNet network simulation package is called SSF.OS.BGP4. ns-BGP maintains most of the SSF.OS.BGP4 functionality, while incorporating the model into the ns-2 simulation environment.

ns-BGP 2.0 was tested on Redhat Linux 9.0 and ns version 2.27.

Installing ns-2

Download ns-2 version 2.27 from the ns-2 homepage.

In the sections that follow, we assume that ns-allinone was installed in your home directory (~).

Unpack the ns-2 package in your home directory:

> cd ~
> tar xzvf ns-allinone-2.27.tar.gz

This will create an "ns-allinone-2.27" subdirectory with all required files and subdirectories.

If you wish to use ns-BGP in ns-2, you should install ns-BGP at this point. Follow the installation instructions in the next section. Then, run the ns-2 installation script:

> cd ~/ns-allinone-2.27
> ./install

When the installation completes, set the environment variables as instructed by the ns-2 install program.

Installing ns-BGP

Download ns-BGP version 2.0 from the ns-BGP homepage.

Unpack it in the "ns-allinone-2.27" directory:

> cd ~/ns-allinone-2.27
> tar zxvf ns-bgp_2.0.tar.gz

This will:

Apply the ns-BGP patch:

> cd ~/ns-allinone-2.27
> patch -p0 < ns-bgp_2.0.patch

Recompiling ns-2

If you are installing ns-BGP into an existing, already compiled ns-2 installation, then ns-2 needs to be recompiled before the changes take effect:

> cd ~/ns-allinone-2.27/ns-2.27
> ./configure
> ./make clean
> ./make

Using ns-BGP in simulations

In order to use ns-BGP, turn on the BGP option with the node-config command in your OTcl scripts before creating BGP nodes:

$ns node-config -BGP ON
set n0 [$ns node 0:] ;# creates a BGP node with AS number 0 and IP address
set n1 [$ns node 1:]
set n2 [$ns node 1:]
$ns node-config -BGP OFF

Configuring ns-BGP

Each BGP routing agent instance (one per BGP node) can be configured individually from OTcl:

set bgp_agent0 [$n0 get-bgp-agent] ;# gets the BGP routing agent
$bgp_agent0 bgp-id ;# sets the BGP ID
$bgp_agent0 neighbor remote-as 1 ;# establishes a BGP session with the router
$bgp_agent0 neighbor remote-as 2

The available configuration commands for a BGP routing agent are:

$bgp_agent0 bgp-id ;# BGP ID
$bgp_agent0 cluster-id 1000 ;# cluster number for route reflection
$bgp_agent0 connretry_time 120 ;# connection retrial time interval
$bgp_agent0 min_as_orig_time 15 ;# Minimum AS Origination Interval
$bgp_agent0 set-auto-config
$bgp_agent0 neighbor $ipaddress $command $cmd-value

The "set-auto-config" command enables a BGP routing agent to automatically find its potential BGP peers and configure these peers with default parameter values.

The "neighbor" command is used to configure each peer of a BGP routing agent:

$bgp_agent0 neighbor remote-as 1
$bgp_agent0 neighbor route-reflector-client ;# sets this peer as a route reflection client
$bgp_agent0 neighbor hold-time 90 ;# Hold Timer value
$bgp_agent0 neighbor keep-alive-time 30 ;# KeepAlive Timer value
$bgp_agent0 neighbor mrai 30 ;# Minimum Route Advertisement Interval Timer value

Please note that no error checking is performed on the values of these variables. Changing them to strange or disallowed values will probably yield unexpected results. The default values can be found in the "ns-2.27/tcl/lib/ns-default.tcl" file.

In addtion to individual configurations, we can also enable some BGP optional features, such as SSLD (sender-side loop detection) and rate_limit_by_dest (per-destination rate-limiting), in the "ns-2.27/bgp/global.h" file. These settings in the global.h file will affect all BGP routing agents in an ns-BGP simulation.

After configuring the BGP routing agents, three run-time commands can be executed during ns-BGP simulations:

$bgp_agent0 network ;# originates a network prefix
$bgp_agent0 no-network ;# withdraws a network prefix
$bgp_agent0 show-routes ;# displays the content of routing tables

A set of validation test scripts can be found in the "ns-2.27/tcl/bgp/test" directory.

Publications and presentations

Other notes and limitations

Route aggregation has not been tested thoroughly. Support for policy routing, flap damping, and multi-protocol need to be added in the future.


If you have any questions or bug reports pertaining to running ns-BGP in ns-2, please e-mail me at tdfeng at cs.sfu.ca.

Tony Dongliang Feng