Advertisement
Guest User

ns2

a guest
Feb 10th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #declaration d'un nv object
  2. set ns [new Simulator]
  3.  
  4. #decl aration des fichiers qui vont contenir le rsx
  5. set ftrace [open trace1.tr w]
  6. set nf [open tp1.nam w]
  7. $ns namtrace-all $nf
  8. #la topologie de rsx, 2 noeuds et 1 lien ful_duplex
  9. set n0 [$ns node]
  10. set n1 [$ns node]
  11. $ns duplex-link $n0 $n1 1Mb 10ms DropTail
  12. #Niveau transport : Agent UDP et Null
  13. set udp [new Agent/UDP]
  14. set null [new Agent/Null]
  15. $ns attach-agent $n0 $udp
  16. $ns attach-agent $n1 $null
  17. $ns connect $udp $null
  18.  
  19. #creation de la source de trafic : CBR
  20.  
  21. set cbr [new Application/Traffic/CBR]
  22. $cbr set packetSize_ 500
  23. $cbr set interval_ 0.005
  24. $cbr attach-agent $udp
  25.  
  26. #procedure qui termine la simulation
  27. proc finish {} {
  28. global ns nf ftrace
  29. $ns flush-trace
  30. close $nf
  31. exec nam tp1.nam &
  32. exit 0
  33. }
  34.  
  35. #faire partir la source CBR et lancer la simution
  36.  
  37. $ns at 0.5 "$cbr start"
  38. $ns at 4.5 "$cbr stop"
  39. $ns at 5.0 "finish"
  40. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement