Advertisement
AnindyaBiswas

NetExp

Aug 3rd, 2022
1,444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.33 KB | None | 0 0
  1. set ns [new Simulator]
  2. $ns rtproto Session
  3. set f [open tes.tr w]
  4. set nf [open tes.nam w]
  5.  
  6. $ns namtrace-all $nf
  7. $ns trace-all $f
  8.  
  9. proc finish { } {
  10.     global ns f
  11.     $ns flush-trace
  12.     close $f
  13.     exec nam tes.nam &
  14.     exit 0
  15. }
  16.  
  17. set n0 [$ns node]
  18. $n0 color "Blue"
  19. set n1 [$ns node]
  20. $n1 color "Green"
  21. set n2 [$ns node]
  22. $n2 color "Yellow"
  23. set n3 [$ns node]
  24.  
  25. $ns color 1 "Green"
  26. $ns color 2 "Red"
  27.  
  28. $ns duplex-link $n0 $n1 10mb 10ms DropTail
  29. $ns duplex-link $n1 $n2 10Mb 10ms DropTail
  30. $ns duplex-link $n2 $n3 10Mb 10ms DropTail
  31. $ns duplex-link $n3 $n0 10Mb 100ms DropTail
  32.  
  33.  
  34. $ns duplex-link-op $n0 $n1 color "Red"
  35. #TCP
  36. set tcp [new Agent/TCP]
  37. $ns attach-agent $n0 $tcp
  38.  
  39.  
  40. #Sink
  41. set sink [new Agent/TCPSink]
  42. $ns attach-agent $n1 $sink
  43.  
  44. $ns connect $tcp $sink
  45. $tcp set fid_ 1
  46. $tcp set packetSize_ 1024
  47.  
  48. #FTP
  49. set ftp [new Application/FTP]
  50. $ftp attach-agent $tcp
  51.  
  52. #dosen't varry
  53. $ftp set rate_ 0.001mb
  54.  
  55.  
  56. #udp
  57. set udp [new Agent/UDP]
  58. $ns attach-agent $n2 $udp
  59.  
  60. #null
  61. set null [new Agent/Null]
  62. $ns attach-agent $n0 $null
  63.  
  64. #connection
  65. $ns connect $udp $null
  66. $udp set fid_ 2
  67.  
  68. #CBR
  69. set cbr [new Application/Traffic/CBR]
  70. $cbr attach-agent $udp
  71. $cbr set packetSize_ 1024
  72. $cbr set rate_ 5mb  
  73.  
  74.  
  75.  
  76. #$ns at 0 "$ftp start"
  77. $ns at 0 "$cbr start"
  78. $ns rtmodel-at 2 down $n1 $n0
  79. $ns at 10 "finish"
  80. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement