Alex Bikfalvi
SimStream Documentation
SimulatorSelect.cpp
00001 #include "Headers.h" 00002 #include "SimulatorPushSelect.h" 00003 #include "Sim.h" 00004 #include "ModelPush.h" 00005 #include "TopoBrite.h" 00006 #include "ModelChannelFlat2Cat.h" 00007 00008 #pragma warning(disable : 4996) 00009 00010 void CSimulatorPushSelect::Run(char* simName, int argc, char* argv[]) 00011 { 00012 printf("\n\nSimulator: PUSH SELECT (v. %s %s) (%s)\n", __DATE__, __TIME__, simName); 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 streamBufferSize; 00065 __uint32 streamBufferSizeHistory; 00066 __uint32 streamBufferSizeBuffering; 00067 __time streamBufferUnderrunTimeout; 00068 double streamBwMargin; 00069 __uint32 bootQueryMax; 00070 __uint32 bootRefreshThreshold; 00071 __time bootQueryTimeout; 00072 __time bootRegisterDelay; 00073 00074 fscanf(fin, "numHosts = %u\n", &numHosts); 00075 fscanf(fin, "numGateways = %u\n", &numGateways); 00076 fscanf(fin, "topoName = %s\n", topoName); 00077 fscanf(fin, "numChannels = %u\n", &numChannels); 00078 fscanf(fin, "bwAccessBins = %u", &bwAccessBins); 00079 00080 bwAccessUpLink = new __bitrate[bwAccessBins]; 00081 bwAccessDownLink = new __bitrate[bwAccessBins]; 00082 bwAccessRatio = new __bitrate[bwAccessBins]; 00083 00084 fscanf(fin, "\nbwAccessUpLink = "); 00085 for(__uint32 index = 0; index < bwAccessBins; index++) 00086 fscanf(fin, "%lf", &bwAccessUpLink[index]); 00087 fscanf(fin, "\nbwAccessDownLink = "); 00088 for(__uint32 index = 0; index < bwAccessBins; index++) 00089 fscanf(fin, "%lf", &bwAccessDownLink[index]); 00090 fscanf(fin, "\nbwAccessRatio = "); 00091 for(__uint32 index = 0; index < bwAccessBins; index++) 00092 fscanf(fin, "%lf", &bwAccessRatio[index]); 00093 fscanf(fin, "\ndelayAccessUpLink = %lf\n", &delayAccessUpLink); 00094 fscanf(fin, "delayAccessDownLink = %lf\n", &delayAccessDownLink); 00095 fscanf(fin, "bwServerUpLink = %lf\n", &bwServerUpLink); 00096 fscanf(fin, "bwServerDownLink = %lf\n", &bwServerDownLink); 00097 fscanf(fin, "delayServerUpLink = %lf\n", &delayServerUpLink); 00098 fscanf(fin, "delayServerDownLink = %lf\n", &delayServerDownLink); 00099 fscanf(fin, "queueLink = %u\n", &queueLink); 00100 fscanf(fin, "queueLinkServer = %u\n", &queueLinkServer); 00101 fscanf(fin, "channelBw = %lf\n", &channelBw); 00102 fscanf(fin, "channelFps = %u\n", &channelFps); 00103 fscanf(fin, "mpegGopDistanceItoI = %u\n", &mpegGopDistanceItoI); 00104 fscanf(fin, "mpegGopDistanceItoP = %u\n", &mpegGopDistanceItoP); 00105 fscanf(fin, "numPopular = %u\n", &numPopular); 00106 fscanf(fin, "probPopular = %lf\n", &probPopular); 00107 fscanf(fin, "streamBufferSize = %u\n", &streamBufferSize); 00108 fscanf(fin, "streamBufferSizeHistory = %u\n", &streamBufferSizeHistory); 00109 fscanf(fin, "streamBufferSizeBuffering = %u\n", &streamBufferSizeBuffering); 00110 fscanf(fin, "streamBufferUnderrunTimeout = %lf\n", &streamBufferUnderrunTimeout); 00111 fscanf(fin, "streamBwMargin = %lf\n", &streamBwMargin); 00112 fscanf(fin, "bootQueryMax = %u\n", &bootQueryMax); 00113 fscanf(fin, "bootRefreshThreshold = %u\n", &bootRefreshThreshold); 00114 fscanf(fin, "bootQueryTimeout = %lf\n", &bootQueryTimeout); 00115 fscanf(fin, "bootRegisterDelay = %lf\n", &bootRegisterDelay); 00116 00117 fclose(fin); 00118 00119 for(__uint32 topoIndex = 0; topoIndex < topoNums; topoIndex++) 00120 { 00121 // Get the topology number 00122 __uint32 topoNum = atoi(argv[7 + topoIndex]); 00123 00124 // Generate topology file 00125 sprintf(topoFile, "%s-%02u.brite", topoName, topoNum); 00126 00127 printf("\nInput parameters are:\ 00128 \n\t 1 - Maximum time = %.0lf\ 00129 \n\t 2 - Hosts = %u\ 00130 \n\t 3 - Gateways = %u\ 00131 \n\t 4 - Topology name = %s\ 00132 \n\t 5 - Topology file = %s\ 00133 \n\t 6 - Topology number = %u\ 00134 \n\t 7 - Access bins = %u\ 00135 ", 00136 maxTime, 00137 numHosts, 00138 numGateways, 00139 topoName, 00140 topoFile, 00141 topoNum, 00142 bwAccessBins); 00143 00144 printf("\n\t 8 - Bandwidth access uplink = "); 00145 for(__uint32 index = 0; index < bwAccessBins; index++) 00146 printf("%.0lf ", bwAccessUpLink[index]); 00147 printf("\n\t 9 - Bandwidth access downlink = "); 00148 for(__uint32 index = 0; index < bwAccessBins; index++) 00149 printf("%.0lf ", bwAccessDownLink[index]); 00150 printf("\n\t10 - Bandwidth access ratio = "); 00151 for(__uint32 index = 0; index < bwAccessBins; index++) 00152 printf("%.3lf ", bwAccessRatio[index]); 00153 00154 printf("\ 00155 \n\t11 - Delay access uplink = %.3lf\ 00156 \n\t12 - Delay access downlink = %.3lf\ 00157 \n\t13 - Bandwidth server uplink = %.0lf\ 00158 \n\t14 - Bandwidth server downlink = %.0lf\ 00159 \n\t15 - Delay server uplink = %.3lf\ 00160 \n\t16 - Delay server downlink = %.3lf\ 00161 \n\t17 - Queue link = %u\ 00162 \n\t18 - Queue link server = %u\ 00163 \n\t19 - Count channels = %u\ 00164 \n\t20 - Count channels multicast min = %u\ 00165 \n\t21 - Count channels multicast max = %u\ 00166 \n\t22 - Count channels multicast inc = %u\ 00167 \n\t23 - Channel bit rate = %.0lf\ 00168 \n\t24 - Channel FPS = %u\ 00169 \n\t25 - MPEG I-to-T distance = %u\ 00170 \n\t26 - MPEG I-to-P distance = %u\ 00171 \n\t27 - Popular channels = %u\ 00172 \n\t28 - Popular probability = %.2lf\ 00173 \n\t29 - Buffer size = %u\ 00174 \n\t30 - Buffer history = %u\ 00175 \n\t31 - Buffering size = %u\ 00176 \n\t32 - Buffer underrun timeout = %lf\ 00177 \n\t33 - Bandwidth margin = %lf\ 00178 \n\t34 - Boot query maximum size = %u\ 00179 \n\t35 - Boot refresh threshold = %u\ 00180 \n\t36 - Boot query timeout = %lf\ 00181 \n\t37 - Boot register delay = %lf\ 00182 \n\n", 00183 delayAccessUpLink, 00184 delayAccessDownLink, 00185 bwServerUpLink, 00186 bwServerDownLink, 00187 delayServerUpLink, 00188 delayServerDownLink, 00189 queueLink, 00190 queueLinkServer, 00191 numChannels, 00192 numChannelsMcastMin, 00193 numChannelsMcastMax, 00194 numChannelsMcastInc, 00195 channelBw, 00196 channelFps, 00197 mpegGopDistanceItoI, 00198 mpegGopDistanceItoP, 00199 numPopular, 00200 probPopular, 00201 streamBufferSize, 00202 streamBufferSizeHistory, 00203 streamBufferSizeBuffering, 00204 streamBufferUnderrunTimeout, 00205 streamBwMargin, 00206 bootQueryMax, 00207 bootRefreshThreshold, 00208 bootQueryTimeout, 00209 bootRegisterDelay 00210 ); 00211 00212 CTopo* topology = new CTopoBrite( 00213 topoFile 00214 ); 00215 00216 for(__uint32 numChannelsMcast = numChannelsMcastMin; numChannelsMcast <= numChannelsMcastMax; numChannelsMcast += numChannelsMcastInc) 00217 { 00218 if(numChannelsMcast > numChannels) continue; 00219 00220 __uint32 numChannelsUcast = numChannels - numChannelsMcast; 00221 00222 char currentSimName[100]; 00223 sprintf(currentSimName, "[%s / %3u]", simName, numChannelsMcast); 00224 00225 printf("\n\n%s : Multicast: %u Unicast: %u\n", currentSimName, numChannelsMcast, numChannelsUcast); 00226 00227 CModelChannel* modelChannel = new CModelChannelFlat2Cat( 00228 numChannelsMcast + numChannelsUcast, 00229 numPopular, 00230 probPopular); 00231 00232 CModel* model = new CModelPush( 00233 name, 00234 maxTime, 00235 topology, 00236 topoNum, 00237 modelChannel, 00238 numHosts, 00239 numGateways, 00240 bwAccessBins, 00241 bwAccessUpLink, 00242 bwAccessDownLink, 00243 bwAccessRatio, 00244 delayAccessUpLink, 00245 delayAccessDownLink, 00246 bwServerUpLink, 00247 bwServerDownLink, 00248 delayServerUpLink, 00249 delayServerDownLink, 00250 queueLink, 00251 queueLinkServer, 00252 numChannelsMcast, 00253 numChannelsUcast, 00254 channelBw, 00255 channelFps, 00256 mpegGopDistanceItoI, 00257 mpegGopDistanceItoP, 00258 streamBufferSize, 00259 streamBufferSizeHistory, 00260 streamBufferSizeBuffering, 00261 streamBufferUnderrunTimeout, 00262 streamBwMargin, 00263 bootQueryMax, 00264 bootRefreshThreshold, 00265 bootQueryTimeout, 00266 bootRegisterDelay 00267 ); 00268 CSim* sim = new CSim(currentSimName, model); 00269 00270 time_t duration; 00271 00272 sim->Run(duration); 00273 00274 printf("\n%s : Simulation finished in %ld seconds.", currentSimName, duration); 00275 00276 delete sim; 00277 delete model; 00278 delete modelChannel; 00279 } 00280 00281 delete topology; 00282 } 00283 00284 delete[] bwAccessUpLink; 00285 delete[] bwAccessDownLink; 00286 delete[] bwAccessRatio; 00287 } 00288
Last updated: February 8, 2011