How to Start Tutorials Point Routing Projects Using NS2
To start routing projects within NS2 to utilise resources or guidance of TutorialsPoint, we follow these thorough techniques to get started:
Steps to Start TutorialsPoint Routing Projects in NS2
Step 1: Understand NS2 Basics
- What is NS2?
- NS2 is a detached event simulator which frequently utilised in network simulation projects with routing protocols.
- Learn NS2 Syntax:
- We can get more knowledge about the Tcl scripting language which is utilised for NS2.
- Focus on fundamental concepts like nodes, links, agents, traffic generation, and topology creation.
- TutorialsPoint Reference:
- TutorialsPoint and other online tutorials are frequently offers more in-depth samples to know the fundamentals of NS2.
- Make use of routing protocol examples that are offered in AODV, DSR.
Step 2: Install NS2
- Installation Steps:
- We can download and install NS2 on the system.
- Install NS2 including all essential dependencies such as Tcl, OTcl, NAM.
- Confirm the installation by executing:
ns -version
- Explore Example Scripts:
- Search for samples that are provided in the ns-allinone-2.x/examples/ directory.
- It is initially begin basic protocols such as AODV or DSDV to advance.
Step 3: Choose a Routing Protocol
Routing projects need to include executing, altering or comparing protocols. Following is a general routing protocols:
- Static Routing:
- It is simple routing in which routes are set up manually.
- Dynamic Routing:
- AODV (Ad Hoc On-Demand Distance Vector):
- Reactive protocol; routes are made on request.
- DSDV (Destination-Sequenced Distance-Vector):
- It is a proactive protocol that sustains routing tables including periodic updates.
- DSR (Dynamic Source Routing):
- Reactive protocol, it utilises for source routing.
- AODV (Ad Hoc On-Demand Distance Vector):
- Custom Routing Protocols:
- Execute the individual algorithm like energy-aware routing or hierarchical protocols such as LEACH.
Step 4: Create a Basic Network Topology
- Make a simple network topology including nodes and links using NS2 script:
set ns [new Simulator]
# Define nodes
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# Create links
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
# Define traffic
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set sink [new Agent/Null]
$ns attach-agent $n3 $sink
$ns connect $udp $sink
# Start traffic
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set interval_ 0.05
$ns at 1.0 “$cbr start”
# Run simulation
$ns run
- We need to save the script like basic_routing.tcl and execute the below command:
ns basic_routing.tcl
Step 5: Simulate a Built-In Routing Protocol
- AODV Example:
- In an ad-hoc network, we can utilise the AODV protocol for dynamic routing.
set ns [new Simulator]
# Define nodes
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# Define links
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
# Use AODV protocol
$ns node-config -adhocRouting AODV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround
# Create nodes with AODV
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# Define traffic
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set sink [new Agent/Null]
$ns attach-agent $n3 $sink
$ns connect $udp $sink
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set interval_ 0.05
$ns at 1.0 “$cbr start”
$ns run
- We can execute the script and then examine the outcomes of it.
Step 6: Create a Custom Routing Protocol
- Modify an Existing Protocol:
- Alter or prolong an existing protocol such as AODV within NS2’s C++ codebase.
- Set the protocol files using ns-2.x/aodv/.
- Write a New Protocol:
- Make a new routing agent by means of receiving from the Agent class.
- Execute the logic for packet forwarding, maintenance and route discovery.
- Compile the New Protocol:
- We need to integrate the protocol to the Makefile.
- Recompile NS2:
make clean && make
Step 7: Simulate and Analyze
- Execute the Tcl script:
ns your_script.tcl
- Envision the behaviour of network with the support of NAM (Network Animator).
- Examine the trace file for performance indicators such as:
- Throughput
- End-to-end delay
- Packet delivery ratio
Step 8: Extend the Project
- Enhance Routing Logic:
- We can execute the QoS-based routing, energy-aware routing, or multi-path routing.
- Performance Comparison:
- Equate the performance of existing protocols such as AODV, DSR, and DSDV.
- Test Scalability:
- Replicate a network including additional nodes and higher traffic to test scalability.
This technique will guide you through the simulation and analyse of TutorialsPoint Routing Projects using NS2 tool and it contains the details regarding the how to setup the build-in protocols; design the network topology and how to execute the process to perform the results with samples snippets. We intend to expand on how this project is performed in other simulation settings.