How to Start Extended Bus Topology Projects Using NS2
To start an Extended Bus Topology project using NS2 (Network Simulator 2) which encompasses to replicate a network in which nodes are linked to a general backbone or bus topology. The bus performs as the shared interaction medium, and several devices are associated by backbone in an extended bus topology. This is an extension of the traditional bus topology in which network can be measured by integrating additional nodes.
We can follow these steps that helps you on how to configure and replicate an Extended Bus Topology project in NS2:
Steps to Start Extended Bus Topology Project in NS2
- Understand Extended Bus Topology
- Extended Bus Topology:
- It includes a single backbone (bus) to which numerous nodes like computers, devices, and so on that are linked in a linear fashion.
- Every device can interact via general backbone, however dynamically nodes can be inserted or extended.
- Applications:
- Small-scale networks with limited interaction requirements.
- LANs (Local Area Networks).
- Simple IoT networks.
- Key Features:
- Scalable by integrating additional nodes.
- Simple and cost-effective.
- Single point of failure as bus fails, the entire network is impacted.
- Set Up NS2
- Install NS2:
- We should install and confirm NS2 functionality:
ns example.tcl
- Tools for Analysis:
- NAM (Network Animator) to envision the topology.
- Trace Analysis Tools which are designed for measuring the performance parameters such as latency, throughput, and packet delivery ratio (PDR).
- Plan the Extended Bus Topology
- Network Design:
- Every node is associated within a single line along the bus or backbone.
- The bus can be prolonged by inserting additional nodes.
- The interaction among the nodes will traverse the bus, and every single node will be linked to the backbone.
- Metrics to Analyze:
- Throughput.
- Latency.
- Packet Delivery Ratio (PDR).
- Write the Simulation Script
Step 4.1: Create the TCL Script
We will want to store the tcl simulation script like extended_bus_topology.tcl with NS2.
Step 4.2: Initialize the Simulator
Configure the simulator:
# Initialize the simulator
set ns [new Simulator]
set tracefile [open trace.tr w]
$ns trace-all $tracefile
set namfile [open extended_bus_topology.nam w]
$ns namtrace-all $namfile
Step 4.3: Create Nodes
We can describe the nodes that are linked to the bus:
# Number of nodes
set val(nn) 5
# Create nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
}
# Set node positions (for visualization)
set x_pos 50
foreach node $node_ {
$node set X_ $x_pos
$node set Y_ 250
$node set Z_ 0.0
incr x_pos 100
}
Step 4.4: Configure Links
- Bus Backbone Links: Nodes are associated with a bus backbone.
# Connect nodes to form the bus
for {set i 0} {$i < [expr $val(nn) – 1]} {incr i} {
$ns duplex-link $node_($i) $node_([expr $i + 1]) 1Mb 10ms DropTail
}
Step 4.5: Configure Traffic
Configure traffic flows among the nodes:
# Traffic from node_0 to node_4
set udp1 [new Agent/UDP]
$ns attach-agent $node_(0) $udp1
set null1 [new Agent/Null]
$ns attach-agent $node_(4) $null1
$ns connect $udp1 $null1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 50kb
$ns at 1.0 “$cbr1 start”
# Traffic from node_1 to node_3
set udp2 [new Agent/UDP]
$ns attach-agent $node_(1) $udp2
set null2 [new Agent/Null]
$ns attach-agent $node_(3) $null2
$ns connect $udp2 $null2
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 512
$cbr2 set rate_ 50kb
$ns at 2.0 “$cbr2 start”
Step 4.6: Enable Routing Protocol
We can utilise a basic routing protocol such as AODV for ad-hoc networking within interaction:
# Enable AODV Routing Protocol
$ns rtproto AODV
Step 4.7: Finalize the Script
Integrate the simulation end conditions to end the simulation script:
# End simulation after a certain time
$ns at 10.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam extended_bus_topology.nam &
exit 0
}
$ns run
- Run the Simulation
- We want to store the tcl simulation script like extended_bus_topology.tcl.
- Then execute it using NS2:
ns extended_bus_topology.tcl
- Go to NAM for envisioning the topology:
nam extended_bus_topology.nam
- Analyze Results
- Trace File Analysis:
- Estimate the performance parameters such as throughput, latency, and packet delivery ratio (PDR) to utilise trace file as trace.tr.
- Example AWK script for throughput:
awk ‘{if ($1 == “r” && $4 == “udp”) sum += $8} END {print “Throughput: “, sum}’
- Metrics:
- Packet Delivery Ratio (PDR): Assess the reliability of data distribution.
- Latency: Measure the delay within data transmission.
- Throughput: Compute the effectiveness of data transmission.
- Expand the Simulation
- Increase Network Size:
- We will integrate additional nodes to the bus and then monitor the performance of network.
- Simulate Link Failures:
- Experiment the network resilience through inactivating a link:
$ns at 5.0 “$ns link-fail $node_(2) $node_(3)”
- Vary Traffic Patterns:
- Integrate additional traffic flows or diverse traffic rates.
- Experiment with Routing Protocols:
- We need to equate the performance with other routing protocols like DSR, DSDV, or OLSR.
- Document the Project
- Objective: Define the project’s goals like configuration of the extended bus topology.
- Setup: It has node connections, traffic models, and routing protocols.
- Results: Provides crucial performance parameters like throughput, latency, and packet delivery ratio.
- Conclusions: Sum up performance and scalability insights.
We had gathered the information, you can explore Extended Bus Topology which were simulated and evaluated in the NS2 environment. If needed, we will deliver the detailed structured for entire execution process in another manual.