Graph NS2模拟器X图形中的错误

Graph NS2模拟器X图形中的错误,graph,error-handling,tcl,bandwidth,ns2,Graph,Error Handling,Tcl,Bandwidth,Ns2,在下面的tcl代码中,我希望通过NS2模拟器中的2个路由器在两个节点之间创建TCP链路,并使用Xgraph绘制bandwith的图形 #step:-1 define global simulator object set sn [new Simulator] #step:-2 Define different colors for data flows (for NAM) $sn color 1 Red $sn color 2 Blue # Step:-3 Opening the NAM

在下面的tcl代码中,我希望通过NS2模拟器中的2个路由器在两个节点之间创建TCP链路,并使用Xgraph绘制bandwith的图形

 #step:-1 define global simulator object

set sn [new Simulator]

#step:-2 Define different colors for data flows (for NAM)
$sn color 1 Red
$sn color 2 Blue

# Step:-3 Opening the NAM trace file
set nt [open simulate.nam w]
$sn namtrace-all $nt

#Step:-4 Opening the Trace file
set tr [open simulate.tr w]
$sn trace-all $tr


#Step:5 Define a 'finish' procedure
proc finish {} {
        global sn nt tr
        $sn flush-trace
        #Close the NAM trace file
        close $nt
        close $tr
        exec nam simulate.nam &
        exec xgraph simulate.tr -geometry 800x400 &
        exit 0
}
#Step:-6 Creation of six nodes
set na [$sn node]
set nb [$sn node]
set nc [$sn node]
set nd [$sn node]
set ne [$sn node]
set nf [$sn node]

#Step:-7 Creating links between the nodes
$sn duplex-link $na $nc 2Mb 10ms DropTail
$sn duplex-link $nb $nc 2Mb 10ms DropTail
$sn duplex-link $nc $nd 1.7Mb 20ms DropTail
$sn duplex-link $nd $ne 2Mb 20ms DropTail
$sn duplex-link $nd $nf 2Mb 20ms DropTail


#Step:-8 Setting Queue Size of link (nc-nd) to 10
$sn queue-limit $nc $nd 10

#Step:-9 Provide node positions to visualize in NAM window
$sn duplex-link-op $na $nc orient right-down
$sn duplex-link-op $nb $nc orient right-up
$sn duplex-link-op $nc $nd orient right
$sn duplex-link-op $nd $ne orient right-up
$sn duplex-link-op $nd $nf orient right-down

#Step:-10 Monitoring the queue for link (nc-nd) (nd-ne). (for NAM)
$sn duplex-link-op $nc $nd queuePos 0.5
$sn duplex-link-op $nd $ne queuePos 0.5

#Step:-11 Setting up a TCP connection
set tcp [new Agent/TCP]
$tcp set class_ 1
$sn attach-agent $na $tcp

#Step:-12 If we setup tcp traffic source then connect it with tcp sink 
set sink [new Agent/TCPSink]
$sn attach-agent $ne $sink
$sn connect $tcp $sink
$tcp set fid_ 2


#Step:-13 Setting up a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
proc record {} {
        global sink tr
    #Get an instance of the simulator
    set ns [Simulator instance]
    #Set the time after which the procedure should be called again
        set time 0.5
    #How many bytes have been received by the traffic sinks?
        set bw0 [$sink set bytes_]
    #Get the current time
        set now [$ns now]
    #Calculate the bandwidth (in MBit/s) and write it to the files
        puts $tr "$now [expr $bw0/$time*8/1000000]"
    #Reset the bytes_ values on the traffic sinks
        $sink set bytes_ 0
    #Re-schedule the procedure
        $ns at [expr $now+$time] "record"
}
#Step:-17 Scheduling events for the CBR and FTP agents

$sn at 0.0 "record"
$sn at 0.5 "$ftp start"
$sn at 4.0 "$ftp stop"
$sn at 5.0 "finish"

#Step:-18 Run the simulation
$sn run
当我运行脚本时,我得到了错误

error in file simulate.tr
unknown line type
但是当这些线

$sn at 0.5 "$ftp start"
$sn at 4.0 "$ftp stop"

如果已删除,则图形将显示,尽管模拟未发生且没有错误!那么,我如何更正代码并查看xgraph中的带宽呢?

您试图将多少数据系列写入一个文件?“VIII.为xgraph创建输出文件”。。。50个例子。。。您可以使用
gnuplot
APP Tool
1…获得更好的绘图。。。2.