00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
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
00060
00061
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_;
00071 };
00072
00073
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
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
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
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
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
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
00208 static const int FSIZE0_CACHE_CUTOFF;
00209 static const int FSIZE0_STRETCH_THRES;
00210
00211 static const double M_FSIZE0_NOTCACHE;
00212
00213 static const double V_FSIZE0_NOTCACHE;
00214
00215
00216 static const double M_LOC;
00217 static const double V_LOC;
00218 static const double SHAPE_SCALE2;
00219 static const double RATE_SCALE2;
00220 static const double V_ERROR;
00221 };
00222
00223
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
00235 static const int FSIZE_CACHE_CUTOFF;
00236
00237 private:
00238 double loc_;
00239 double scale_;
00240
00241
00242 static const double M_LOC;
00243 static const double V_LOC;
00244 static const double SHAPE_SCALE2;
00245 static const double RATE_SCALE2;
00246 static const double V_ERROR;
00247 };
00248
00249
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;
00260
00261 private:
00262 double probability_;
00263
00264 };
00265
00266
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;
00278 static const double SHAPE_NPAGE;
00279 static const double SCALE_NPAGE;
00280
00281 private:
00282 double probability_;
00283 double shape_;
00284 double scale_;
00285 };
00286
00287
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;
00298
00299 private:
00300 double probability_;
00301 };
00302
00303
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;
00313 static const double SCALE_NTRANSFER;
00314
00315 private:
00316 double shape_;
00317 double scale_;
00318 };
00319
00320
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
00330 static const double M_LOC_B;
00331 static const double V_LOC_B;
00332 static const double SHAPE_SCALE2_B;
00333 static const double RATE_SCALE2_B;
00334 static const double V_ERROR_B;
00335
00336 private:
00337 double loc_b_;
00338 double scale2_b_;
00339 };
00340
00341
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
00351 static const double M_LOC_W;
00352 static const double V_LOC_W;
00353 static const double SHAPE_SCALE2_W;
00354 static const double RATE_SCALE2_W;
00355 static const double V_ERROR_W;
00356
00357 private:
00358 double loc_w_;
00359 double scale2_w_;
00360 };
00361
00362
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