Alex Bikfalvi
SimStream Documentation
SimulatorNetMcast.cpp
00001 #include "Headers.h" 00002 #include "SimulatorNetMcast.h" 00003 #include "TopoBrite.h" 00004 #include "MulticastTree.h" 00005 #include "Shuffle.h" 00006 #include "Rand.h" 00007 00008 #pragma warning(disable : 4996) 00009 00010 void CSimulatorNetMcast::Run(char* simName, int argc, char* argv[]) 00011 { 00012 printf("\n\nSimulator: NETWORK MULTICAST (v. %s %s) (%s)\n", __DATE__, __TIME__, simName); 00013 00014 if(argc != 11) 00015 { 00016 printf("\nSyntax is:\ 00017 \n\t 1 - Topology name\ 00018 \n\t 2 - Output file\ 00019 \n\t 3 - Count edge nodes min\ 00020 \n\t 4 - Count edge nodes max\ 00021 \n\t 5 - Group size min\ 00022 \n\t 6 - Group size max\ 00023 \n\t 7 - Count trials edge nodes per topology\ 00024 \n\t 8 - Count trials groups per edge nodes set\ 00025 \n\t 9 - Min topology\ 00026 \n\t10 - Max topology\ 00027 \n"); 00028 return; 00029 } 00030 00031 // Input parameters 00032 char* name = argv[1]; 00033 char* outName = argv[2]; 00034 __uint32 numEdgeNodesMin = atoi(argv[3]); 00035 __uint32 numEdgeNodesMax = atoi(argv[4]); 00036 __uint32 groupMin = atoi(argv[5]); 00037 __uint32 groupMax = atoi(argv[6]); 00038 __uint32 numTrialsEdge = atoi(argv[7]); 00039 __uint32 numTrialsGroups = atoi(argv[8]); 00040 __uint32 minTopo = atoi(argv[9]); 00041 __uint32 maxTopo = atoi(argv[10]); 00042 00043 printf("\nInput parameters are:\ 00044 \n\t 1 - Topology name : %s\ 00045 \n\t 2 - Output file : %s\ 00046 \n\t 3 - Count edge nodes min : %u\ 00047 \n\t 4 - Count edge nodes max : %u\ 00048 \n\t 5 - Group size min : %u\ 00049 \n\t 6 - Group size max : %u\ 00050 \n\t 7 - Count trials edge nodes per topology : %u\ 00051 \n\t 8 - Count trials groups per edge nodes set : %u\ 00052 \n\t 9 - Min topology : %u\ 00053 \n\t10 - Max topology : %u\ 00054 \n\n", 00055 name, 00056 outName, 00057 numEdgeNodesMin, 00058 numEdgeNodesMax, 00059 groupMin, 00060 groupMax, 00061 numTrialsEdge, 00062 numTrialsGroups, 00063 minTopo, 00064 maxTopo); 00065 00066 assert(groupMin < groupMax); 00067 00068 char topoFile[1024]; 00069 __uint32 groups = groupMax - groupMin + 1; 00070 00071 FILE* out = fopen(outName, "w"); 00072 if(NULL == out) printf("\n\nCannot open file %s.", outName); 00073 00074 // For each network topology 00075 for(__uint32 topo = minTopo; topo <= maxTopo; topo++) 00076 { 00077 // Generate topology file 00078 sprintf(topoFile, "%s-%02u.brite", name, topo); 00079 00080 // Create topology 00081 CTopo* topology = new CTopoBrite(topoFile); 00082 00083 // Create a multicast tree for the current topology 00084 CMulticastTree* tree = new CMulticastTree(topology, 0, 0); 00085 00086 // For each number of edge nodes 00087 for(__uint32 nodes = numEdgeNodesMin; nodes <= numEdgeNodesMax; nodes++) 00088 { 00089 assert(nodes <= topology->Nodes()); 00090 00091 // For each random set of edge nodes 00092 for(__uint32 trialEdge = 0; trialEdge < numTrialsEdge; trialEdge++) 00093 { 00094 // Generate random edge nodes 00095 CShuffle shuffleEdge(topology->Nodes()); 00096 00097 // For each group trial 00098 for(__uint32 trialGroup = 0; trialGroup < numTrialsGroups; trialGroup++) 00099 { 00100 fprintf(out, "%u %u %u %u ", topo, nodes, trialEdge, trialGroup); 00101 00102 printf("\nTopology : %s0-%02u Nodes : %u Edge set : %u Group set : %u", name, topo, nodes, trialEdge, trialGroup); 00103 00104 // For each group size 00105 for(__uint32 group = groupMin; group <= groupMax; group++) 00106 { 00107 // Clear the tree 00108 tree->Clear(); 00109 00110 // For each host 00111 for(__uint32 index = 0; index < group; index++) 00112 { 00113 // Add host to a random edge node 00114 tree->Add(0, index, shuffleEdge[CRand::Generate(nodes-1)]); 00115 } 00116 00117 fprintf(out, "%u ", tree->SizeCoreLast()); 00118 } 00119 00120 fprintf(out, "\n"); 00121 } 00122 } 00123 } 00124 00125 delete tree; 00126 00127 delete topology; 00128 } 00129 00130 fclose(out); 00131 }
Last updated: February 8, 2011