Alex Bikfalvi
SimStream Documentation
SimulatorFlow.cpp
00001 #include "Headers.h" 00002 #include "SimulatorFlow.h" 00003 #include "Sim.h" 00004 #include "ModelFlow.h" 00005 #include "TopoBrite.h" 00006 00007 #pragma warning(disable : 4996) 00008 00009 void CSimulatorFlow::Run(char* simName, int argc, char* argv[]) 00010 { 00011 printf("\n\nSimulator: FLOW (v. %s %s) (%s)\n", __DATE__, __TIME__, simName); 00012 00013 if(argc < 3) 00014 { 00015 printf("\nSyntax is:\ 00016 \n\t1 - Input configuration file\ 00017 \n\t2 - Maximum time\ 00018 \n\t3 - Topology number(s)\ 00019 \n"); 00020 return; 00021 } 00022 00023 // Read input file 00024 char* fileInput = argv[1]; 00025 00026 FILE* fin; 00027 00028 if(FILE_OPEN(fin, fileInput, "r")) { printf("\nCannot open configuration file: %s\n", fileInput); return; } 00029 00030 __time maxTime = atof(argv[2]); 00031 char topoName[1024]; 00032 char topoFile[1024]; 00033 __uint32 topoNums = argc - 3; 00034 __uint32 numHosts; 00035 __uint32 numGateways; 00036 __bitrate bwAccessUpLink; 00037 __bitrate bwAccessDownLink; 00038 __time delayAccessUpLink; 00039 __time delayAccessDownLink; 00040 __uint32 queueLink; 00041 00042 fscanf(fin, "numHosts = %u\n", &numHosts); 00043 fscanf(fin, "numGateways = %u\n", &numGateways); 00044 fscanf(fin, "topoName = %s\n", topoName); 00045 fscanf(fin, "bwAccessUpLink = %lf\n", &bwAccessUpLink); 00046 fscanf(fin, "bwAccessDownLink = %lf\n", &bwAccessDownLink); 00047 fscanf(fin, "delayAccessUpLink = %lf\n", &delayAccessUpLink); 00048 fscanf(fin, "delayAccessDownLink = %lf\n", &delayAccessDownLink); 00049 fscanf(fin, "queueLink = %u\n", &queueLink); 00050 00051 fclose(fin); 00052 00053 for(__uint32 topoIndex = 0; topoIndex < topoNums; topoIndex++) 00054 { 00055 // Get the topology number 00056 __uint32 topoNum = atoi(argv[3 + topoIndex]); 00057 00058 // Generate topology file 00059 sprintf(topoFile, "%s-%02u.brite", topoName, topoNum); 00060 00061 printf("\nInput parameters are:\ 00062 \n\t 1 - Maximum time = %.0lf\ 00063 \n\t 2 - Hosts = %u\ 00064 \n\t 3 - Gateways = %u\ 00065 \n\t 4 - Topology name = %s\ 00066 \n\t 5 - Topology file = %s\ 00067 \n\t 6 - Topology number = %u\ 00068 \n\t 7 - Bandwidth access uplink = %.3lf\ 00069 \n\t 7 - Bandwidth access downlink = %.3lf\ 00070 \n\t 8 - Delay access uplink = %.3lf\ 00071 \n\t 9 - Delay access downlink = %.3lf\ 00072 \n\t10 - Queue link = %u\ 00073 \n\n", 00074 maxTime, 00075 numHosts, 00076 numGateways, 00077 topoName, 00078 topoFile, 00079 topoNum, 00080 bwAccessUpLink, 00081 bwAccessDownLink, 00082 delayAccessUpLink, 00083 delayAccessDownLink, 00084 queueLink 00085 ); 00086 00087 CTopo* topology = new CTopoBrite( 00088 topoFile 00089 ); 00090 00091 CModel* model = new CModelFlow( 00092 maxTime, 00093 topology, 00094 topoNum, 00095 numHosts, 00096 numGateways, 00097 bwAccessUpLink, 00098 bwAccessDownLink, 00099 delayAccessUpLink, 00100 delayAccessDownLink, 00101 queueLink 00102 ); 00103 CSim* sim = new CSim(simName, model); 00104 00105 time_t duration; 00106 00107 sim->Run(duration); 00108 00109 printf("\nSimulation finished in %ld seconds.", duration); 00110 00111 delete sim; 00112 delete model; 00113 delete topology; 00114 } 00115 } 00116
Last updated: February 8, 2011