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