Version 66 of How do I read and write files in Tcl

Updated 2011-11-25 10:05:41 by test

lor "purple" $n2 color "seagreen" $n3 color "orange" $n4 color "skyblue" $n5 color "red" $n6 color "black"

$ns at 0.0 "$n0 label Sender" $ns at 0.0 "$n1 label Receiver1" $ns at 0.0 "$n2 label Receiver2" $ns at 0.0 "$n3 label Receiver3"

set nf open bus.nam w $ns namtrace-all $nf set f open bus.tr w $ns trace-all $f

$ns duplex-link $n0 $n5 $Bandwidth 30ms DropTail $ns duplex-link $n5 $n2 $Bandwidth 30ms DropTail $ns duplex-link $n4 $n1 $Bandwidth 30ms DropTail $ns duplex-link $n4 $n5 $Bandwidth 30ms DropTail $ns duplex-link $n5 $n6 $Bandwidth 30ms DropTail $ns duplex-link $n6 $n3 $Bandwidth 30ms DropTail

$ns duplex-link-op $n0 $n5 orient down $ns duplex-link-op $n5 $n2 orient down $ns duplex-link-op $n4 $n1 orient down $ns duplex-link-op $n4 $n5 orient right $ns duplex-link-op $n5 $n6 orient right $ns duplex-link-op $n6 $n3 orient down

$ns queue-limit $n4 $n5 10

Agent/TCP set nam_tracevar_ true Agent/TCP set window_ $wind Agent/TCP set cwnd_ $cwnd

set tcp1 new Agent/TCP $ns attach-agent $n0 $tcp1 $tcp1 set fid_ 1 ;

set sink1 new Agent/TCPSink $ns attach-agent $n1 $sink1

$ns connect $tcp1 $sink1

set ftp1 new Application/FTP $ftp1 attach-agent $tcp1

set tcp2 new Agent/TCP $ns attach-agent $n0 $tcp2 $tcp2 set fid_ 1 ;

set sink2 new Agent/TCPSink $ns attach-agent $n2 $sink2

$ns connect $tcp2 $sink2

set ftp2 new Application/FTP $ftp2 attach-agent $tcp2

$ns at 0.05 "$ftp1 start" $ns at 0.35 "$ns detach-agent $n0 $tcp1 ; $ns detach-agent $n1 $sink1" $ns at 0.45 "$ftp2 start" $ns at 0.90 "$ns detach-agent $n0 $tcp2 ; $ns detach-agent $n2 $sink2"

$ns at 0.90 "finish"

proc finish {} {

        global ns nf
        $ns flush-trace
        close $nf
        exec awk {
               {
                 if ($1=="-" && $5=="tcp")  {
                     print $2  "\t" $11  
                 }

} } bus.tr > throughput.data

        puts "filtering..."
        # exec tclsh ../bin/namfilter.tcl multicast.nam
        # puts "running nam..."
        exec nam bus.nam &
        exec xgraph throughput.data &
        exit 0

}

$ns run