How to Start Address Protocol Projects Using NS2
To start Address Protocol projects in NS2 (Network Simulator 2), we will need to replicate the addressing schemes and address resolution approaches like ARP – Address Resolution Protocol within a network. Addressing protocols generally function for IP address resolution, address assignment, and interaction in Layer 2 (Data Link Layer) and Layer 3 (Network Layer). Here’s a detailed instruction to get started:
Steps to Start Address Protocol Projects in NS2
- Set Up the NS2 Environment
Make sure that we have installed NS2 and executing on the machine.
- On Ubuntu/Linux:
sudo apt-get update
sudo apt-get install ns2 nam xgraph
- Confirm the installation:
ns
If % prompt is occurs then installation is effectively executed.
- Understand Address Protocol Concepts
- IP Addressing: It replicates the static or dynamic IP address assignment.
- ARP (Address Resolution Protocol):
- Determines the IP addresses for ABR protocol to MAC addresses.
- It functions for interaction through network in Layer 2.
- Address Configuration:
- Static addressing: It is a predefined address.
- Dynamic addressing: This replicated via DHCP protocols.
Focus Areas:
- In wired or wireless network, replicate the behaviour of ARP.
- Allocate an IP addresses to nodes and monitor interaction.
- Examine the packet flow and resolution overhead.
- Design the Network Topology
- Wired Networks: Nodes are associated within a LAN including static addresses.
- Wireless Networks: Mobile nodes in which dynamic address resolution happens.
- Experiment interaction among the nodes to apply UDP/TCP traffic.
- Create a TCL Script
Here’s an instance simulation of Address Protocol (ARP-based) using NS2.
Address Protocol Simulation Script
# Initialize the Simulator
set ns [new Simulator]
set tracefile [open address_trace.tr w]
$ns trace-all $tracefile
set namfile [open address_nam.nam w]
$ns namtrace-all $namfile
# Define Colors for Visualization
$ns color 1 Blue
$ns color 2 Red
# Define Nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
# Define Links (LAN Topology)
$ns duplex-link $n0 $n1 10Mb 5ms DropTail
$ns duplex-link $n1 $n2 10Mb 5ms DropTail
$ns duplex-link $n2 $n3 10Mb 5ms DropTail
# Define Static Addressing
$n0 label “192.168.1.1”
$n1 label “192.168.1.2”
$n2 label “192.168.1.3”
$n3 label “192.168.1.4”
# Add UDP Agents for Traffic
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $n0 $udp
$ns attach-agent $n3 $null
$ns connect $udp $null
# CBR Traffic over UDP
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set rate_ 1Mb
# Simulate ARP Resolution (Optional Debug Messages)
puts “Resolving ARP for $n0 to $n3 communication”
# Schedule Traffic
$ns at 1.0 “$cbr start”
$ns at 5.0 “$cbr stop”
# Finish Procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam address_nam.nam &
exit 0
}
# Run Simulation
$ns at 6.0 “finish”
$ns run
- Run the Simulation
- We will need to store the simulation script like address_protocol_simulation.tcl.
- Then, we can execute the simulation using NS2:
ns address_protocol_simulation.tcl
- Outputs:
- Trace file: address_trace.tr (for analysis).
- NAM file: address_nam.nam which is used for envisioning the network animation.
- Analyze the Results
Key Metrics:
- Packet Delivery Ratio (PDR): Examine the volume of packets that are transmitted vs received:
awk ‘BEGIN {sent=0; recv=0} {if ($1==”s”) sent++; if ($1==”r”) recv++}
END {print “PDR:”, recv/sent*100 “%”}’ address_trace.tr
- ARP Resolution Overhead: Verify for any address resolution packets using trace file.
- End-to-End Delay: Compute the time taken by obtaining send and receive timestamps to apply trace file.
- Extend the Project
- Dynamic Address Resolution:
- Replicate the dynamic address resolution failures and reexecutes.
- Wireless Networks:
- Mimic ARP or address resolution within MANET including the mobile nodes.
- Comparison:
- We can equate the performance of static addressing vs dynamic addressing which is simulated by DHCP.
- Performance Metrics:
- Estimate the performance parameters such as resolution overhead, latency, and delivery ratio.
- Security Integration:
- Integrate the security simulation for ARP spoofing detection.
- Document the Results
It provides comprehensive report or documentation that contains:
- Topology: Network topology includes node arrangement and addressing scheme.
- Simulation Setup: Configure the packet size, bandwidth, and addressing.
- Performance Metrics:
- Measure the performance parameters such as PDR, latency, and overhead.
- Comparative Study: We compare the performance of static vs dynamic addressing.
We had provided detailed information and step-by-step simulation procedure regarding how to start and simulate the Address Protocol Projects using NS2 simulation environment. More relevant insights will be added in another guide.