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

Re: [ns] Re: throughput measurement



Hi

I've attached an awk-file which I use to measure the TCP flow. Create a trace of the link closest to the receiver:

$ns trace-queue $node_x $node_y $out_tracefile

and run the awk file on the trace:

awk -f flowcalc.awk [-v graphgran=value] [-v fidfrom=value] [-v fidto=value] -v flowtype=tcp -v outdata_file=filename trace_file

or you can run this directly with the exec command in your simulation script.

It calculates the flow for all or the selected flow ids, so you have to set unique flow id to all flows using the link you trace.

/Håkan

Amit Kumar wrote:

 hi,
 i am new to ns. can anybody help me with how to measure the throughput of
 a tcp agent. for a udp agent, i know we can use a loss monitor, but when i
 used the same for tcp agent, it creates trouble, it doesn't return the
 acks and hence there is no packet transmission.
 hope to get a quick help

 thanks
 amit
 
 
 
 

-- 
Håkan Byström, Operax
+46 920 755 07, office
+46 70 374 03 24, cellular
 
BEGIN {
    arguments = 2;
    if (ARGC < arguments || ARGC > arguments || flowtype == 0) {
	printf("error: wrong number of arguments.\nawk: usage - awk -f flowcalc.awk [-v graphgran=value] [-v fidfrom=value] [-v fidto=value] -v flowtype=\"type\" -v outdata_file=\"filename\" indata_file\n");
	exit;
    } else {
	printf("Running flowcalc on %s to %s.\n", ARGV[arguments - 1], outdata_file);
    }
    measuretime = 0;
    if (graphgran == 0) {
	graphgran = 0.1;
    }
    bits = 0;
    first_time = 0;
    
}

{
    if (($1 == "r") &&
	((fidfrom == 0 && fidto ==0) || (($8 <= fidto) && ($8 >= fidfrom))) &&
	(flowtype == "all" || flowtype == $5)) {

	bits = bits + $6 * 8;

	if (($2 - graphgran) > measuretime) {
	    last_time = $2;
	    rate = (bits/1000000)/(last_time - first_time);
	    print last_time, rate >> outdata_file;
	    measuretime = $2;
	    bits = 0;
	    first_time = $2;
	}
    }
}

END {
}