ns-BGP 2.0 for ns-2.34


ns-BGP 2.0, which was originally developed in 2003 for ns-2.27 (ns-BGP), is an implementation of BGP-4 in ns-2 network simulator. The initial implementation 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 in the model into the ns-2 simulation environment. Later, ns-BGP was integrated in ns-2.33 (ns-BGP 2.0 for ns-2.33) in 2008. Recently, it has been integrated in the current version of ns-2 (ns-2.34).

ns-2.34-BGP was tested on Xubuntu 9.4 and ns version 2.34.

Installing ns-2

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

In the sections that follow, it is assumed that ns-allinone can be installed in your home directory.

Unpack the ns-2 package in your home directory:

> gzip -dc ns-allinone-2.34.tar.gz | ( cd ; tar xvf - )

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

Follow the installation instructions in the next section. Then, run the ns-2 installation script:

> cd ~/ns-allinone-2.34 ; ./install
> cd ns-2.34 ; ./validate

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

Installing ns-BGP

Download ns-BGP version 2.0 for ns-2.34 here.

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

> gzip -dc ns-2.34-bgp_2.0.tgz | ( cd ~/ns-allinone-2.34 ; tar xvf - )

This will:

Apply the ns-BGP patch:

> cd ~/ns-allinone-2.34 ; patch -p0 < ns-2.34-bgp_2.0_patch

Recompiling ns-2

ns-2 then needs to be recompiled before the changes take effect:

> cd ~/ns-allinone-2.34/ns-2.34
> ./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.34/tcl/lib/ns-default.tcl" file.

In addition 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.34/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.34/tcl/bgp/test" directory.

Publications and presentations

Other notes and limitations

The ns-2.34-BGP has the same limitations as the ns-2.33-BGP implemention. Specifically, there is a core dump while running reflection2.tcl test case. Support for route flap damping, adaptive minimal route advertisement interval (MRAI) timer, and policy routing need to be added in the future.


If you have any questions relating to running ns-BGP in ns-2.34, please e-mail me at mrs16 at sfu.ca.

Reza Sahraei