#
# Carnegie Mellon University
# 1999-2000
# Shahzad Ali
#
# Test script for wf2q+.
# Illustrates the behavior of the worst-case weighted FQ 
# (implemented by wf2q.cc) policy in the presence of 
# 3 UDP flows with different parameters 
# 
#     source, flow 0 (UDP)         sink, flow 0
#        \                              /
#         \                            /
#          n0 ----------------------- n1
#         /                            \
#        /                              \
#     source, flow 1 (UDP)         sink, flow 1
#     source, flow 2 (UDP)	   sink, flow 2

source utils.tcl

# create an instance of the simulator
set ns [new Simulator]

# create nodes
set n0 [$ns node]
set n1 [$ns node]

$ns duplex-link $n0 $n1 1.5Mb 10ms WF2Q

# set sizes of queues allocated to  flows 0 and 1 at the output
# port of n0 to 5000 bytes
# 
# NOTE: first we get a handle to the RR queue discipline
set q [$ns get-queue $n0 $n1]
$q set-queue-size 0 5000
$q set-queue-size 1 5000

# Set the weight of the flows
$q set-flow-weight 0 2 
$q set-flow-weight 1 1
$q set-flow-weight 2 1


# build the three UDP flows.  First two with 1000 byte packets at 1 Mbps
# and the thiird with 500 bytes packets at 0.6 Mbps
build-udp $n0 $n1 1000 0.008 0 0 10
build-udp $n0 $n1 1000 0.008 1 0.1 10
build-udp $n0 $n1 500 0.0067 2 0.2 10


#
# Create a trace and arrange for all link
# events to be dumped to "out.tr"
#
set tf [open out.tr w]
$ns trace-queue $n0 $n1 $tf

$ns at 10.0 "finish"

# flush all trace data when finish
proc finish {} {
        global ns tf
        $ns flush-trace
        close $tf
        exit 0
}
 
# start simulation
$ns run
