Advertisement
Shailrshah

I don't know what this is [Part 3]

Apr 3rd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.95 KB | None | 0 0
  1. #Create a simulator object
  2. set ns [new Simulator]
  3. #Define a 'finish' procedure
  4. proc finish {} {
  5.     global ns nf
  6.     $ns flush-trace
  7.     #Close the NAM trace file
  8.     close $nf
  9.     #Execute NAM on the trace file
  10.     exec nam out.nam &
  11.     exit 0d
  12. }
  13. #Open the NAM trace file
  14. set nf [open out.nam w]
  15. $ns namtrace-all $nf
  16.  
  17. #Create four nodes
  18. set n0 [$ns node]
  19. set n1 [$ns node]
  20. set n2 [$ns node]
  21. set n3 [$ns node]
  22. set n4 [$ns node]
  23.  
  24. #Create links between the nodes
  25. $ns duplex-link $n0 $n1 2Mb 10ms DropTail
  26. $ns duplex-link $n2 $n1 2Mb 10ms DropTail
  27. $ns duplex-link $n3 $n1 1.7Mb 20ms DropTail
  28. $ns duplex-link $n4 $n1 1.7Mb 20ms DropTail
  29. #Give node position (for NAM)
  30. $ns duplex-link-op $n0 $n1 orient right-down
  31. $ns duplex-link-op $n2 $n1 orient left-down
  32. $ns duplex-link-op $n3 $n1 orient right-up
  33. $ns duplex-link-op $n4 $n1 orient left-up
  34. #Call the finish procedure after 5 seconds of simulation time
  35. $ns at 5.0 "finish"
  36.  
  37. #Run  the simulation
  38. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement