Advertisement
neeyoo11

5Node Star Topology

May 25th, 2022
611
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set ns [new Simulator]
  2. set tracefile [open lab2.tr w]
  3. $ns trace-all $tracefile
  4. set namfile [open lab2.nam w]
  5. $ns namtrace-all $namfile
  6. set n0[$ns node]
  7. set n1[$ns node]
  8. set n2[$ns node]
  9. set n3[$ns node]
  10. set n4[$ns node]
  11. $ns duplex-link $n0 $n4 1Mb 10ms DropTail
  12. $ns duplex-link $n1 $n4 1Mb 10ms DropTail
  13. $ns duplex-link $n4 $n3 1Mb 10ms DropTail
  14. $ns duplex-link $n4 $n2 1Mb 10ms DropTail
  15. set tcp [new Agent/TCP]
  16. $ns attach-agent $n0 $tcp
  17. set sink [new Agent/TCPSink]
  18. $ns attach-agent $n3 $sink
  19. $ns connect $tcp $sink
  20. set ftp [new Application/FTP]
  21. $ftp attach-agent $tcp
  22. set udp [new Agent/UDP]
  23. $ns atatch-agent $1 $udp
  24. set null [new Agent/NULL]
  25. $ns attach-agent $2 $null
  26. $ns connect $udp $null
  27. set cbr [new Application/Traffic/CBR]
  28. $cbr set packetSize_ 500
  29. $cbr set interval_ 0.005
  30. $cbr attach-agent $udp
  31. $ns at 0.0 "$cbr start"
  32. $ns at 0.0 "$ftp start"
  33. $ns at 9.0 "$cbr stop"
  34. $ns at 9.0 "$ftp stop"
  35. proc finish {} {
  36. global ns namfile tracefile
  37. $ns flush-trace
  38. close $tracefile
  39. close $namfile
  40. exec nam lab1.nam &
  41. exit 0
  42. }
  43. $ns at 10.0 "finish"
  44. $ns run
Advertisement
RAW Paste Data Copied
Advertisement