Alex Bikfalvi
SimStream Documentation
SimulatorPushMulti.cpp
00001 #include "Headers.h" 00002 #include "SimulatorPushMulti.h" 00003 #include "Sim.h" 00004 #include "ModelPushMulti.h" 00005 #include "TopoBrite.h" 00006 #include "ModelChannelFlat2Cat.h" 00007 00008 #pragma warning(disable : 4996) 00009 00010 void CSimulatorPushMulti::Run(char* simName, int argc, char* argv[]) 00011 { 00012 printf("\n\nSimulator: PUSH MULTI (v. %s %s)\n", __DATE__, __TIME__); 00013 00014 if(argc < 10) 00015 { 00016 printf("\nSyntax is:\ 00017 \n\t1 - Input configuration file\ 00018 \n\t2 - Output name\ 00019 \n\t3 - Maximum time\ 00020 \n\t4 - Min multicast channels\ 00021 \n\t5 - Max multicast channels\ 00022 \n\t6 - Inc multicast channels\ 00023 \n\t7 - Number of layers\ 00024 \n\t8 - Number of minimum layers\ 00025 \n\t9 - Topology number(s)\ 00026 \n"); 00027 return; 00028 } 00029 00030 // Read input file 00031 char* fileInput = argv[1]; 00032 00033 FILE* fin; 00034 00035 if(FILE_OPEN(fin, fileInput, "r")) { printf("\nCannot open configuration file: %s\n", fileInput); return; } 00036 00037 char* name = argv[2]; 00038 __time maxTime = atof(argv[3]); 00039 char topoName[1024]; 00040 char topoFile[1024]; 00041 __uint32 topoNums = argc - 9; 00042 __uint32 numHosts; 00043 __uint32 numGateways; 00044 __uint32 bwAccessBins; 00045 __bitrate* bwAccessUpLink; 00046 __bitrate* bwAccessDownLink; 00047 double* bwAccessRatio; 00048 __time delayAccessUpLink; 00049 __time delayAccessDownLink; 00050 __bitrate bwServerUpLink; 00051 __bitrate bwServerDownLink; 00052 __time delayServerUpLink; 00053 __time delayServerDownLink; 00054 __uint32 queueLink; 00055 __uint32 queueLinkServer; 00056 __uint32 numChannels; 00057 __uint32 numChannelsMcastMin = atoi(argv[4]); 00058 __uint32 numChannelsMcastMax = atoi(argv[5]); 00059 __uint32 numChannelsMcastInc = atoi(argv[6]); 00060 __uint32 numLayers = atoi(argv[7]); 00061 __uint32 numLayersMin = atoi(argv[8]); 00062 __bitrate channelBw; 00063 __uint32 channelFps; 00064 __uint32 mpegGopDistanceItoI; 00065 __uint32 mpegGopDistanceItoP; 00066 __uint32 numPopular; 00067 double probPopular; 00068 __uint32 streamBufferMcastSize; 00069 __uint32 streamBufferMcastSizeHistory; 00070 __uint32 streamBufferMcastSizeBuffering; 00071 __uint32 streamBufferUcastSize; 00072 __uint32 streamBufferUcastSizeHistory; 00073 __uint32 streamBufferUcastSizeBuffering; 00074 __time streamBufferUnderrunTimeout; 00075 double streamBwMargin; 00076 __uint32 bootQueryMax; 00077 __uint32 bootRefreshThreshold; 00078 __time bootQueryTimeout; 00079 __time bootRegisterDelay; 00080 00081 fscanf(fin, "numHosts = %u\n", &numHosts); 00082 fscanf(fin, "numGateways = %u\n", &numGateways); 00083 fscanf(fin, "topoName = %s\n", topoName); 00084 fscanf(fin, "numChannels = %u\n", &numChannels); 00085 fscanf(fin, "bwAccessBins = %u", &bwAccessBins); 00086 00087 bwAccessUpLink = new __bitrate[bwAccessBins]; 00088 bwAccessDownLink = new __bitrate[bwAccessBins]; 00089 bwAccessRatio = new __bitrate[bwAccessBins]; 00090 00091 fscanf(fin, "\nbwAccessUpLink = "); 00092 for(__uint32 index = 0; index < bwAccessBins; index++) 00093 fscanf(fin, "%lf", &bwAccessUpLink[index]); 00094 fscanf(fin, "\nbwAccessDownLink = "); 00095 for(__uint32 index = 0; index < bwAccessBins; index++) 00096 fscanf(fin, "%lf", &bwAccessDownLink[index]); 00097 fscanf(fin, "\nbwAccessRatio = "); 00098 for(__uint32 index = 0; index < bwAccessBins; index++) 00099 fscanf(fin, "%lf", &bwAccessRatio[index]); 00100 fscanf(fin, "\ndelayAccessUpLink = %lf\n", &delayAccessUpLink); 00101 fscanf(fin, "delayAccessDownLink = %lf\n", &delayAccessDownLink); 00102 fscanf(fin, "bwServerUpLink = %lf\n", &bwServerUpLink); 00103 fscanf(fin, "bwServerDownLink = %lf\n", &bwServerDownLink); 00104 fscanf(fin, "delayServerUpLink = %lf\n", &delayServerUpLink); 00105 fscanf(fin, "delayServerDownLink = %lf\n", &delayServerDownLink); 00106 fscanf(fin, "queueLink = %u\n", &queueLink); 00107 fscanf(fin, "queueLinkServer = %u\n", &queueLinkServer); 00108 fscanf(fin, "channelBw = %lf\n", &channelBw); 00109 fscanf(fin, "channelFps = %u\n", &channelFps); 00110 fscanf(fin, "mpegGopDistanceItoI = %u\n", &mpegGopDistanceItoI); 00111 fscanf(fin, "mpegGopDistanceItoP = %u\n", &mpegGopDistanceItoP); 00112 fscanf(fin, "numPopular = %u\n", &numPopular); 00113 fscanf(fin, "probPopular = %lf\n", &probPopular); 00114 fscanf(fin, "streamBufferMcastSize = %u\n", &streamBufferMcastSize); 00115 fscanf(fin, "streamBufferMcastSizeHistory = %u\n", &streamBufferMcastSizeHistory); 00116 fscanf(fin, "streamBufferMcastSizeBuffering = %u\n", &streamBufferMcastSizeBuffering); 00117 fscanf(fin, "streamBufferUcastSize = %u\n", &streamBufferUcastSize); 00118 fscanf(fin, "streamBufferUcastSizeHistory = %u\n", &streamBufferUcastSizeHistory); 00119 fscanf(fin, "streamBufferUcastSizeBuffering = %u\n", &streamBufferUcastSizeBuffering); 00120 fscanf(fin, "streamBufferUnderrunTimeout = %lf\n", &streamBufferUnderrunTimeout); 00121 fscanf(fin, "streamBwMargin = %lf\n", &streamBwMargin); 00122 fscanf(fin, "bootQueryMax = %u\n", &bootQueryMax); 00123 fscanf(fin, "bootRefreshThreshold = %u\n", &bootRefreshThreshold); 00124 fscanf(fin, "bootQueryTimeout = %lf\n", &bootQueryTimeout); 00125 fscanf(fin, "bootRegisterDelay = %lf\n", &bootRegisterDelay); 00126 00127 fclose(fin); 00128 00129 for(__uint32 topoIndex = 0; topoIndex < topoNums; topoIndex++) 00130 { 00131 // Get the topology number 00132 __uint32 topoNum = atoi(argv[9 + topoIndex]); 00133 00134 // Generate topology file 00135 sprintf(topoFile, "%s-%02u.brite", topoName, topoNum); 00136 00137 printf("\nInput parameters are:\ 00138 \n\t 1 - Maximum time = %.0lf\ 00139 \n\t 2 - Hosts = %u\ 00140 \n\t 3 - Gateways = %u\ 00141 \n\t 4 - Topology name = %s\ 00142 \n\t 5 - Topology file = %s\ 00143 \n\t 6 - Topology number = %u\ 00144 \n\t 7 - Access bins = %u\ 00145 ", 00146 maxTime, 00147 numHosts, 00148 numGateways, 00149 topoName, 00150 topoFile, 00151 topoNum, 00152 bwAccessBins); 00153 00154 printf("\n\t 8 - Bandwidth access uplink = "); 00155 for(__uint32 index = 0; index < bwAccessBins; index++) 00156 printf("%.0lf ", bwAccessUpLink[index]); 00157 printf("\n\t 9 - Bandwidth access downlink = "); 00158 for(__uint32 index = 0; index < bwAccessBins; index++) 00159 printf("%.0lf ", bwAccessDownLink[index]); 00160 printf("\n\t10 - Bandwidth access ratio = "); 00161 for(__uint32 index = 0; index < bwAccessBins; index++) 00162 printf("%.3lf ", bwAccessRatio[index]); 00163 00164 printf("\ 00165 \n\t11 - Delay access uplink = %.3lf\ 00166 \n\t12 - Delay access downlink = %.3lf\ 00167 \n\t13 - Bandwidth server uplink = %.0lf\ 00168 \n\t14 - Bandwidth server downlink = %.0lf\ 00169 \n\t15 - Delay server uplink = %.3lf\ 00170 \n\t16 - Delay server downlink = %.3lf\ 00171 \n\t17 - Queue link = %u\ 00172 \n\t18 - Queue link server = %u\ 00173 \n\t19 - Count channels = %u\ 00174 \n\t20 - Count channels multicast min = %u\ 00175 \n\t21 - Count channels multicast max = %u\ 00176 \n\t22 - Count channels multicast inc = %u\ 00177 \n\t23 - Count layers = %u\ 00178 \n\t24 - Count minimum layers = %u\ 00179 \n\t25 - Channel bit rate = %.0lf\ 00180 \n\t26 - Channel FPS = %u\ 00181 \n\t27 - MPEG I-to-T distance = %u\ 00182 \n\t28 - MPEG I-to-P distance = %u\ 00183 \n\t29 - Popular channels = %u\ 00184 \n\t30 - Popular probability = %.2lf\ 00185 \n\t31 - Buffer size (unicast) = %u\ 00186 \n\t32 - Buffer history (unicast) = %u\ 00187 \n\t33 - Buffering size (unicast) = %u\ 00188 \n\t34 - Buffer size (multicast) = %u\ 00189 \n\t35 - Buffer history (multicast) = %u\ 00190 \n\t36 - Buffering size (multicast) = %u\ 00191 \n\t37 - Buffer underrun timeout = %lf\ 00192 \n\t38 - Bandwidth margin = %lf\ 00193 \n\t39 - Boot query maximum size = %u\ 00194 \n\t40 - Boot refresh threshold = %u\ 00195 \n\t41 - Boot query timeout = %lf\ 00196 \n\t42 - Boot register delay = %lf\ 00197 \n\n", 00198 delayAccessUpLink, 00199 delayAccessDownLink, 00200 bwServerUpLink, 00201 bwServerDownLink, 00202 delayServerUpLink, 00203 delayServerDownLink, 00204 queueLink, 00205 queueLinkServer, 00206 numChannels, 00207 numChannelsMcastMin, 00208 numChannelsMcastMax, 00209 numChannelsMcastInc, 00210 numLayers, 00211 numLayersMin, 00212 channelBw, 00213 channelFps, 00214 mpegGopDistanceItoI, 00215 mpegGopDistanceItoP, 00216 numPopular, 00217 probPopular, 00218 streamBufferMcastSize, 00219 streamBufferMcastSizeHistory, 00220 streamBufferMcastSizeBuffering, 00221 streamBufferUcastSize, 00222 streamBufferUcastSizeHistory, 00223 streamBufferUcastSizeBuffering, 00224 streamBufferUnderrunTimeout, 00225 streamBwMargin, 00226 bootQueryMax, 00227 bootRefreshThreshold, 00228 bootQueryTimeout, 00229 bootRegisterDelay 00230 ); 00231 00232 CTopo* topology = new CTopoBrite( 00233 topoFile 00234 ); 00235 00236 for(__uint32 numChannelsMcast = numChannelsMcastMin; numChannelsMcast <= numChannelsMcastMax; numChannelsMcast += numChannelsMcastInc) 00237 { 00238 if(numChannelsMcast > numChannels) continue; 00239 00240 __uint32 numChannelsUcast = numChannels - numChannelsMcast; 00241 00242 char currentSimName[100]; 00243 sprintf(currentSimName, "[%s / %3u]", simName, numChannelsMcast); 00244 00245 printf("\n\n%s : Multicast: %u Unicast: %u\n", currentSimName, numChannelsMcast, numChannelsUcast); 00246 00247 CModelChannel* modelChannel = new CModelChannelFlat2Cat( 00248 numChannelsMcast + numChannelsUcast, 00249 numPopular, 00250 probPopular); 00251 00252 CModel* model = new CModelPushMulti( 00253 name, 00254 maxTime, 00255 topology, 00256 topoNum, 00257 modelChannel, 00258 numHosts, 00259 numGateways, 00260 bwAccessBins, 00261 bwAccessUpLink, 00262 bwAccessDownLink, 00263 bwAccessRatio, 00264 delayAccessUpLink, 00265 delayAccessDownLink, 00266 bwServerUpLink, 00267 bwServerDownLink, 00268 delayServerUpLink, 00269 delayServerDownLink, 00270 queueLink, 00271 queueLinkServer, 00272 numChannelsMcast, 00273 numChannelsUcast, 00274 numLayers, 00275 numLayersMin, 00276 channelBw, 00277 channelFps, 00278 mpegGopDistanceItoI, 00279 mpegGopDistanceItoP, 00280 streamBufferMcastSize, 00281 streamBufferMcastSizeHistory, 00282 streamBufferMcastSizeBuffering, 00283 streamBufferUcastSize, 00284 streamBufferUcastSizeHistory, 00285 streamBufferUcastSizeBuffering, 00286 streamBufferUnderrunTimeout, 00287 streamBwMargin, 00288 bootQueryMax, 00289 bootRefreshThreshold, 00290 bootQueryTimeout, 00291 bootRegisterDelay 00292 ); 00293 CSim* sim = new CSim(currentSimName, model); 00294 00295 time_t duration = 0; 00296 00297 sim->Run(duration); 00298 00299 printf("\n%s : Simulation finished in %lu seconds.", currentSimName, duration); 00300 00301 delete sim; 00302 delete model; 00303 delete modelChannel; 00304 } 00305 00306 delete topology; 00307 } 00308 00309 delete[] bwAccessUpLink; 00310 delete[] bwAccessDownLink; 00311 delete[] bwAccessRatio; 00312 } 00313
Last updated: February 8, 2011