The document outlines a simulation setup using a network simulator (NS) with six nodes and various TCP and UDP connections. It defines the network topology, including link characteristics and queue limits, and schedules events for FTP and CBR traffic. The simulation is set to run for a total of 5.5 seconds, after which it will execute a finish procedure to close trace files and visualize results in NAM.
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)
14 views3 pages
Scenario4a TCL
The document outlines a simulation setup using a network simulator (NS) with six nodes and various TCP and UDP connections. It defines the network topology, including link characteristics and queue limits, and schedules events for FTP and CBR traffic. The simulation is set to run for a total of 5.5 seconds, after which it will execute a finish procedure to close trace files and visualize results in NAM.
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
You are on page 1/ 3
#Create a simulator object
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 blue $ns color 2 red $ns color 3 green $ns color 4 black
#Open the NAM trace file
set nf [open scenario4a.nam w] $ns namtrace-all $nf
#open the trace file
set tf [open scenario4a.tr w] $ns trace-all $tf
#Define a 'finish' procedure
proc finish {} { global ns nf tf $ns flush-trace #Close the trace file close $tf #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam scenario4a.nam & exit 0 }
#Create six nodes
for {set i 0} {$i < 6} {incr i} { set n$i [$ns node] }
set tcp1 [new Agent/TCP] $tcp1 set class_ 2 $ns attach-agent $n0 $tcp1 set sink1 [new Agent/TCPSink] $ns attach-agent $n5 $sink1 $ns connect $tcp1 $sink1 $tcp1 set fid_ 2
#Setup a TCP connection from Node1 to Node5
set tcp2 [new Agent/TCP] $tcp2 set class_ 2 $ns attach-agent $n1 $tcp2 set sink2 [new Agent/TCPSink] $ns attach-agent $n5 $sink2 $ns connect $tcp2 $sink2 $tcp2 set fid_ 1
#Setup a FTP over TCP connection from Node0 to Node5
set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 $ftp1 set type_ FTP $ftp1 set packet_size_ 1000
#Setup a FTP over TCP connection from Node1 to Node5
set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 $ftp2 set type_ FTP $ftp2 set packet_size_ 1000
#Setup a UDP connection from Node2 to Node5
set udp1 [new Agent/UDP] $ns attach-agent $n2 $udp1 set null1 [new Agent/Null] $ns attach-agent $n5 $null1 $ns connect $udp1 $null1 $udp1 set fid_ 3
#Setup a UDP connection from Node3 to Node5
set udp2 [new Agent/UDP] $ns attach-agent $n3 $udp2 set null2 [new Agent/Null] $ns attach-agent $n5 $null2 $ns connect $udp2 $null2 $udp2 set fid_ 4
#Setup a CBR over UDP connection from Node2 to Node5
set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 $cbr1 set type_ CBR $cbr1 set packet_size_ 1000 $cbr1 set rate_ 1mb $cbr1 set random_ false
#Setup a CBR over UDP connection from Node3 to Node5
set cbr2 [new Application/Traffic/CBR] $cbr2 attach-agent $udp2 $cbr2 set type_ CBR $cbr2 set packet_size_ 1000 $cbr2 set rate_ 1mb $cbr2 set random_ false
#Schedule events for the CBR and FTP agents
$ns at 0.1 "$ftp1 start" $ns at 0.2 "$cbr2 start" $ns at 1.0 "$ftp2 start" $ns at 1.0 "$cbr1 start" $ns at 4.5 "$ftp2 stop" $ns at 5.0 "$ftp1 stop" $ns at 5.0 "$cbr1 stop" $ns at 5.0 "$cbr2 stop"
#Detach tcp and sink agents (not really necessary)