To simulate Simple Network Management Protocol (SNMP), which is primarily a protocol utilized for network management instead of a routing protocol. It enables the observing and management of network devices (like routers, switches, and computers) by accumulating and organizing data regarding network performance. Replicating SNMP within NS2 can be done by designing the interaction among SNMP agents (residing on network devices) and an SNMP manager, which queries or receives updates regarding network conditions.
Even though NS2 is commonly utilised for replicating network layer protocols, we can be mimicked SNMP-like behaviour by executing mechanisms for observing network performance metrics, transmitting updates (traps), and querying information, while NS2 doesn’t have a native execution for SNMP.
Here’s how we can replicate a Simple Network Management Protocol (SNMP) project using NS2:
Steps to Simulate SNMP Projects Using NS2
- Install NS2
Make sure we have NS2 installed. We can download it from here.
- Understanding SNMP Basics
- SNMP Manager: Centralized system, which observes and handles network devices. It transmits queries to SNMP agents and receives traps (alerts) from them.
- SNMP Agents: Installed on network devices that responsible for accumulating local device performance parameters and reacting to SNMP manager queries.
In NS2, we will be replicated an SNMP Manager, which queries SNMP agents (devices/nodes) to recover statistics such as bandwidth usage, packet loss, and delay. These nodes will perform as routers or hosts on the network.
- TCL Script Structure for SNMP Simulation
Here’s an instance of how we mimic SNMP-like behaviour in NS2 utilizing custom scripts to model querying, observing, and reporting.
Example TCL Script for Simulating SNMP
# Create a simulator object
set ns [new Simulator]
# Open files for tracing and NAM visualization
set tracefile [open snmp_simulation.tr w]
$ns trace-all $tracefile
set namfile [open snmp_simulation.nam w]
$ns namtrace-all $namfile
# Define network topology
set topo [new Topography]
$topo load_flatgrid 1000 1000
# Define link parameters: bandwidth, delay, and queue type
set bw 10Mb
set delay 10ms
set queue DropTail
# Create nodes: one SNMP manager and multiple SNMP agents (nodes)
set manager [$ns node] ;# SNMP Manager node
set agent0 [$ns node] ;# SNMP Agent 1
set agent1 [$ns node] ;# SNMP Agent 2
set agent2 [$ns node] ;# SNMP Agent 3
# Create links between nodes
$ns duplex-link $manager $agent0 $bw $delay $queue
$ns duplex-link $manager $agent1 $bw $delay $queue
$ns duplex-link $manager $agent2 $bw $delay $queue
# Define SNMP behavior: query agents for performance metrics
proc query_agents {manager agents time_interval} {
foreach agent $agents {
global ns
puts “SNMP Manager querying $agent at $time_interval seconds”
$ns at $time_interval “puts \”Manager received response from $agent at time [clock seconds]\””
}
}
# Query agents at regular intervals
set agents [list $agent0 $agent1 $agent2]
for {set time 1.0} {$time <= 15.0} {set time [expr $time + 5.0]} {
query_agents $manager $agents $time
}
# Create TCP agents and generate traffic to simulate network activity
set tcp0 [new Agent/TCP]
$ns attach-agent $agent0 $tcp0
set sink [new Agent/TCPSink]
$ns attach-agent $agent2 $sink
# Connect TCP agent and sink
$ns connect $tcp0 $sink
# Start FTP traffic over TCP to simulate network load
set ftp [new Application/FTP]
$ftp attach-agent $tcp0
$ns at 2.0 “$ftp start”
$ns at 10.0 “$ftp stop”
# End simulation after 20 seconds
$ns at 20.0 “finish”
# Define finish procedure to close trace and NAM files
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam snmp_simulation.nam &
exit 0
}
# Run the simulation
$ns run
- Explanation of the Script
- Simulator Setup: Makes the simulator object and opens trace and NAM files for recording simulation events.
- Nodes Creation: Four nodes are made — one performing as the SNMP Manager and another one performing as SNMP Agents. Links are made among them with bandwidth and delay parameters.
- SNMP-like Behavior: The query_agents procedure replicates the manager querying each agent occasionally (every 5 seconds) for network statistics (like packet loss, delay, etc.). This replicates how an SNMP manager queries agents for performance data.
- Traffic Generation: FTP traffic is made among agent0 and agent2 to replicate network activity that could be observed by SNMP.
- Simulation End: The simulation runs for 20 seconds, with FTP traffic beginning at 2 seconds and ending at 10 seconds.
- Running the Simulation
When we have written the TCL script (e.g., snmp_simulation.tcl) then we run it using NS2 with the below command:
ns snmp_simulation.tcl
It will make trace files and create a NAM visualization file for the simulation.
- Analyzing the Results
- NAM Visualization: Open the .nam file within NAM (Network Animator) to envision the network, packet transmission, and SNMP-like querying behaviour.
nam snmp_simulation.nam
- Trace File Analysis: Investigate the .tr trace file to monitor packet transmission, react to SNMP-like queries, and overall network performance.
- Extending the Simulation
To make a more realistic simulation of SNMP behaviour, we can prolong the simulation by:
- Performance Monitoring: Log actual performance parameters such as bandwidth usage, packet loss, and latency. We can have SNMP agents replicate transmitting this data to the manager.
- SNMP Traps: Replicate SNMP traps by having the agents transmit alerts to the manager once particular thresholds are crossed (e.g., packet loss exceeds a certain level).
- Scalability: Maximize the amount of agents to replicate a large-scale network under SNMP management.
- QoS Monitoring: Mimic how SNMP could observe QoS (Quality of Service) metrics, dynamically modifying resources according to the network performance.
Example of Extending SNMP Queries with Metrics
To replicate the manager receiving certain parameters then we can change the query_agents procedure to query and return specific metrics:
proc query_agents_with_metrics {manager agents time_interval} {
foreach agent $agents {
global ns
set bandwidth_usage [expr int(rand()*100)]
set packet_loss [expr int(rand()*10)]
puts “SNMP Manager querying $agent at $time_interval seconds”
$ns at $time_interval “puts \”Manager received from $agent: Bandwidth=$bandwidth_usage Mbps, Packet Loss=$packet_loss% at time [clock seconds]\””
}
}
It could replicate querying SNMP agents for real-time bandwidth and packet loss statistics.
Here, we had given typical techniques with sample snippets to simulate and examine the Simple Network Management Protocol projects through the virtual environment NS2. According to your requirements, we will be provided more informations on this subject.
For expert assistance with Simple Network Management Protocol projects using the ns2 tool, connect with phdprime.com. We guarantee comprehensive project support.