• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/tcp/formula.h

00001 #define MAXRATE 25000000.0 
00002 #define SAMLLFLOAT 0.0000001
00003 
00004 /*
00005  * This takes as input the packet drop rate, and outputs the sending 
00006  *   rate in bytes per second.
00007  */
00008 static double p_to_b(double p, double rtt, double tzero, int psize, int bval) 
00009 {
00010         double tmp1, tmp2, res;
00011 
00012         if (p < 0 || rtt < 0) {
00013                 return MAXRATE ; 
00014         }
00015         res=rtt*sqrt(2*bval*p/3);
00016         tmp1=3*sqrt(3*bval*p/8);
00017         if (tmp1>1.0) tmp1=1.0;
00018         tmp2=tzero*p*(1+32*p*p);
00019         res+=tmp1*tmp2;
00020 //      if (formula_ == 1 && p > 0.25) { 
00021 //              // Get closer to RFC 3714, Table 1.
00022 //              // This is for TCP-friendliness with a TCP flow without ECN
00023 //              //   and without timestamps.
00024 //              // Just for experimental purposes. 
00025 //              if p > 0.70) {
00026 //                      res=res*18.0;
00027 //              } else if p > 0.60) {
00028 //                      res=res*7.0;
00029 //              } else if p > 0.50) {
00030 //                      res=res*5.0;
00031 //              } else if p > 0.45) {
00032 //                      res=res*4.0;
00033 //              } else if p > 0.40) {
00034 //                      res=res*3.0;
00035 //              } else if p > 0.25) {
00036 //                      res=res*2.0;
00037 //              }
00038 //      }
00039         // At this point, 1/res gives the sending rate in pps:
00040         // 1/(rtt*sqrt(2*bval*p/3) + 3*sqrt(3*bval*p/8)*tzero*p*(1+32*p*p))
00041         if (res < SAMLLFLOAT) {
00042                 res=MAXRATE;
00043         } else {
00044                 // change from 1/pps to Bps.
00045                 res=psize/res;
00046         }
00047         if (res > MAXRATE) {
00048                 res = MAXRATE ; 
00049         }
00050         return res;
00051 }

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1