#Create a simulator object set ns [new Simulator] #Define a 'finish' procedure proc finish {} { global ns tcp $ns flush-trace exit 0 } #Create five nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 10Mb 5ms DropTail $ns duplex-link $n1 $n2 10Mb 5ms DropTail $ns duplex-link $n2 $n3 10Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 20 $ns queue-limit $n2 $n3 20 #Setup the first TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Setup the second TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Schedule events for the CBR and FTP agents $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run