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

[ns] Anything wrong with utilization? (fwd)



---------- Forwarded message ----------
Date: Sat, 24 Nov 2001 15:20:31 -0500 (EST)
From: Liangping Ma <[email protected]>
To: [email protected]
Subject: Anything wrong with utilization?

Hi,
    I was puzzled by the utilization I obtained for FTP.
    The topology I used is a dum-bell with each of the two core nodes
having five edge nodes. And each edge node has 3 infinite FTP
applications. I send 15 FTP data from one side of the dum-bell to the
corresponding 15 sinks on the other side. The core link is 8Mbps, and each
edge link is 100Mbps. The buffers are 100 pkts and 200 pkts respectively.
    Given the receive window W, the number of TCP connections N, the
maximum packet size (say 1000 bytes), the maximum throughput in the core
link is T=(N*W*1000*8/RTT), and the utilization of the core link (8Mbps)
is T/8M. Set the ratio to be 1, then the W* is the minimum window size to
achieve utilization 1 in the core link. However in simulation, when the
window size (FTP_MAXWIN) is half of the theoretical lower bound W*, the
utilization in the core link is already 1. If we take into transmission
delay, the W* should be larger, which makes the dispcrepancy larger. The
window size which achieves utilization 1 in the core link should be larger
than W*.

     What is wrong?
     Thanks in advance!

Sincerely yours,
Liangping

P.S. The code (tclsh8.3): (for convenience, I also use attachments for
them)
#
# Modified by Liangping Ma, November 2001 ([email protected])
#

#
# Includes a file with basic function definitions
#
source basic_functions.tcl

#
# Create Simulator TCL object
#
set ns [new Simulator]


#
# Initialize random number generation seed
#
set rnd [new RNG]
puts "Random seed:"
gets stdin seed
$rnd seed $seed



#
# Create topology: nodes and links
#
puts "\n                           -----   TOPOLOGY SETUP   -----\n"

# Create (5+5+2) network nodes
for {set i 1} {$i <= 5} {incr i} {
set A($i) [$ns node]
set B($i) [$ns node]
}

set C1 [$ns node];  # Core nodes C1, C2
set C2 [$ns node]

# edge link parameters
set BW 100Mb;
set BUFF 200;

