8
#Schedule events for the CBR agent $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run tell the CBR agent when to send data and when to stop sending

10
proc record {} { global ns tcp1 file1 tcp2 file2 statevar record_interval #Set the time after which the procedure should be called again set time $record_interval #Get the current time set now [$ns now] puts $file1 "$now [$tcp1 set $statevar]" puts $file2 "$now [$tcp2 set $statevar]" #Re-schedule the procedure $ns at [expr $now+$time] "record" } 2