File: formula.h

package info (click to toggle)
ns2 2.35%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 79,396 kB
  • sloc: cpp: 172,923; tcl: 107,167; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 829; awk: 525; csh: 355
file content (51 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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*bval*p/3);
	tmp1=3*sqrt(3*bval*p/8);
	if (tmp1>1.0) tmp1=1.0;
	tmp2=tzero*p*(1+32*p*p);
	res+=tmp1*tmp2;
//	if (formula_ == 1 && p > 0.25) { 
//		// Get closer to RFC 3714, Table 1.
//		// This is for TCP-friendliness with a TCP flow without ECN
//		//   and without timestamps.
//		// Just for experimental purposes. 
//		if p > 0.70) {
//			res=res*18.0;
//		} else if p > 0.60) {
//			res=res*7.0;
//		} else if p > 0.50) {
//			res=res*5.0;
//		} else if p > 0.45) {
//			res=res*4.0;
//		} else if p > 0.40) {
//			res=res*3.0;
//		} else if p > 0.25) {
//			res=res*2.0;
//		}
//	}
	// 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 ; 
	}
	return res;
}