# Create drop-tail links from A's (B's) to C's
for {set i 1} {$i <=5} {incr i} {
#set DEL_AC1  [$rnd uniform 5 20]ms
#set DEL_BC2  [$rnd uniform 5 20]ms
# To simplify the calculation, use deterministic delays
set DEL_AC1 12.5ms;    # delay between A()'s to C1
set DEL_BC2 12.5ms;    # delay between B()'s to C2
#
$ns simplex-link $A($i) $C1 $BW DEL_AC1 DropTail
[[$ns link $A($i) $C1] queue] set limit_ $BUFF
$ns simplex-link $C1 $A($i) $BW DEL_AC1 DropTail
[[$ns link $C1 $A($i)] queue] set limit_ $BUFF
#
$ns simplex-link $B($i) $C2 $BW DEL_BC2 DropTail
[[$ns link $B($i) $C2] queue] set limit_ $BUFF
$ns simplex-link $C2 $B($i) $BW DEL_BC2 DropTail
[[$ns link $C2 $B($i)] queue] set limit_ $BUFF
#
puts [format "Link from A($i) to C1 ::\t\t\t DROPTAIL - bw: $BW - delay:
$DEL_AC1 "]
puts [format "Link from C1 to A($i) ::\t\t\t DROPTAIL - bw: $BW - delay:
$DEL_AC1 "]
puts [format "Link from B($i) to C2 ::\t\t\t DROPTAIL - bw: $BW - delay:
$DEL_BC2 "]
puts [format "Link from C2 to B($i) ::\t\t\t DROPTAIL - bw: $BW - delay:
$DEL_BC2 "]
}
puts " \n"

# Core link parameters
set Core_Del 25ms;
set Core_BW  8Mb;
set Core_BUFF 100;

# Create drop-tail links from C1 to C2
$ns simplex-link $C1 $C2 $Core_BW $Core_Del DropTail
[[$ns link $C1 $C2] queue] set limit_ $Core_BUFF
$ns simplex-link $C2 $C1 $Core_BW $Core_Del DropTail
[[$ns link $C2 $C1] queue] set limit_ $Core_BUFF
puts [format "Link from C1 to C2 ::\t\t\t DROPTAIL - bw: $Core_BW - delay:
$Core_Del "]
puts [format "Link from C2 to C1 ::\t\t\t DROPTAIL - bw: $Core_BW - delay:
$Core_Del"]


#
# Create network traffic
#
puts " "
puts "\n             ------ Traffic setup -------\n"

#
# Create FTP connections from A's to B's and UDP (exponential off)
connections
#

set NO_FTPS	  3;    # Number of FTP connections for each edge node
set FTP_PKTSZ   1000;   # Packet size for FTP connections
set FTP_MAXWIN   4; 	# Maximum receiver's window for FTP connection

for {set j 1} {$j <= 5} {incr j} {
puts "Creating FTP connections  from A($j) to B($j): "
for {set i 1} {$i <= $NO_FTPS} {incr i} {
	set id  [expr ($j - 1) * 3 + $i]
        set start_time [expr 0.0 + [$rnd uniform 0 1]];
	inf_ftp $id $A($j) $B($j) $FTP_MAXWIN $FTP_PKTSZ $start_time
        puts " -> FTP connection (FID=$id) starts at $start_time"
}
puts " "
}


#
#Monitoring Code
#

set STATS_START  0.0; 	# Start-time for getting statistics
set STATS_INTR   2.0;	# Interval between reporting statistics
$ns at $STATS_START "print_time $STATS_INTR"


# Queue monitor from C1 to C2
set qmon_c1c2 [$ns monitor-queue $C1 $C2 ""]
set bing_c1c2 [$qmon_c1c2 get-bytes-integrator];	# bytes integrator
set ping_c1c2 [$qmon_c1c2 get-pkts-integrator];	# packets integrator
$ns at $STATS_START  "$qmon_c1c2 reset"
$ns at $STATS_START  "$bing_c1c2 reset"
$ns at $STATS_START  "$ping_c1c2 reset"
$ns at [expr $STATS_START+$STATS_INTR] "linkDump [$ns link $C1 $C2]
$bing_c1c2 $ping_c1c2 $qmon_c1c2 $STATS_INTR C1-C2"

# Queue monitor from C2 to C1
set qmon_c2c1 [$ns monitor-queue $C2 $C1 ""]
set bing_c2c1 [$qmon_c2c1 get-bytes-integrator];	# bytes integrator
set ping_c2c1 [$qmon_c2c1 get-pkts-integrator];	# packets integrator
$ns at $STATS_START  "$qmon_c2c1 reset"
$ns at $STATS_START  "$bing_c2c1 reset"
$ns at $STATS_START  "$ping_c2c1 reset"
$ns at [expr $STATS_START+$STATS_INTR] "linkDump [$ns link $C2 $C1]
$bing_c2c1 $ping_c2c1 $qmon_c2c1 $STATS_INTR C2-C1"


proc finish {} {
	puts "\n                           -----   SIMULATION ENDS
-----\n"
        exit 0
}

set FINISH_TIME 	12.1;	# simulation end-time
$ns at $FINISH_TIME "finish"



#
# Start the simulation!
#
puts "\n                           -----   SIMULATION STARTS   -----\n"
$ns run

**********************
********************** where the line "source  basic_functions.tcl"
directs to :

#
# Print periodic "i'am alive" message
#
proc print_time {interval} {
global ns
        puts stdout [format "\nTime: %.2f" [$ns now]]
        $ns at [expr [$ns now]+$interval] "print_time $interval"
}


#
# Dump the statistics of a (unidirectional) link periodically
#
proc linkDump {link binteg pinteg qmon interval name} {
global ns
        set now_time [$ns now]
        $ns at [expr $now_time + $interval] "linkDump $link $binteg
$pinteg $qmon $interval $name"
        set bandw [[$link link] set bandwidth_]
        set queue_bd [$binteg set sum_]
        set abd_queue [expr $queue_bd/[expr 1.*$interval]]
        set queue_pd [$pinteg set sum_]
        set apd_queue [expr $queue_pd/[expr 1.*$interval]]
        set utilz [expr 8*[$qmon set bdepartures_]/[expr
1.*$interval*$bandw]]
        if {[$qmon set parrivals_] != 0} {
                set drprt [expr [$qmon set pdrops_]/[expr 1.*[$qmon set
parrivals_]]]
        } else {
                set drprt 0
        }
	if {$utilz != 0} {;	# compute avg queueing delay based on
Little's formula
		set a_delay [expr ($abd_queue*8*1000)/($utilz*$bandw)]
	} else {
		set a_delay 0.
	}
        puts stdout [format "\nTime interval: %.2f-%.2f" [expr [$ns now] -
$interval] [$ns now]]
        puts [format "Link %s: Utiliz=%.3f LossRate=%.3f AvgDelay=%.1fms
AvgQueue(Packs)=%.0f AvgQueue(Bytes)=%.0f" $name $utilz $drprt $a_delay
$apd_queue $abd_queue]
        $binteg reset
        $pinteg reset
        $qmon reset
}


#
# Print the statistics of a flow
#
proc printFlow {f outfile fm interval} {
global ns
puts $outfile [format "Flow-ID: %d packs: %d bytes: %d drops(pck): %d
drops(byt): %d rate: %.0f drop_rate: %.3f" [$f set flowid_] [$f set
parrivals_] [$f set barrivals_] [$f set pdrops_] [$f set bdrops_] [expr
[$f set barrivals_]*8/($interval*1000.)] [expr [$f set pdrops_]/double([$f
set parrivals_])] ]
}


#
# Dump the statistics of all flows
#
proc flowDump {link fm file_p interval} {
global ns
        $ns at [expr [$ns now] + $interval]  "flowDump $link $fm $file_p
$interval"
        puts $file_p [format "\nTime: %.2f" [$ns now]]
        set theflows [$fm flows]
        if {[llength $theflows] == 0} {
                return
        } else {
        	set total_arr [expr double([$fm set barrivals_])]
        	if {$total_arr > 0} {
                	foreach f $theflows {
                        	set arr [expr [expr double([$f set
barrivals_])] / $total_arr]
                        	if {$arr >= 0.0001} {
                                printFlow $f $file_p $fm $interval
                        	}
                        	$f reset
                	}
                	$fm reset
        	}
        }
}



#
# Create "infinite-duration" FTP connection
#
proc inf_ftp {id src dst maxwin pksize starttm} {
global ns
        set tcp [$ns create-connection TCP/Newreno $src TCPSink/DelAck
$dst $id]
        set ftp [$tcp attach-source FTP]
  	$tcp set window_ 	$maxwin
  	$tcp set packetSize_ 	$pksize
        $ns at $starttm "$ftp start"
	return $tcp
}


#
# Create an Exponential On-Off source
#
proc build-exp-off { src dest pktSize burstTime idleTime rate id startTime
} {
    global ns
    set cbr [new Agent/CBR/UDP]
    $ns attach-agent $src $cbr
    set null [new Agent/Null]
    $ns attach-agent $dest $null
    $ns connect $cbr $null
    set exp1 [new Traffic/Expoo]
    $exp1 set packet-size $pktSize
    $exp1 set burst-time  [expr $burstTime / 1000.0]
    $exp1 set idle-time   [expr $idleTime / 1000.0]
    $exp1 set rate        [expr $rate * 1000.0]
    $cbr  attach-traffic  $exp1
    $ns at $startTime "$cbr start"
    $cbr set fid_      $id
    return $cbr
}