This document summarizes the setup of a simulation in NS2 to monitor traffic in a bus topology network with 4 nodes connected by a LAN. It creates nodes, attaches agents and applications to generate and receive traffic, connects the traffic sources and sinks, schedules events such as starting/stopping the traffic generation, and runs the simulation for 5 seconds before finishing.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2K views1 page
Bus Topology
This document summarizes the setup of a simulation in NS2 to monitor traffic in a bus topology network with 4 nodes connected by a LAN. It creates nodes, attaches agents and applications to generate and receive traffic, connects the traffic sources and sinks, schedules events such as starting/stopping the traffic generation, and runs the simulation for 5 seconds before finishing.
set tcp0 [new Agent/TCP] $tcp0 set class_ 1 $ns attach-agent $n1 $tcp0 #Create a TCP Sink agent (a traffic sink) for TCP and attach it to node n3 set sink0 [new Agent/TCPSink] $ns attach-agent $n3 $sink0 #Connect the traffic sources with the traffic sink $ns connect $tcp0 $sink0
# Create a CBR traffic source and attach it to tcp0
set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.01 $cbr0 attach-agent $tcp0
#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time