[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Is this a bug of NS?



Hello everyone!

I am a newer in NS. and I did a simple test about two TCP flows on one link, and all parameters of these TCP flows are the same except fid_  .

My question is : why the two same TCP flows passing the same link (and start at the same time) have different simulation result?

I think this is due to the two "start" is not start at the same time in NS, is it?


.tcl file's content is :

#----------------------------------a simple test ----------------------------------------
#debug 1

proc create_flowstats { mylink stoptime point_num } {
    global ns r1fm flowfile

    set flowfile data.f
    set flowdesc [open $flowfile w]
    set r1fm [$ns makeflowmon Fid]
    $r1fm attach $flowdesc
    $ns attach-fmon $mylink $r1fm;
    for {set ii 0} { $ii <= $point_num } {incr ii} {
     set now_time [expr 1.000000*$ii*$stoptime/$point_num];
        $ns at $now_time "$r1fm dump";
    }
    $ns at $stoptime "close $flowdesc"
}

 
set point_num 1000
set ns [new Simulator]
set finish_time 500
 
#
#
# Create a simple six node topology:
#
#       tcp1      
#             r1 ---------- r2
#       tcp2 

proc build_topology { ns } {

    global node_

    set node_(r1) [$ns node]
    set node_(r2) [$ns node]

    $ns duplex-link $node_(r1) $node_(r2) 0.8Mb 2ms DropTail
    $ns queue-limit $node_(r1) $node_(r2) 25
    $ns queue-limit $node_(r2) $node_(r1) 25

    $ns duplex-link-op $node_(r1) $node_(r2) orient right
    $ns duplex-link-op $node_(r1) $node_(r2) queuePos 0.5
    $ns duplex-link-op $node_(r2) $node_(r1) queuePos 0.5
 
}

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

build_topology $ns

# Use nam trace format for TCP variable trace 
Agent/TCP set nam_tracevar_ true

set tcp1 [$ns create-connection TCP $node_(r1) TCPSink $node_(r2) 0]
$tcp1 set fid_ 1
$tcp1 set window_ 15

set tcp2 [$ns create-connection TCP $node_(r1) TCPSink $node_(r2) 0]
$tcp1 set fid_ 2
$tcp2 set window_ 15
 
set ftp1 [$tcp1 attach-app FTP]    
set ftp2 [$tcp2 attach-app FTP]

# Add agent traces and variable trace
$ns add-agent-trace $tcp1 tcp1
$ns add-agent-trace $tcp2 tcp2
$ns monitor-agent-trace $tcp1
$ns monitor-agent-trace $tcp2
$tcp1 tracevar cwnd_
$tcp2 tracevar cwnd_

create_flowstats [$ns link $node_(r1) $node_(r2)] $finish_time $point_num
 
$ns at 0.0 "$ftp1 start"
$ns at 0.0 "$ftp2 start"

$ns at 0 "$tcp1 tracevar cwnd_"
$ns at 0 "$tcp2 tracevar cwnd_"


$ns at $finish_time "finish"

proc finish {} {
        global ns f nf
        $ns flush-trace
        close $f
        close $nf
 
        #XXX
#       puts "Filtering ..."
# exec tclsh8.0 /home/ns2/nam-1.0a8/bin/namfilter.tcl out.nam

#       puts "running nam..."
#       exec nam out.nam &
        exit 0
}
 
puts "Simulating ...................."
$ns run

#------------------------------------end of file----------------------------------------------
   
  
in the file, the parameters of two TCP flowsare are similiar except fid_.
But after simulation, we can look through the file "data.f" and we can find that the performance (such as drop packet and throughput) of these two flows is different.

when I use 
    $ns at 0 "$tcp1 tracevar cwnd_"
    $ns at 0 "$tcp2 tracevar cwnd_"
in .tcl file, then the flow 2 is better.

while,
when I use 
    $ns at 0 "$tcp1 tracevar cwnd_"
    $ns at 0 "$tcp2 tracevar cwnd_"
in .tcl file, then the flow 1 is better.

when I use TCP/Reno---TCPSink, or TCP/Sack1--TCPSink/Sack1, the result is similiar with TCP(Tahoe).

Good result can be derived only when I use TCP/Sack1--TCPSink/Sack1/DelAck, the result is: two TCP flows have the same performance.