Description:
X, Y coordinates points for more than one graph is generated randomly and put it in the trace files. All the trace files are given as input file to xgraph to plot all the graphs in the same plot.
X, Y coordinates points for more than one graph is generated randomly and put it in the trace files. All the trace files are given as input file to xgraph to plot all the graphs in the same plot.
File name: “graph2.tcl”
#-------Event scheduler object creation--------#
set ns [new Simulator]
set ns [new Simulator]
#Creating nam file:
set nf [open Tcpred.nam w]
$ns namtrace-all $nf
set nf [open Tcpred.nam w]
$ns namtrace-all $nf
#Open the trace file
set nt [open Tcpred.tr w]
$ns trace-all $nt
set nt [open Tcpred.tr w]
$ns trace-all $nt
proc Graph {} {
global ns g g1
set time 1.0
set now [$ns now]
puts $g "[expr rand()*8] [expr rand()*6]"
puts $g1 "[expr rand()*8] [expr rand()*6]"
$ns at [expr $now+$time] "Graph"
}
#Finish Procedure..
proc finish {} {
global ns nf nt
exec xgraph -brb -geometry 600X500 graph.tr graph1.tr &
exit 0
}
global ns g g1
set time 1.0
set now [$ns now]
puts $g "[expr rand()*8] [expr rand()*6]"
puts $g1 "[expr rand()*8] [expr rand()*6]"
$ns at [expr $now+$time] "Graph"
}
#Finish Procedure..
proc finish {} {
global ns nf nt
exec xgraph -brb -geometry 600X500 graph.tr graph1.tr &
exit 0
}
#Calling finish procedure
$ns at 5.0 "finish"
$ns run
$ns at 5.0 "finish"
$ns run
# How to run
$ns filename.tcl
$ns filename.tcl