• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/packmime/packmime_ranvar.h

00001 /* 
00002  * Copyright 2002, Statistics Research, Bell Labs, Lucent Technologies and
00003  * The University of North Carolina at Chapel Hill
00004  * 
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *    1. Redistributions of source code must retain the above copyright 
00009  * notice, this list of conditions and the following disclaimer.
00010  *    2. Redistributions in binary form must reproduce the above copyright 
00011  * notice, this list of conditions and the following disclaimer in the 
00012  * documentation and/or other materials provided with the distribution.
00013  *    3. The name of the author may not be used to endorse or promote 
00014  * products derived from this software without specific prior written 
00015  * permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00019  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00020  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
00021  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00022  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00023  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00024  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00025  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
00026  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 /*
00031  * Reference
00032  *     Stochastic Models for Generating Synthetic HTTP Source Traffic 
00033  *     J. Cao, W.S. Cleveland, Y. Gao, K. Jeffay, F.D. Smith, and M.C. Weigle 
00034  *     IEEE INFOCOM 2004.
00035  *
00036  * Documentation available at http://dirt.cs.unc.edu/packmime/
00037  * 
00038  * Contacts: Michele Weigle (mcweigle@cs.unc.edu),
00039  *           Kevin Jeffay (jeffay@cs.unc.edu)
00040  */
00041 
00042 #ifndef ns_pm_ranvar_h
00043 #define ns_pm_ranvar_h
00044 
00045 #include "ranvar.h"
00046 
00047 #define PACKMIME_XMIT_CLIENT 0
00048 #define PACKMIME_XMIT_SERVER 1
00049 #define PACKMIME_REQ_SIZE 0
00050 #define PACKMIME_RSP_SIZE 1
00051 
00052 struct arima_params {
00053   double d;
00054   int N;
00055   double varRatioParam0, varRatioParam1;
00056   int pAR, qMA;
00057 };
00058 
00059 /*:::::::::::::::::::::::::::::::: FX  :::::::::::::::::::::::::::::::::::::*/
00060 
00061 // FX generator based on interpolation
00062 class FX {
00063 public:
00064   FX(const double* x, const double* y, int n);
00065   ~FX();
00066   double LinearInterpolate(double xnew);
00067 private:
00068   double* x_, *y_;
00069   int nsteps_;
00070   double* slope_; // avoid real-time slope computation
00071 };
00072 
00073 /*:::::::::::::::::::::::::::: Fractional ARIMA  :::::::::::::::::::::::::::*/
00074 
00075 class FARIMA {
00076 public:
00077   FARIMA(RNG* rng, double d, int N, int pAR=0, int qMA=1);
00078   ~FARIMA();
00079 
00080   double Next();
00081 private:
00082   RNG* rng_;
00083   int t_, N_, pAR_, qMA_, tmod_;
00084   double* AR_, *MA_, *x_, *y_, *phi_, d_;
00085   double NextLow();
00086 };
00087 
00088 /*:::::::::::::::::::::: PackMimeHTTP Transmission Delay RanVar ::::::::::::*/
00089 
00090 class PackMimeHTTPXmitRandomVariable : public RandomVariable {
00091 
00092 public:
00093   virtual double value();
00094   virtual double avg();
00095   PackMimeHTTPXmitRandomVariable();
00096   PackMimeHTTPXmitRandomVariable(double rate, int type);
00097   PackMimeHTTPXmitRandomVariable(double rate, int type, RNG* rng);
00098   ~PackMimeHTTPXmitRandomVariable();
00099   double* ratep() {return &rate_;}
00100   double rate() {return rate_;}
00101   void setrate(double r) {rate_ = r;}
00102   int* typep() {return &type_;}
00103   int type() {return type_;}
00104   void settype(int t) {type_ = t;}
00105 
00106 private:
00107   void initialize();
00108   double rate_;
00109   int type_;
00110   double varRatio_, sigmaNoise_, sigmaEpsilon_;
00111   double const_;
00112   double mean_;
00113   FARIMA* fARIMA_;
00114   static const double SHORT_RTT_INVCDF_X[];
00115   static const double SHORT_RTT_INVCDF_Y[];
00116   static const double LONG_RTT_INVCDF_X[];
00117   static const double LONG_RTT_INVCDF_Y[];
00118   static struct arima_params rtt_arima_params[]; 
00119   static FX rtt_invcdf[2];
00120   static const double WEIBULL_SHAPE[2];
00121 };
00122 
00123 /*:::::::::::::::::::::: PackMimeHTTP Flow Arrival RanVar :::::::::::::::::*/
00124 
00125 class PackMimeHTTPFlowArriveRandomVariable : public RandomVariable {
00126 public:
00127   virtual double value();
00128   virtual double avg();
00129   virtual double avg(int gap_type_);
00130   PackMimeHTTPFlowArriveRandomVariable();
00131   PackMimeHTTPFlowArriveRandomVariable(double rate);
00132   PackMimeHTTPFlowArriveRandomVariable(double rate, RNG* rng);
00133   ~PackMimeHTTPFlowArriveRandomVariable();
00134   double* ratep() {return &rate_;}
00135   double rate() {return rate_;}
00136   void setrate(double r) {rate_ = r;}
00137 
00138 private:
00139   void initialize();
00140   double rate_;
00141   double const_;
00142   double mean_;
00143   double varRatio_, sigmaNoise_, sigmaEpsilon_, weibullShape_, weibullScale_;
00144   FARIMA *fARIMA_;
00145   static struct arima_params flowarrive_arima_params;
00146 };
00147 
00148 /*:::::::::::::::::::::: PackMimeHTTP File Size RanVar :::::::::::::::::::::*/
00149 
00150 class PackMimeHTTPFileSizeRandomVariable : public RandomVariable {
00151 public:
00152   virtual double value();
00153   virtual double avg();
00154   PackMimeHTTPFileSizeRandomVariable();
00155   PackMimeHTTPFileSizeRandomVariable(double rate, int type);  
00156   PackMimeHTTPFileSizeRandomVariable(double rate, int type, RNG* rng);  
00157   ~PackMimeHTTPFileSizeRandomVariable(); 
00158   double* ratep() {return &rate_;}
00159   double rate() {return rate_;}
00160   void setrate(double r) {rate_ = r;}
00161   int* typep() {return &type_;}
00162   int type() {return type_;}
00163   void settype(int t) {type_ = t;}
00164 
00165 private:
00166   void initialize();
00167   double rate_;
00168   int type_;
00169   double const_;
00170   double mean_;
00171   double varRatio_, sigmaNoise_, sigmaEpsilon_;
00172   FARIMA* fARIMA_;
00173   int runlen_, state_;
00174   double shape_[2], scale_[2];
00175   double loc_;
00176   double scale2_;
00177   int rfsize0(int state);
00178   int qfsize1(double p);
00179 
00180   /* fitted inverse cdf curves for file sizes  */
00181   static const double FSIZE0_INVCDF_A_X[];
00182   static const double FSIZE0_INVCDF_A_Y[];
00183   static const double FSIZE0_INVCDF_B_X[];
00184   static const double FSIZE0_INVCDF_B_Y[];
00185   static const double FSIZE1_INVCDF_A_X[];
00186   static const double FSIZE1_INVCDF_A_Y[];
00187   static const double FSIZE1_INVCDF_B_X[];
00188   static const double FSIZE1_INVCDF_B_Y[];
00189   static const double FSIZE1_PROB_A;
00190   static const double FSIZE1_D;
00191   static const double FSIZE1_VARRATIO_INTERCEPT;
00192   static const double FSIZE1_VARRATIO_SLOPE;
00193 
00194   /* server file size run length for downloaded and cache validation */
00195   static const double WEIBULLSCALECACHERUN;
00196   static const double WEIBULLSHAPECACHERUN_ASYMPTOE;
00197   static const double WEIBULLSHAPECACHERUN_PARA1;
00198   static const double WEIBULLSHAPECACHERUN_PARA2;
00199   static const double WEIBULLSHAPECACHERUN_PARA3;
00200   static const double WEIBULLSCALEDOWNLOADRUN;
00201   static const double WEIBULLSHAPEDOWNLOADRUN;
00202   static const double FSIZE0_PARA[];
00203   static struct arima_params filesize_arima_params;
00204   static const double* P;
00205   static FX fsize_invcdf[2][2]; 
00206 
00207   /* cut off of file size for cache validation */
00208   static const int FSIZE0_CACHE_CUTOFF; 
00209   static const int FSIZE0_STRETCH_THRES;
00210   /* mean of log2(fsize0) for non cache validation flows */
00211   static const double M_FSIZE0_NOTCACHE;
00212   /* variance of log2(fsize0) for non cache validation flows */ 
00213   static const double V_FSIZE0_NOTCACHE; 
00214 
00215   /* fsize0 for non-cache validation flow */
00216   static const double M_LOC;        /* mean of location */
00217   static const double V_LOC;        /* variance of location */
00218   static const double SHAPE_SCALE2; /* Gamma shape parameter of scale^2*/
00219   static const double RATE_SCALE2;  /* Gamma rate parameter of scale^2 */
00220   static const double V_ERROR;      /* variance of error */
00221 };
00222 
00223 /*:::::::::::::::::::::: PackMimeHTTP Persistent Rsp Size RanVar :::::::::::*/
00224 
00225 class PackMimeHTTPPersistRspSizeRandomVariable : public RandomVariable {
00226 public:
00227   virtual double value();
00228   virtual double avg();
00229   PackMimeHTTPPersistRspSizeRandomVariable();
00230   PackMimeHTTPPersistRspSizeRandomVariable(RNG* rng);
00231   ~PackMimeHTTPPersistRspSizeRandomVariable(); 
00232   inline void reset_loc_scale() {loc_ = -1; scale_ = -1;}
00233 
00234   /* cut off of file size for cache validation */
00235   static const int FSIZE_CACHE_CUTOFF; 
00236 
00237 private:
00238   double loc_;
00239   double scale_;
00240 
00241   /* fsize for non-cache validation flow */
00242   static const double M_LOC;        /* mean of location */
00243   static const double V_LOC;        /* variance of location */
00244   static const double SHAPE_SCALE2; /* Gamma shape parameter of scale^2*/
00245   static const double RATE_SCALE2;  /* Gamma rate parameter of scale^2 */
00246   static const double V_ERROR;      /* variance of error */
00247 };
00248 
00249 /*:::::::::::::::::::::: PackMimeHTTP Persistent RanVar ::::::::::::::::::::*/
00250 
00251 class PackMimeHTTPPersistentRandomVariable : public RandomVariable {
00252 public:
00253   virtual double value();
00254   virtual double avg() {return 0;}
00255   PackMimeHTTPPersistentRandomVariable();
00256   PackMimeHTTPPersistentRandomVariable(double prob);  
00257   PackMimeHTTPPersistentRandomVariable(double prob, RNG* rng);  
00258 
00259   static const double P_PERSISTENT;   /* P(persistent=1) */
00260 
00261 private:
00262   double probability_;    // probability that the connection is persistent
00263 
00264 };
00265 
00266 /*:::::::::::::::::::::: PackMimeHTTP NumPages RanVar ::::::::::::::::::::::*/
00267 
00268 class PackMimeHTTPNumPagesRandomVariable : public RandomVariable {
00269 public:
00270   virtual double value();
00271   virtual double avg() {return 0;}
00272   PackMimeHTTPNumPagesRandomVariable();
00273   PackMimeHTTPNumPagesRandomVariable(double prob, double shape, double scale);
00274   PackMimeHTTPNumPagesRandomVariable(double prob, double shape, double scale, 
00275                                      RNG* rng);  
00276 
00277   static const double P_1PAGE;       /* P(num reqs=1) */
00278   static const double SHAPE_NPAGE;   /* shape param for (#page reqs-1)*/
00279   static const double SCALE_NPAGE;   /* scale param for (#page reqs-1) */
00280 
00281 private:
00282   double probability_;  // probability that the connection has just one page
00283   double shape_;        // shape of Weibull for number of pages in connection
00284   double scale_;        // scale of Weibull for number of pages in connection
00285 };
00286 
00287 /*:::::::::::::::::::::: PackMimeHTTP SingleObj RanVar :::::::::::::::::::::*/
00288 
00289 class PackMimeHTTPSingleObjRandomVariable : public RandomVariable {
00290 public:
00291   virtual double value();
00292   virtual double avg() {return 0;}
00293   PackMimeHTTPSingleObjRandomVariable();
00294   PackMimeHTTPSingleObjRandomVariable(double prob);
00295   PackMimeHTTPSingleObjRandomVariable(double prob, RNG* rng);  
00296 
00297   static const double P_1TRANSFER; /* P(#xfers=1 | #page req>=2) */
00298 
00299 private:
00300   double probability_;    // probability that the num of objs is 1
00301 };
00302 
00303 /*:::::::::::::::::::::: PackMimeHTTP ObjsPerPage RanVar :::::::::::::::::::*/
00304 
00305 class PackMimeHTTPObjsPerPageRandomVariable : public RandomVariable {
00306 public:
00307   virtual double value();
00308   virtual double avg() {return 0;}
00309   PackMimeHTTPObjsPerPageRandomVariable();
00310   PackMimeHTTPObjsPerPageRandomVariable(double shape, double scale);
00311   PackMimeHTTPObjsPerPageRandomVariable(double shape, double scale, RNG* rng);
00312   static const double SHAPE_NTRANSFER; /* shape param for (#xfers-1)*/
00313   static const double SCALE_NTRANSFER; /* scale param for (#xfers-1) 1.578 */
00314 
00315 private:
00316   double shape_;          // shape of Weibull for number of objs in page
00317   double scale_;          // scale of Weibull for number of objs in page
00318 };
00319 
00320 /*:::::::::::::::::::::: PackMimeHTTP TimeBtwnPages RanVar :::::::::::::::::*/
00321 
00322 class PackMimeHTTPTimeBtwnPagesRandomVariable : public RandomVariable {
00323 public:
00324   virtual double value();
00325   virtual double avg() {return 0;}
00326   PackMimeHTTPTimeBtwnPagesRandomVariable();
00327   PackMimeHTTPTimeBtwnPagesRandomVariable(RNG* rng);
00328 
00329   /* time gap between page requests */
00330   static const double M_LOC_B;        /* mean of location */
00331   static const double V_LOC_B;        /* variance of location */
00332   static const double SHAPE_SCALE2_B; /* Gamma shape param of scale^2*/
00333   static const double RATE_SCALE2_B;  /* Gamma rate param of scale^2 */
00334   static const double V_ERROR_B;      /* variance of error */
00335 
00336 private:
00337   double loc_b_;
00338   double scale2_b_;
00339 };
00340 
00341 /*:::::::::::::::::::::: PackMimeHTTP TimeBtwnObjs RanVar ::::::::::::::::::*/
00342 
00343 class PackMimeHTTPTimeBtwnObjsRandomVariable : public RandomVariable {
00344 public:
00345   virtual double value();
00346   virtual double avg() {return 0;}
00347   PackMimeHTTPTimeBtwnObjsRandomVariable();
00348   PackMimeHTTPTimeBtwnObjsRandomVariable(RNG* rng);
00349 
00350   /* time gap within page requests */
00351   static const double M_LOC_W;        /* mean of location */
00352   static const double V_LOC_W;        /* variance of location */
00353   static const double SHAPE_SCALE2_W; /* Gamma shape param of scale^2*/
00354   static const double RATE_SCALE2_W;  /* Gamma rate param of scale^2 */
00355   static const double V_ERROR_W;      /* variance of error */
00356 
00357 private:
00358   double loc_w_;
00359   double scale2_w_;
00360 };
00361 
00362 /*:::::::::::::::::::::: PackMimeHTTP ServerDelay RanVar :::::::::::::::::::*/
00363 
00364 class PackMimeHTTPServerDelayRandomVariable : public RandomVariable {
00365 public:
00366   virtual double value();
00367   virtual double avg() {return 0;}
00368   PackMimeHTTPServerDelayRandomVariable();
00369   PackMimeHTTPServerDelayRandomVariable(double shape, double scale);
00370   PackMimeHTTPServerDelayRandomVariable(double shape, double scale, RNG* rng);
00371   static const double SERVER_DELAY_SHAPE;
00372   static const double SERVER_DELAY_SCALE;
00373   static const double SERVER_DELAY_DIV;
00374 
00375 private:
00376   double shape_; 
00377   double scale_; 
00378   double const_;
00379   double mean_;
00380 };
00381 
00382 #endif

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