22. Example 1 (contd.) – Basic tracing #Create a simulator object set ns [new Simulator] #Open the nam trace file set nf [open out.nam w] # Start tracing $ns namtrace-all $nf #Open the general trace file set tf [open out.tr w] # Start tracing $ns trace-all $tf #Define a 'finish' procedure proc finish {} { global ns nf tf $ns flush-trace #Close the trace files close $nf close $tf #Execute nam on the trace file exec nam out.nam & exit 0 } # Say when to stop simulation $ns at 5.0 "finish“ #Run the simulation $ns run