How to Implement On Exterior Gateway Protocol in NS2

To implement an Exterior Gateway Protocol (EGP) like BGP (Border Gateway Protocol) within NS2 (Network Simulator 2) that is challenging since NS2 was mainly created for simulating old network protocols such as TCP/IP and wireless networks, and it absences built-in support for the furthered routing protocols such as BGP. But, we can still mimic an EGP setup by either tailoring NS2 via code extensions or by using a further proper network simulation tool such as NS3 or specialized BGP simulators.

If we need to investigate simple concepts or simulate too basic structure of the exterior gateway behaviour. We can attempt to mimic the interaction among various autonomous systems (ASes) by manually set up routes and using static routing or by expanding NS2 with custom scripts. Below is a procedure to executing a simple concept of exterior gateway routing in NS2:

Step-by-Step Guide to Implement Basic EGP Concepts in NS2

Step 1: Understand EGP and BGP Concepts

  • EGP (Exterior Gateway Protocol) is used to interchange the routing data among the various autonomous systems (ASes) on the internet. BGP is the most generally used the EGP.
  • BGP manages routing among the ASes by exchanging route information and choosing on the best path according to the policies, prefixes, and path attributes.

Step 2: Set Up NS2 and Create a Simulation Script

  1. Install NS2: Make sure that NS2 is installed on the computer then we can download it from the NS2 webpage and follow the installation instructions particular to the operating system.
  2. Create a New Tcl Script: Open a text editor and make a new file, for sample, egp_basic_example.tcl.
  3. Set up the Simulation Environment: Describe the simulator, set up the network topology, and configure the metrics exact to the simulation. It has contains making several autonomous systems (ASes) and manually setup the routes among them.

Example: Simulating Basic EGP Concepts in NS2

# Create a simulator object

set ns [new Simulator]

# Define options for the simulation

set val(chan)   Channel/WirelessChannel    ;# Channel type

set val(prop)   Propagation/TwoRayGround   ;# Propagation model

set val(netif)  Phy/WirelessPhy            ;# Network interface type

set val(mac)    Mac/802_11                 ;# MAC type

set val(ifq)    Queue/DropTail/PriQueue    ;# Interface Queue type

set val(ll)     LL                         ;# Link layer type

set val(ant)    Antenna/OmniAntenna        ;# Antenna type

set val(ifqlen) 50                         ;# Max packet in ifq

set val(nn)     6                          ;# Number of nodes (representing different ASes)

set val(stop)   10.0                       ;# Simulation time

set val(x)      1000                       ;# X dimension of topography

set val(y)      1000                       ;# Y dimension of topography

# Initialize the topology object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# Create the God object

create-god $val(nn)

# Configure the nodes

$ns node-config -llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace ON \

-movementTrace ON

# Create nodes representing ASes

for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0

}

# Manually configure node positions to represent different ASes

$node_(0) set X_ 100.0; $node_(0) set Y_ 100.0

$node_(1) set X_ 300.0; $node_(1) set Y_ 100.0

$node_(2) set X_ 500.0; $node_(2) set Y_ 100.0

$node_(3) set X_ 100.0; $node_(3) set Y_ 300.0

$node_(4) set X_ 300.0; $node_(4) set Y_ 300.0

$node_(5) set X_ 500.0; $node_(5) set Y_ 300.0

# Establish links between nodes to simulate inter-AS connections

$ns duplex-link $node_(0) $node_(1) 1Mb 10ms DropTail

$ns duplex-link $node_(1) $node_(2) 1Mb 10ms DropTail

$ns duplex-link $node_(3) $node_(4) 1Mb 10ms DropTail

$ns duplex-link $node_(4) $node_(5) 1Mb 10ms DropTail

$ns duplex-link $node_(1) $node_(4) 1Mb 20ms DropTail  ;# Link between ASes

$ns duplex-link $node_(2) $node_(5) 1Mb 20ms DropTail  ;# Link between ASes

# Manually assign IP addresses and simulate static routing between ASes

$node_(0) set-address “10.1.1.1/24”

$node_(1) set-address “10.1.2.1/24”

$node_(2) set-address “10.1.3.1/24”

$node_(3) set-address “10.2.1.1/24”

$node_(4) set-address “10.2.2.1/24”

$node_(5) set-address “10.2.3.1/24”

# Add static routes to simulate basic EGP behavior

$node_(1) add-route “10.2.0.0/16” $node_(4)

$node_(4) add-route “10.1.0.0/16” $node_(1)

# Setup traffic sources between ASes to simulate EGP behavior

set udp [new Agent/UDP]

$ns attach-agent $node_(0) $udp

set null [new Agent/Null]

$ns attach-agent $node_(5) $null

$ns connect $udp $null

# Setup CBR (Constant Bit Rate) application over UDP

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr start

# Setup simulation end

$ns at $val(stop) “stop”

$ns at $val(stop) “$ns nam-end-wireless $val(stop)”

$ns at $val(stop) “exit 0”

proc stop {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

}

# Run the simulation

$ns run

Step 3: Run the Simulation

  1. We can save the Tcl script such as egp_basic_example.tcl.
  2. Open a terminal and navigate to the directory in which we saved the Tcl script.
  3. Run the simulation using the given command:

ns egp_basic_example.tcl

The above command will generate the trace files, optionally a network animation file if permitted in the script.

Step 4: Analyse the Results

We can use the trace files and network animator (NAM) to assess the performance of the replicated EGP-like behaviour, concentrating on the inter-AS routing, delay, and packet delivery.

Step 5: Visualize the Results (Optional)

If we have allowed the network animator (NAM) in the script then we can visualize the simulation:

nam egp_basic_example.nam

It will open the NAM window in which we can observe the network topology and the behaviour of the replicated exterior gateway scenario when the simulation.

Additional Considerations

  • Static Routing: In the nonappearance of furthered BGP or OSPF support, this static routing can mimic simple EGP behaviour. However it absences the dynamic nature of the actual EGPs.
  • Performance Metrics: Compute and compare how the network performs under various topologies and traffic conditions.
  • Extension of NS2: Executing a full-fledged BGP simulation in the simulator NS2 that need the extensive customization of the NS2 source code, especially in C++. It is not an insignificant task and it may be better suitable for the simulators such as NS3 or a dedicated BGP simulator.

Over this explanation we learned and get knowledge regarding the Exterior Gateway protocol using the ns2 environment through the above procedure. We can offer more details about this topic as required.

Experience a comprehensive performance analysis tailored just for you. We deliver outstanding results for Exterior Gateway Protocol within NS2 implementation, accompanied by innovative research concepts. Our team specializes in BGP simulators customized to meet the specific requirements of your project.