Comp 388/488 - advanced TCP/IP Dordal November 21, 2001 program 3 due: Dec 12, Wednesday (or within 1-2 days) You are to use ns to make some measurements of the average queue length under tcp. The conjecture is that for a single active TCP Reno connection, the average queue length used at a router is half the router's actual capacity; that is, the actual queue size varies uniformly from size 0 to full. You are to verify that, and also experiment with multiple connections, including TCP Vegas. To do this you will have to create trace files for specific links, and then analyze the files for queue size changes. You should also accumulate statistics for how long (if ever) the queue is empty. To create a tracefile, "mytracexy.tr", between nodes x and y, put the following into your ns tcl script: set tr [open mytracexy.tr w] # create the file for writing $ns trace-queue $x $y $tr Note that "tr" is the name of the file variable within the program; the file's "external" name is "mytracexy.tr"; this is the file that will exist after the program has run. Note also that the queue is considered by ns to be attached to a _link_, from x to y above, and not to the node x. Note also that the queue is considered by ns to be attached to a _link_, from x to y above, and not to the node x. A trace file consists of lines with 12 fields: 1. disposition (+: arrival, -: departure, d: drop, r: received at far end) 2. time 3. link src (always the same if you only trace between two fixed nodes as above; equal to node x in the example above) 4. link dest (node y above) 5. type, eg "tcp" 6. packet size 7. flag string, which we'll ignore 8. flowid, useful for distinguishing between multiple connections 9. srchost.srcport 10. dsthost.dstport 11. sequence number 12. unique packet id We'll only be concerned with a few of these. The first field tells you what was done with the packet. If a packet arrived ("+"), you increment the queue size. If a packet departed ("-"), you decrement (and verify, if desired, that the queue size did not become negative). If the packet was dropped ("d"), you decrement the queue size (and verify, if desired, that the queue was full). For "r" events, this means that the packet was received at the other end of the link; you simply ignore these. What you need to do is maintain a running average of the queue size, by (a) keeping track of the size, and (b) for each time interval [t1,t2] over which the queue has a given size s, add s*(t2-t1) to a running total. When you're done, divide the running total by the total simulation time to get the average. Here is a simple script in the "awk" language, available on abel, that does this. Awk parses the input lines into fields, denoted $1 through $12 (though we only use $1 and $2 here). Awk is string-based; you can get further information from the "man" page, obtained on abel by typing "man awk", or else by searching on the web. BEGIN {size=0; prevtime=0.0;sum=0.0;} $1 == "r" {next} { sum += size*($2-prevtime); prevtime=$2; } $1 == "+" {size+=1} $1 == "-" {size-=1; if (size==0) print "size zero at ", $2} $1 == "d" {size-=1; print "size at drop is ", size, " ", sum} END {print "sum is ", sum, " final size is ", size} Put this into a file, say "queue_avg", and then run it via awk -f queue_avg mytracexy.tr Here are some questions to answer: 1. For a single tcp connection with a bottleneck link, find out the average queue size and how much time the queue is empty. Do this for, as usual, a few different queue sizes. 2. For two tcp connections sharing a bottleneck link, how much queue does each get? How does this number compare to the *bandwidth* each gets? Use a couple scenarios you developed for the previous ns project. 3. Create a scenario in which two TCP Reno connections share the bandwidth reasonably fairly. Then change one to TCP Vegas, and see what the relative bandwidth and queue utilization are. Note that when working with more than one connection you'll have to use the flowid field ($8) to keep separate totals for each flow.