[Sumover-dev] [svn commit] r4644 - vic/branches/cc/cc

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Wed Feb 24 14:09:11 GMT 2010


Author: soohyunc
Date: Wed Feb 24 14:09:11 2010
New Revision: 4644

Added:
   vic/branches/cc/cc/formula-inverse.h   (contents, props changed)
   vic/branches/cc/cc/formula.h   (contents, props changed)

Log:
added TCP throughput equation and its inverse function



Added: vic/branches/cc/cc/formula-inverse.h
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/formula-inverse.h	Wed Feb 24 14:09:11 2010
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2010 University College London
+ * All rights reserved.
+ *
+ * AUTHOR: Soo-Hyun Choi <s.choi at .cs.ucl.ac.uk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef vic_cc_formula_inverse_h
+#define vic_cc_formula_inverse_h
+
+#include "formula.h"
+
+double b_to_p(double b, double rtt, double tzero, int psize, int bval) 
+{
+	double p, pi, bres;
+	int ctr=0;
+	p=0.5;pi=0.25;
+	while(1) {
+		bres=p_to_b(p,rtt,tzero,psize, bval);
+		/*
+		 * if we're within 5% of the correct value from below, this is OK
+		 * for this purpose.
+		 */
+		if ((bres>0.95*b)&&(bres<1.05*b)) 
+			return p;
+		if (bres>b) {
+			p+=pi;
+		} else {
+			p-=pi;
+		}
+		pi/=2.0;
+		ctr++;
+		if (ctr>30) {
+			return p;
+		}
+	}
+}
+
+#endif /* vic_cc_formula_inverse_h */

Added: vic/branches/cc/cc/formula.h
==============================================================================
--- (empty file)
+++ vic/branches/cc/cc/formula.h	Wed Feb 24 14:09:11 2010
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010 University College London
+ * All rights reserved.
+ *
+ * AUTHOR: Soo-Hyun Choi <s.choi at .cs.ucl.ac.uk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef vic_cc_formula_h
+#define vic_cc_formula_h
+
+#define MAXRATE 25000000.0 
+#define SAMLLFLOAT 0.0000001
+
+/*
+ * This takes as input the packet drop rate, and outputs the sending 
+ *   rate in bytes per second.
+ */
+static double p_to_b(double p, double rtt, double tzero, int psize, int bval)
+{
+	double tmp1, tmp2, res;
+
+	if (p < 0 || rtt < 0) {
+		return MAXRATE ;
+	}
+	res = rtt * sqrt(2.0*bval*p/3.0);
+	tmp1 = 3.0 * sqrt(3.0*bval*p/8.0);
+
+	if (tmp1>1.0) tmp1=1.0;
+
+	tmp2 = tzero * p * (1.0+32.0 * p * p);
+	res += tmp1 * tmp2;
+
+	double temp = res;  // res val (packets per second)
+
+	// At this point, 1/res gives the sending rate in pps:
+	// 1/(rtt*sqrt(2*bval*p/3) + 3*sqrt(3*bval*p/8)*tzero*p*(1+32*p*p))
+	if (res < SAMLLFLOAT) {
+		res=MAXRATE;
+	} else {
+		// change from 1/pps to Bps.
+		res=psize/res;
+	}
+	if (res > MAXRATE) {
+		res = MAXRATE ;
+	}
+
+	double now;
+	double Tx = 8.0 * res;  // unit of Tx is "bits" per second
+	fprintf (stderr, 
+		" %f tfrcTx: %f temp: %f rtt: %f tzero: %f p: %f\n",
+		now, Tx, temp, rtt, tzero, p);
+
+	return res;
+}
+
+#endif /* vic_cc_formula_h */



More information about the Sumover-dev mailing list