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

[ns] why delay is so large?



Hi, 

I try a very simple script to test the delay performance.
10x64kbps CBR with packetsize 53byte, link rate is 2Mkbps.
It is expected that delay is very small, however the delay is 
large up to 44ms.  I can't bound the delay even when using
WFQ algorithm.

I wonder what's the problem. Someone who is kind enough to help me
may want to try my script attached belw.

Thanks.
set ns [new Simulator]

ns-random 0

set n0 [$ns node]
set n1 [$ns node]


set tf [open out.tr w]
$ns trace-all $tf
set df [open temp.q w]

$ns simplex-link $n0 $n1 2Mb 2ms DropTail

set fmon [$ns makeflowmon Fid]
$ns attach-fmon [$ns link $n0 $n1] $fmon

for {set i 0} {$i < 10} {incr i} {
	$ns at 0.0 "build-udp $n0 $n1 53 0.006625 $i 1.0 10.0"
}

# $ns at 6.0 "cdumpdel"
 $ns at 8.0 "cdumpdel"

#$ns at 10.0 "Bfinish; Pfinish Output"
$ns at 10.0 "Pfinish Output"
$ns at 10.0 "exit 0"

proc build-udp { src dest pktSize interval id startTime stopTime} {
    global ns

    # build udp source
    
    set udp [new Agent/UDP]
    $ns attach-agent $src $udp
    set cbr [new Application/Traffic/CBR]
    $cbr attach-agent $udp

    #build cbr sink
    set null [new Agent/LossMonitor]
    $ns attach-agent $dest $null

    #connect cbr sink to cbr null
    $ns connect $udp $null

    # init. cbr parameters
    if {$pktSize > 0} {  
        $cbr set packetSize_ $pktSize
    }
    $udp set fid_      $id
    $cbr set interval_ $interval
    $cbr set random_   1
    $ns at $startTime "$cbr start"
    $ns at $stopTime "$cbr stop"

    return $udp
}

# To display the throupput of several flows
proc Bfinish {} {
	global ns f0 f1	f2
	close $f0 
	close $f1
	close $f2
	#Call xgraph to display the results
	exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &
       
}

# To display the packets dispatched of flows
proc Pfinish file {
	
	set f [open temp.rands w]
	puts $f "TitleText: $file"
	puts $f "Device: Postscript"
	
	exec rm -f temp.p temp.d 
	exec touch temp.d temp.p
	#
	# split queue/drop events into two separate files.
	# we don't bother checking for the link we're interested in
	# since we know only such events are in our trace file
	#
	exec awk {
		{
			if (($1 == "+" || $1 == "-" ) && \
			    ($5 == "cbr"))\
					print $2, $8 + ($11 % 90) * 0.01
		}
	} out.tr > temp.p
	exec awk {
		{
			if ($1 == "d")
				print $2, $8 + ($11 % 90) * 0.01
		}
	} out.tr > temp.d

	puts $f \"packets
	flush $f
	exec cat temp.p >@ $f
	flush $f
	# insert dummy data sets so we get X's for marks in data-set 4
	puts $f [format "\n\"skip-1\n0 1\n\n\"skip-2\n0 1\n\n"]

	puts $f \"drops
	flush $f
	#
	# Repeat the first line twice in the drops file because
	# often we have only one drop and xgraph won't print marks
	# for data sets with only one point.
	#
	exec head -1 temp.d >@ $f
	exec cat temp.d >@ $f
	close $f
	exec xgraph -bb -tk -nl -m -x time -y packet temp.rands &

	# dump the highest seqno sent of each tcp agent
	# this gives an idea of throughput
	set k 1
	while 1 {
		global tcp$k
		if [info exists tcp$k] {
			set tcp [set tcp$k]
			puts "tcp$k seqno [$tcp set t_seqno_]"
		} else {
			break
		}
		incr k
	}
	exit 0
}

# To display average queueing delay 
proc cdumpdel {} {
	  global ns fmon df
	  set now [$ns now]
	  set fcl [$fmon classifier]
	
	  set fids { 0 1 2 }
	  foreach i $fids {
		  set flow [$fcl lookup auto 0 0 $i]
		  if { $flow != "" } {
			  set dsamp [$flow get-delay-samples]
			  puts "dumping delay"
			  puts $df "$now $i [$dsamp mean]"
		  } else { puts $df "fuck nothing" }
	  }
	close $df
}

$ns run