Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Create a simulator object
- set ns [new Simulator]
- #Define a 'finish' procedure
- proc finish {} {
- global ns nf
- $ns flush-trace
- #Close the NAM trace file
- close $nf
- #Execute NAM on the trace file
- exec nam out.nam &
- exit 0d
- }
- #Open the NAM trace file
- set nf [open out.nam w]
- $ns namtrace-all $nf
- #Create four nodes
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- #Create links between the nodes
- $ns duplex-link $n0 $n1 2Mb 10ms DropTail
- $ns duplex-link $n2 $n1 2Mb 10ms DropTail
- $ns duplex-link $n3 $n1 1.7Mb 20ms DropTail
- $ns duplex-link $n4 $n1 1.7Mb 20ms DropTail
- #Give node position (for NAM)
- $ns duplex-link-op $n0 $n1 orient right-down
- $ns duplex-link-op $n2 $n1 orient left-down
- $ns duplex-link-op $n3 $n1 orient right-up
- $ns duplex-link-op $n4 $n1 orient left-up
- #Call the finish procedure after 5 seconds of simulation time
- $ns at 5.0 "finish"
- #Run the simulation
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement