Alex Bikfalvi
SimStream Documentation
ModelPushMulti.cpp
00001 #include "Headers.h" 00002 #include "ModelPushMulti.h" 00003 #include "Shuffle.h" 00004 #include "Rand.h" 00005 00006 #include "EventServerStart.h" 00007 #include "EventClientArrive.h" 00008 #include "EventClientWatch.h" 00009 #include "EventClientLeave.h" 00010 00011 #pragma warning(disable : 4996) 00012 00013 CModelPushMulti::CModelPushMulti( 00014 char* name, 00015 __time maxTime, 00016 CTopo* topology, 00017 __uint32 topologyNumber, 00018 CModelChannel* modelChannel, 00019 __uint32 numHosts, 00020 __uint32 numGateways, 00021 __uint32 bwAccessBins, 00022 __bitrate* bwAccessUpLink, 00023 __bitrate* bwAccessDownLink, 00024 double* bwAccessRatio, 00025 __time delayAccessUpLink, 00026 __time delayAccessDownLink, 00027 __bitrate bwServerUpLink, 00028 __bitrate bwServerDownLink, 00029 __time delayServerUpLink, 00030 __time delayServerDownLink, 00031 __uint32 queueLink, 00032 __uint32 queueLinkServer, 00033 __uint32 numChannelsMcast, 00034 __uint32 numChannelsUcast, 00035 __uint32 numLayers, 00036 __uint32 numLayersMin, 00037 __bitrate channelBw, 00038 __byte channelFps, 00039 __byte mpegGopDistanceItoI, 00040 __byte mpegGopDistanceItoP, 00041 __uint32 streamBufferMcastSize, 00042 __uint32 streamBufferMcastSizeHistory, 00043 __uint32 streamBufferMcastSizeBuffering, 00044 __uint32 streamBufferUcastSize, 00045 __uint32 streamBufferUcastSizeHistory, 00046 __uint32 streamBufferUcastSizeBuffering, 00047 __time streamBufferUnderrunTimeout, 00048 double streamBwMargin, 00049 __uint32 bootQueryMax, 00050 __uint32 bootRefreshThreshold, 00051 __time bootQueryTimeout, 00052 __time bootRegisterDelay 00053 ) : CModel(maxTime, topology) 00054 { 00055 assert(name); 00056 assert(numHosts > 0); 00057 assert(numGateways > 0); 00058 assert(bwAccessBins > 0); 00059 00060 // Simulator 00061 this->name = name; 00062 this->sim = NULL; 00063 this->topology = topology; 00064 this->topologyNumber = topologyNumber; 00065 this->modelChannel = modelChannel; 00066 00067 // Nodes 00068 this->numHosts = numHosts; 00069 this->numServers = 1; 00070 this->numGateways = (numGateways <= this->topology->Nodes())?numGateways:this->topology->Nodes(); 00071 this->bwAccessBins = bwAccessBins; 00072 this->bwAccessUpLink = bwAccessUpLink; 00073 this->bwAccessDownLink = bwAccessDownLink; 00074 this->bwAccessRatio = bwAccessRatio; 00075 this->delayAccessUpLink = delayAccessUpLink; 00076 this->delayAccessDownLink = delayAccessDownLink; 00077 this->bwServerUpLink = bwServerUpLink; 00078 this->bwServerDownLink = bwServerDownLink; 00079 this->delayServerUpLink = delayServerUpLink; 00080 this->delayServerDownLink = delayServerDownLink; 00081 this->queueLink = queueLink; 00082 this->queueLinkServer = queueLinkServer; 00083 00084 this->hosts = NULL; 00085 this->routers = NULL; 00086 this->server = NULL; 00087 this->linksCore = NULL; 00088 this->linksAccess = NULL; 00089 this->linkServer = NULL; 00090 00091 // Channels 00092 this->numChannels = numChannelsUcast + numChannelsMcast; 00093 this->numChannelsUcast = numChannelsUcast; 00094 this->numChannelsMcast = numChannelsMcast; 00095 this->numLayers = numLayers; 00096 this->numLayersMin = numLayersMin; 00097 00098 this->channelBw = channelBw; 00099 this->channelFps = channelFps; 00100 00101 // Stream 00102 this->streamBufferMcastSize = streamBufferMcastSize; 00103 this->streamBufferMcastSizeHistory = streamBufferMcastSizeHistory; 00104 this->streamBufferMcastSizeBuffering = streamBufferMcastSizeBuffering; 00105 this->streamBufferUcastSize = streamBufferUcastSize; 00106 this->streamBufferUcastSizeHistory = streamBufferUcastSizeHistory; 00107 this->streamBufferUcastSizeBuffering = streamBufferUcastSizeBuffering; 00108 this->streamBufferUnderrunTimeout = streamBufferUnderrunTimeout; 00109 this->streamBwMargin = streamBwMargin; 00110 00111 // Stream sources 00112 this->mpegGopDistanceItoI = mpegGopDistanceItoI; 00113 this->mpegGopDistanceItoP = mpegGopDistanceItoP; 00114 00115 // Bootstrap 00116 this->bootQueryMax = bootQueryMax; 00117 this->bootRefreshThreshold = bootRefreshThreshold; 00118 this->bootQueryTimeout = bootQueryTimeout; 00119 this->bootRegisterDelay = bootRegisterDelay; 00120 00121 // Generate gateways 00122 this->gateways = new __uint32[this->numHosts]; 00123 00124 // Generate gateway links (the number of access links for each gateway) 00125 this->routerAccessLinks = new __uint32[this->topology->Nodes()]; 00126 00127 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00128 this->routerAccessLinks[index] = 0; 00129 00130 // Generate gateway for server 00131 this->gatewayServer = CRand::Generate(this->topology->Nodes()); 00132 00133 // Shuffle routers 00134 CShuffle shuffleRouters(this->topology->Nodes()); 00135 00136 // Assign a gateway for each host 00137 for(__uint32 index = 0; index < this->numHosts; index++) 00138 { 00139 __uint32 gw = shuffleRouters[CRand::Generate(this->numGateways)]; 00140 assert(gw < this->topology->Nodes()); 00141 00142 this->gateways[index] = gw; 00143 this->routerAccessLinks[gw]++; 00144 } 00145 00146 // Generate route 00147 this->routeNodes = this->topology->Nodes(); 00148 this->routeDst = this->topology->Nodes() + this->numHosts + this->numServers; 00149 00150 this->route = new int*[this->routeNodes]; 00151 00152 for(__uint32 index = 0; index < this->routeNodes; index++) 00153 { 00154 this->route[index] = new int[this->routeDst]; 00155 } 00156 00157 // Addresses for the multicast RP for each channel 00158 this->mcastRp = new CAddress[this->numChannelsMcast]; 00159 00160 for(__uint32 index = 0; index < this->numChannelsMcast; index++) 00161 this->mcastRp[index] = ROUTER_ADDR(this->gatewayServer); 00162 00163 // Create channels 00164 this->channelsMcast = new CChannel[this->numChannelsMcast]; 00165 00166 for(__uint32 index = 0; index < this->numChannelsMcast; index++) 00167 this->channelsMcast[index] = CChannel(index, CChannel::CHANNEL_MULTICAST, CAddress::Multicast(index), this->channelBw, this->channelFps); 00168 00169 this->channelsUcast = new CChannel[this->numChannelsUcast]; 00170 00171 for(__uint32 index = 0; index < this->numChannelsUcast; index++) 00172 this->channelsUcast[index] = CChannel(index + this->numChannelsMcast, CChannel::CHANNEL_UNICAST, SERVER_ADDR(0), this->channelBw, this->channelFps); 00173 00174 // Create stream sources for all channels 00175 this->streamSources = new CStreamSourceMpeg*[this->numChannels]; 00176 00177 // Create stream sources 00178 for(__uint32 index = 0; index < this->numChannels; index++) 00179 { 00180 this->streamSources[index] = new CStreamSourceMpeg( 00181 this->Channel(index), 00182 mpegGopDistanceItoI, 00183 mpegGopDistanceItoP); 00184 } 00185 00186 // Generate access bandwidth 00187 this->bwAccessHostUpLink = new __bitrate[this->numHosts]; 00188 this->bwAccessHostDownLink = new __bitrate[this->numHosts]; 00189 00190 // Randomize Hosts 00191 CShuffle shuffleHosts(this->numHosts); 00192 00193 __uint32 index = 0; 00194 for(unsigned bin = 0; (bin < this->bwAccessBins) && (index < this->numHosts); bin++) 00195 { 00196 __uint32 binSize = (__uint32)floor(this->bwAccessRatio[bin] * this->numHosts); 00197 for(__uint32 idx = 0; idx < binSize; idx++, index++) 00198 { 00199 this->bwAccessHostUpLink[shuffleHosts[index]] = this->bwAccessUpLink[bin]; 00200 this->bwAccessHostDownLink[shuffleHosts[index]] = this->bwAccessDownLink[bin]; 00201 } 00202 } 00203 00204 // Data 00205 this->data = new CData( 00206 this->name, 00207 this->topologyNumber, 00208 this->numChannelsMcast 00209 ); 00210 } 00211 00212 CModelPushMulti::~CModelPushMulti() 00213 { 00214 // Delete gateways 00215 delete[] this->gateways; 00216 delete[] this->routerAccessLinks; 00217 00218 // Delete routes 00219 for(__uint32 index = 0; index < this->routeNodes; index++) 00220 delete[] this->route[index]; 00221 delete[] this->route; 00222 00223 // Delete multicast RP addresses 00224 delete[] this->mcastRp; 00225 00226 // Delete stream sources 00227 for(__uint32 index = 0; index < this->numChannels; index++) 00228 delete this->streamSources[index]; 00229 delete[] this->streamSources; 00230 00231 // Delete channels 00232 delete[] this->channelsMcast; 00233 delete[] this->channelsUcast; 00234 00235 // Delete access bandwidth 00236 delete[] this->bwAccessHostUpLink; 00237 delete[] this->bwAccessHostDownLink; 00238 00239 // Delete data 00240 delete this->data; 00241 } 00242 00243 void CModelPushMulti::Init(CSimHandler* sim) 00244 { 00245 this->sim = sim; 00246 00247 // Generate hosts 00248 this->hosts = new CHostClientPushMulti*[this->numHosts]; 00249 00250 for(__uint32 index = 0; index < this->numHosts; index++) 00251 { 00252 this->hosts[index] = new CHostClientPushMulti( 00253 HOST_ID(index), 00254 this->sim, 00255 HOST_ADDR(index), 00256 this, 00257 this->data, 00258 this->bwAccessHostUpLink[index] 00259 ); 00260 } 00261 00262 // Generate server 00263 this->server = new CHostServerPushMulti( 00264 SERVER_ID(0), 00265 this->sim, 00266 SERVER_ADDR(0), 00267 this, 00268 this->data); 00269 00270 // Generate routers 00271 this->routers = new CRouter*[this->topology->Nodes()]; 00272 00273 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00274 { 00275 this->routers[index] = new CRouter( 00276 ROUTER_ID(this->topology->Node(index)->Id()), 00277 this->sim, 00278 ROUTER_ADDR(index), 00279 this->topology->Node(index)->Degree() + this->routerAccessLinks[index] + ((index == this->gatewayServer)?1:0), 00280 this, 00281 this, 00282 this->mcastRp 00283 ); 00284 } 00285 00286 // Generate core links 00287 this->linksCore = new CLink*[this->topology->Edges()]; 00288 00289 for(__uint32 index = 0; index < this->topology->Edges(); index++) 00290 { 00291 assert(this->topology->Edge(index)->Nodes()[0] < this->topology->Nodes()); 00292 assert(this->topology->Edge(index)->Nodes()[1] < this->topology->Nodes()); 00293 00294 this->linksCore[index] = new CLink( 00295 LINK_CORE_ID(this->topology->Edge(index)->Id()), 00296 this->sim, 00297 this->queueLink, 00298 this->topology->Edge(index)->Bandwidth(), 00299 this->topology->Edge(index)->Bandwidth(), 00300 this->topology->Edge(index)->Delay(), 00301 this->topology->Edge(index)->Delay()); 00302 } 00303 00304 // Generate access links 00305 this->linksAccess = new CLink*[this->numHosts]; 00306 00307 for(__uint32 index = 0; index < this->numHosts; index++) 00308 { 00309 this->linksAccess[index] = new CLink( 00310 LINK_ACCESS_ID(index), 00311 this->sim, 00312 this->queueLink, 00313 this->bwAccessHostUpLink[index], 00314 this->bwAccessHostDownLink[index], 00315 this->delayAccessUpLink, 00316 this->delayAccessDownLink 00317 ); 00318 } 00319 00320 // Generate server link 00321 this->linkServer = new CLink( 00322 LINK_SERVER_ID(0), 00323 this->sim, 00324 this->queueLinkServer, 00325 this->bwServerUpLink, 00326 this->bwServerDownLink, 00327 this->delayServerUpLink, 00328 this->delayServerDownLink 00329 ); 00330 00331 // Generate node-link mappings 00332 // Generate for routers and core links 00333 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00334 for(__uint32 idx = 0; idx < this->topology->Node(index)->Degree(); idx++) 00335 this->routers[index]->AddLink(this->linksCore[this->topology->Node(index)->Edge(idx)]); 00336 00337 // Generate for hosts, gateway routers and access links 00338 for(__uint32 index = 0; index < this->numHosts; index++) 00339 { 00340 // Add link to the host: entry 0 corresponds to the host (uplink) 00341 this->hosts[index]->AddLink(this->linksAccess[index]); 00342 00343 // Add link to the corresponding gateway: entry 1 corresponds to the router (downlink) 00344 this->routers[this->gateways[index]]->AddLink(this->linksAccess[index]); 00345 } 00346 00347 // Generate for server : add link to server 00348 this->server->AddLink(this->linkServer); 00349 // Generate for server gateway 00350 this->routers[this->gatewayServer]->AddLink(this->linkServer); 00351 00352 // Calculate routes 00353 for(__uint32 node = 0; node < this->routeNodes; node++) 00354 { 00355 // Routes: node to node 00356 for(__uint32 dst = 0; dst < this->routeNodes; dst++) 00357 if(dst == node) this->route[ROUTER_ADDR(node)][ROUTER_ADDR(dst)] = -1; 00358 else this->route[ROUTER_ADDR(node)][ROUTER_ADDR(dst)] = this->routers[node]->LinkIndex(this->linksCore[this->topology->Route()->NextEdge(node, dst)]->Id()); 00359 00360 // Routes: node to host 00361 for(__uint32 host = 0; host < this->numHosts; host++) 00362 { 00363 if(this->gateways[host] == node) 00364 { 00365 // If the node is the gateway of the destination 00366 this->route[ROUTER_ADDR(node)][HOST_ADDR(host)] = this->routers[node]->LinkIndex(this->linksAccess[host]->Id()); 00367 } 00368 else 00369 { 00370 // Else: the route to the gateway 00371 this->route[ROUTER_ADDR(node)][HOST_ADDR(host)] = this->routers[node]->LinkIndex(this->linksCore[this->topology->Route()->NextEdge(node, this->gateways[host])]->Id()); 00372 } 00373 } 00374 00375 // Routes: node to server 00376 if(this->gatewayServer == node) 00377 // If the node is the gateway of the server 00378 this->route[ROUTER_ADDR(node)][SERVER_ADDR(0)] = this->routers[node]->LinkIndex(this->linkServer->Id()); 00379 else 00380 // Else: the route to the server gateway 00381 this->route[ROUTER_ADDR(node)][SERVER_ADDR(0)] = this->routers[node]->LinkIndex(this->linksCore[this->topology->Route()->NextEdge(node, this->gatewayServer)]->Id()); 00382 } 00383 00384 #if _DEBUG_CHECK 00385 // Verify routers 00386 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00387 { 00388 // Check the links 00389 for(__uint32 idx = 0; idx < this->routers[index]->NumLinks(); idx++) 00390 { 00391 CLink* link = this->routers[index]->Link(idx); 00392 __uint32 entry = this->routers[index]->LinkEntry(idx); 00393 00394 assert(link); 00395 assert(link->Node(entry) == this->routers[index]); 00396 assert(link->NodeEntry(entry) == idx); 00397 } 00398 } 00399 // Verify hosts 00400 for(__uint32 index = 0; index < this->numHosts; index++) 00401 { 00402 CLink* link = this->hosts[index]->Link(); 00403 __uint32 entry = this->hosts[index]->LinkEntry(); 00404 00405 assert(link); 00406 assert(link->Node(entry) == this->hosts[index]); 00407 assert(link->NodeEntry(entry) == 0); 00408 } 00409 // Verify core links 00410 for(__uint32 index = 0; index < this->topology->Edges(); index++) 00411 { 00412 for(__uint32 idx = 0; idx < 2; idx++) 00413 { 00414 CRouter* router = type_cast<CRouter*>(this->linksCore[index]->Node(idx)); 00415 __uint32 entry = this->linksCore[index]->NodeEntry(idx); 00416 00417 assert(router); 00418 assert(router->Link(entry) == this->linksCore[index]); 00419 assert(router->LinkEntry(entry) == idx); 00420 } 00421 } 00422 // Verify access links 00423 for(__uint32 index = 0; index < this->numHosts; index++) 00424 { 00425 CHost* host = type_cast<CHost*>(this->linksAccess[index]->Node(0)); 00426 __uint32 entryHost = this->linksAccess[index]->NodeEntry(0); 00427 CRouter* router = type_cast<CRouter*>(this->linksAccess[index]->Node(1)); 00428 __uint32 entryRouter = this->linksAccess[index]->NodeEntry(1); 00429 00430 assert(host); 00431 assert(host->Link() == this->linksAccess[index]); 00432 assert(host->LinkEntry() == 0); 00433 assert(router); 00434 assert(router->Link(entryRouter) == this->linksAccess[index]); 00435 assert(router->LinkEntry(entryRouter) == 1); 00436 } 00437 // Verify routes 00438 // router-to-router 00439 00440 for(__uint32 src = 0; src < this->routeNodes; src++) 00441 for(__uint32 dst = 0; dst < this->routeNodes; dst++) 00442 { 00443 CNode* node = this->routers[src]; 00444 CLink* link; 00445 __uint32 linkEntry; 00446 int index; 00447 00448 while(node != this->routers[dst]) 00449 { 00450 index = this->route[node->Address().Address()][this->routers[dst]->Address().Address()]; 00451 link = type_cast<CRouter*>(node)->Link(index); 00452 linkEntry = type_cast<CRouter*>(node)->LinkEntry(index); 00453 node = type_cast<CNode*>(link->Node(linkEntry ^ 1)); 00454 } 00455 // Check the destination was reached 00456 assert(node == this->routers[dst]); 00457 } 00458 00459 // router-to-hosts 00460 for(__uint32 src = 0; src < this->routeNodes; src++) 00461 for(__uint32 dst = 0; dst < this->numHosts; dst++) 00462 { 00463 CNode* node = this->routers[src]; 00464 CLink* link; 00465 __uint32 linkEntry; 00466 int index; 00467 00468 while(node != this->hosts[dst]) 00469 { 00470 index = this->route[node->Address().Address()][this->hosts[dst]->Address().Address()]; 00471 link = type_cast<CRouter*>(node)->Link(index); 00472 linkEntry = type_cast<CRouter*>(node)->LinkEntry(index); 00473 node = type_cast<CNode*>(link->Node(linkEntry ^ 1)); 00474 } 00475 // Check the destination was reached 00476 assert(node == this->hosts[dst]); 00477 } 00478 #endif 00479 } 00480 00481 __uint32 CModelPushMulti::Events() 00482 { 00483 return 1 + this->numHosts; 00484 } 00485 00486 CSimEvent* CModelPushMulti::Event(__uint32 index, __time& time) 00487 { 00488 switch(index) 00489 { 00490 case 0: // Server init event 00491 time = 0; 00492 return new CEventServerStart(this->server); 00493 default: // Peer arrive 00494 time = 1; 00495 return new CEventClientArrive(this->hosts[index-1]); 00496 } 00497 } 00498 00499 void CModelPushMulti::Finalize() 00500 { 00501 FILE* out; 00502 char fileName[1024]; 00503 00504 /* 00505 * Simple statistics 00506 */ 00507 00508 // Calculate data 00509 00510 // Data : bandwidth 00511 this->dataBwTotal = 0; 00512 00513 // Data : bandwidth core 00514 this->dataBwCoreTotal = 0; 00515 00516 // Data : bandwidth access 00517 this->dataBwAccessTotal = 0; 00518 00519 // Data : bandwidth access uplink 00520 this->dataBwAccessUpTotal = 0; 00521 00522 // Data : bandwidth access downlink 00523 this->dataBwAccessDownTotal = 0; 00524 00525 // Data : bandwidth server 00526 this->dataBwServerTotal = 0; 00527 00528 // Data : bandwidth stream 00529 this->dataBwStreamTotal = 0; 00530 00531 // Data : bandwidth core stream 00532 this->dataBwCoreStreamTotal = 0; 00533 00534 // Data : bandwidth access stream 00535 this->dataBwAccessStreamTotal = 0; 00536 00537 // Data : bandwidth access uplink stream 00538 this->dataBwAccessUpStreamTotal = 0; 00539 00540 // Data : bandwidth access downlink stream 00541 this->dataBwAccessDownStreamTotal = 0; 00542 00543 // Data : bandwidth server stream 00544 this->dataBwServerStreamTotal = 0; 00545 00546 // Data : bandwidth control 00547 this->dataBwControlTotal = 0; 00548 00549 // Data : bandwidth core control 00550 this->dataBwCoreControlTotal = 0; 00551 00552 // Data : bandwidth access control 00553 this->dataBwAccessControlTotal = 0; 00554 00555 // Data : bandwidth access uplink control 00556 this->dataBwAccessUpControlTotal = 0; 00557 00558 // Data : bandwidth access downlink control 00559 this->dataBwAccessDownControlTotal = 0; 00560 00561 // Data : bandwidth server control 00562 this->dataBwServerControlTotal = 0; 00563 00564 // Data : multicast entries 00565 this->dataRouterMcastEntries = 0; 00566 this->dataRouterMcastEntriesIgmp = 0; 00567 this->dataRouterMcastEntriesPimSm = 0; 00568 00569 // Data : host statistics 00570 this->dataCoderEncodedPackets = 0; 00571 this->dataCoderDecodedPackets = 0; 00572 this->dataCoderDiscardedPackets = 0; 00573 00574 this->dataCoderEncodedFrames = 0; 00575 this->dataCoderDecodedFrames = 0; 00576 this->dataCoderDiscardedFrames = 0; 00577 00578 this->dataClientRecvFrames = 0; 00579 this->dataClientDiscardedFrames = 0; 00580 this->dataClientExpectedFrames = 0; 00581 00582 00583 // Server link 00584 this->dataBwTotal += this->linkServer->StatBits(0,0) + this->linkServer->StatBits(0,1) + this->linkServer->StatBits(1,0) + this->linkServer->StatBits(1,1); 00585 this->dataBwServerTotal += this->linkServer->StatBits(0,0) + this->linkServer->StatBits(0,1) + this->linkServer->StatBits(1,0) + this->linkServer->StatBits(1,1); 00586 this->dataBwStreamTotal += this->linkServer->StatBits(1,0) + this->linkServer->StatBits(1,1); 00587 this->dataBwServerStreamTotal += this->linkServer->StatBits(1,0) + this->linkServer->StatBits(1,1); 00588 this->dataBwServerControlTotal += this->linkServer->StatBits(0,0) + this->linkServer->StatBits(0,1); 00589 00590 // Core links 00591 for(__uint32 index = 0; index < this->topology->Edges(); index++) 00592 { 00593 this->dataBwTotal += this->linksCore[index]->StatBits(0,0) + this->linksCore[index]->StatBits(0,1) + this->linksCore[index]->StatBits(1,0) + this->linksCore[index]->StatBits(1,1); 00594 this->dataBwCoreTotal += this->linksCore[index]->StatBits(0,0) + this->linksCore[index]->StatBits(0,1) + this->linksCore[index]->StatBits(1,0) + this->linksCore[index]->StatBits(1,1); 00595 this->dataBwStreamTotal += this->linksCore[index]->StatBits(1,0) + this->linksCore[index]->StatBits(1,1); 00596 this->dataBwCoreStreamTotal += this->linksCore[index]->StatBits(1,0) + this->linksCore[index]->StatBits(1,1); 00597 this->dataBwControlTotal += this->linksCore[index]->StatBits(0,0) + this->linksCore[index]->StatBits(0,1); 00598 this->dataBwCoreControlTotal += this->linksCore[index]->StatBits(0,0) + this->linksCore[index]->StatBits(0,1); 00599 } 00600 00601 // Access links 00602 for(__uint32 index = 0; index < this->numHosts; index++) 00603 { 00604 this->dataBwTotal += this->linksAccess[index]->StatBits(0,0) + this->linksAccess[index]->StatBits(0,1) + this->linksAccess[index]->StatBits(1,0) + this->linksAccess[index]->StatBits(1,1); 00605 this->dataBwAccessTotal += this->linksAccess[index]->StatBits(0,0) + this->linksAccess[index]->StatBits(0,1) + this->linksAccess[index]->StatBits(1,0) + this->linksAccess[index]->StatBits(1,1); 00606 this->dataBwAccessUpTotal += this->linksAccess[index]->StatBits(0,0) + this->linksAccess[index]->StatBits(1,0); 00607 this->dataBwAccessDownTotal += this->linksAccess[index]->StatBits(0,1) + this->linksAccess[index]->StatBits(1,1); 00608 this->dataBwStreamTotal += this->linksAccess[index]->StatBits(1,0) + this->linksAccess[index]->StatBits(1,1); 00609 this->dataBwAccessStreamTotal += this->linksAccess[index]->StatBits(1,0) + this->linksAccess[index]->StatBits(1,1); 00610 this->dataBwAccessUpStreamTotal += this->linksAccess[index]->StatBits(1,0); 00611 this->dataBwAccessDownStreamTotal += this->linksAccess[index]->StatBits(1,1); 00612 this->dataBwControlTotal += this->linksAccess[index]->StatBits(0,0) + this->linksAccess[index]->StatBits(0,1); 00613 this->dataBwAccessControlTotal += this->linksAccess[index]->StatBits(0,0) + this->linksAccess[index]->StatBits(0,1); 00614 this->dataBwAccessUpControlTotal += this->linksAccess[index]->StatBits(0,0); 00615 this->dataBwAccessDownControlTotal += this->linksAccess[index]->StatBits(0,1); 00616 } 00617 00618 this->dataBwAvg = this->dataBwTotal/this->maxTime; 00619 this->dataBwCoreAvg = this->dataBwCoreTotal/this->maxTime; 00620 this->dataBwAccessAvg = this->dataBwAccessTotal/this->maxTime; 00621 this->dataBwAccessUpAvg = this->dataBwAccessUpTotal/this->maxTime; 00622 this->dataBwAccessDownAvg = this->dataBwAccessDownTotal/this->maxTime; 00623 this->dataBwServerAvg = this->dataBwServerTotal/this->maxTime; 00624 this->dataBwStreamAvg = this->dataBwStreamTotal/this->maxTime; 00625 this->dataBwCoreStreamAvg = this->dataBwCoreStreamTotal/this->maxTime; 00626 this->dataBwAccessStreamAvg = this->dataBwAccessStreamTotal/this->maxTime; 00627 this->dataBwAccessUpStreamAvg = this->dataBwAccessUpStreamTotal/this->maxTime; 00628 this->dataBwAccessDownStreamAvg = this->dataBwAccessDownStreamTotal/this->maxTime; 00629 this->dataBwServerStreamAvg = this->dataBwServerStreamTotal/this->maxTime; 00630 this->dataBwControlAvg = this->dataBwControlTotal/this->maxTime; 00631 this->dataBwCoreControlAvg = this->dataBwCoreControlTotal/this->maxTime; 00632 this->dataBwAccessControlAvg = this->dataBwAccessControlTotal/this->maxTime; 00633 this->dataBwAccessUpControlAvg = this->dataBwAccessUpControlTotal/this->maxTime; 00634 this->dataBwAccessDownControlAvg = this->dataBwAccessDownControlTotal/this->maxTime; 00635 this->dataBwServerControlAvg = this->dataBwServerControlTotal/this->maxTime; 00636 00637 // Routers 00638 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00639 { 00640 this->routers[index]->Finalize(); 00641 this->dataRouterMcastEntries += (this->routers[index]->StatMcastEntriesIgmp() + this->routers[index]->StatMcastEntriesPimSm()); 00642 this->dataRouterMcastEntriesIgmp += this->routers[index]->StatMcastEntriesIgmp(); 00643 this->dataRouterMcastEntriesPimSm += this->routers[index]->StatMcastEntriesPimSm(); 00644 } 00645 00646 // Global file 00647 sprintf(fileName, "network_%s_%u.out", this->name, this->topologyNumber); 00648 if(FILE_OPEN(out, fileName, "a")) printf("\nCannot write to file %s.", fileName); 00649 else 00650 { 00651 fprintf(out, "%u %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %llu %.9lf %.9lf %.9lf %.9lf\n", 00652 this->numChannelsMcast, 00653 this->dataBwTotal, 00654 this->dataBwAvg, 00655 this->dataBwCoreTotal, 00656 this->dataBwCoreAvg, 00657 this->dataBwAccessTotal, 00658 this->dataBwAccessAvg, 00659 this->dataBwAccessUpTotal, 00660 this->dataBwAccessUpAvg, 00661 this->dataBwAccessDownTotal, 00662 this->dataBwAccessDownAvg, 00663 this->dataBwServerTotal, 00664 this->dataBwServerAvg, 00665 this->dataBwStreamTotal, 00666 this->dataBwStreamAvg, 00667 this->dataBwCoreStreamTotal, 00668 this->dataBwCoreStreamAvg, 00669 this->dataBwAccessStreamTotal, 00670 this->dataBwAccessStreamAvg, 00671 this->dataBwAccessUpStreamTotal, 00672 this->dataBwAccessUpStreamAvg, 00673 this->dataBwAccessDownStreamTotal, 00674 this->dataBwAccessDownStreamAvg, 00675 this->dataBwServerStreamTotal, 00676 this->dataBwServerStreamAvg, 00677 this->dataBwControlTotal, 00678 this->dataBwControlAvg, 00679 this->dataBwCoreControlTotal, 00680 this->dataBwCoreControlAvg, 00681 this->dataBwAccessControlTotal, 00682 this->dataBwAccessControlAvg, 00683 this->dataBwAccessUpControlTotal, 00684 this->dataBwAccessUpControlAvg, 00685 this->dataBwAccessDownControlTotal, 00686 this->dataBwAccessDownControlAvg, 00687 this->dataBwServerControlTotal, 00688 this->dataBwServerControlAvg, 00689 this->dataRouterMcastEntries, 00690 this->dataRouterMcastEntriesIgmp, 00691 this->dataRouterMcastEntriesPimSm 00692 ); 00693 00694 fclose(out); 00695 } 00696 00697 #ifdef STAT_VERBOSE 00698 00699 // Channel quality 00700 sprintf(fileName, "qchannel_%s_%u.out", this->name, this->topologyNumber); 00701 if(fopen_s(&out, fileName, "a")) printf("\nCannot write to file %s.", fileName); 00702 else 00703 { 00704 fprintf(out, "%u ", this->numChannelsMcast); 00705 for(__uint32 index = 0; index < this->numChannels; index++) 00706 { 00707 fprintf(out, "%.9lf ", this->data->QualityChannelNormal(index)); 00708 } 00709 for(__uint32 index = 0; index < this->numChannels; index++) 00710 { 00711 fprintf(out, "%.9lf ", this->data->QualityChannelWeighted(index)); 00712 } 00713 fprintf(out, "\n"); 00714 00715 fclose(out); 00716 } 00717 00718 // Session quality 00719 sprintf(fileName, "qsession_%s_%u.out", this->name, this->topologyNumber); 00720 if(fopen_s(&out, fileName, "a")) printf("\nCannot write to file %s.", fileName); 00721 else 00722 { 00723 fprintf(out, "%u ", this->numChannelsMcast); 00724 for(__uint32 index = 0; index < this->maxTime; index++) 00725 { 00726 fprintf(out, "%.9lf ", this->data->QualitySession(index)); 00727 } 00728 fprintf(out, "\n"); 00729 00730 fclose(out); 00731 } 00732 00733 /* 00734 * Advanced statistics 00735 */ 00736 00737 // Statistics file in user form 00738 00739 sprintf(fileName, "stat_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 00740 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 00741 else 00742 { 00743 // Save host statistics 00744 fprintf(out, "\n\nHosts\n"); 00745 fprintf(out, "\nHost Gw Read Write"); 00746 fprintf(out, "\n======================================================================="); 00747 00748 fprintf(out, "\nSERVER %3u %10I64u %10I64u", 00749 this->gatewayServer, 00750 this->server->StatPacketsRead(), 00751 this->server->StatPacketsWrite()); 00752 00753 for(__uint32 index = 0; index < this->numHosts; index++) 00754 { 00755 fprintf(out, "\nHOST %3u %3u %10I64u %10I64u", 00756 index, 00757 this->gateways[index], 00758 this->hosts[index]->StatPacketsRead(), 00759 this->hosts[index]->StatPacketsWrite() 00760 ); 00761 } 00762 00763 // Save router statistics 00764 fprintf(out, "\n\nRouters\n"); 00765 fprintf(out, "\nRouter Read Write Entr IGMP Entr PIMSM "); 00766 fprintf(out, "\n============================================================="); 00767 00768 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00769 { 00770 fprintf(out, "\nROUTER %3u %10I64u %10I64u %10.5lf %10.5lf", 00771 index, 00772 this->routers[index]->StatPacketsRead(), 00773 this->routers[index]->StatPacketsWrite(), 00774 this->routers[index]->StatMcastEntries(), 00775 this->routers[index]->StatMcastEntriesPimSm() 00776 ); 00777 } 00778 00779 00780 // Save link statistics : server 00781 fprintf(out, "\n\nServer link\n"); 00782 fprintf(out, "\nLink Bw0 Bw1 Util00 Util01 Util10 Util11 Pack00 Disc00 Pack01 Disc01 Pack10 Disc10 Pack11 Disc11 Bits00 Bits01 Bits10 Bits11 Que00 Que01 Que10 Que11"); 00783 fprintf(out, "\n========================================================================================================================================================================"); 00784 00785 this->linkServer->Finalize(); 00786 fprintf(out, "\n%3u %10.0lf %10.0lf : %6.4lf %6.4lf %6.4lf %6.4lf %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6.2lf %6.2lf %6.2lf %6.2lf ", 00787 0, 00788 this->linkServer->Bandwidth(0), 00789 this->linkServer->Bandwidth(1), 00790 this->linkServer->StatUtilization(0, 0), 00791 this->linkServer->StatUtilization(0, 1), 00792 this->linkServer->StatUtilization(1, 0), 00793 this->linkServer->StatUtilization(1, 1), 00794 this->linkServer->StatPackets(0, 0), 00795 this->linkServer->StatDiscard(0, 0), 00796 this->linkServer->StatPackets(0, 1), 00797 this->linkServer->StatDiscard(0, 1), 00798 this->linkServer->StatPackets(1, 0), 00799 this->linkServer->StatDiscard(1, 0), 00800 this->linkServer->StatPackets(1, 1), 00801 this->linkServer->StatDiscard(1, 1), 00802 this->linkServer->StatBits(0, 0), 00803 this->linkServer->StatBits(0, 1), 00804 this->linkServer->StatBits(1, 0), 00805 this->linkServer->StatBits(1, 1), 00806 this->linkServer->StatQueue(0, 0), 00807 this->linkServer->StatQueue(0, 1), 00808 this->linkServer->StatQueue(1, 0), 00809 this->linkServer->StatQueue(1, 1) 00810 ); 00811 00812 00813 // Save link statistics : access 00814 fprintf(out, "\n\nAccess links\n"); 00815 fprintf(out, "\nLink Bw0 Bw1 Util00 Util01 Util10 Util11 Pack00 Disc00 Pack01 Disc01 Pack10 Disc10 Pack11 Disc11 Bits00 Bits01 Bits10 Bits11 Que00 Que01 Que10 Que11"); 00816 fprintf(out, "\n========================================================================================================================================================================"); 00817 for(__uint32 index = 0; index < this->numHosts; index++) 00818 { 00819 this->linksAccess[index]->Finalize(); 00820 fprintf(out, "\n%3u %10.0lf %10.0lf : %6.4lf %6.4lf %6.4lf %6.4lf %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6.2lf %6.2lf %6.2lf %6.2lf ", 00821 index, 00822 this->linksAccess[index]->Bandwidth(0), 00823 this->linksAccess[index]->Bandwidth(1), 00824 this->linksAccess[index]->StatUtilization(0, 0), 00825 this->linksAccess[index]->StatUtilization(0, 1), 00826 this->linksAccess[index]->StatUtilization(1, 0), 00827 this->linksAccess[index]->StatUtilization(1, 1), 00828 this->linksAccess[index]->StatPackets(0, 0), 00829 this->linksAccess[index]->StatDiscard(0, 0), 00830 this->linksAccess[index]->StatPackets(0, 1), 00831 this->linksAccess[index]->StatDiscard(0, 1), 00832 this->linksAccess[index]->StatPackets(1, 0), 00833 this->linksAccess[index]->StatDiscard(1, 0), 00834 this->linksAccess[index]->StatPackets(1, 1), 00835 this->linksAccess[index]->StatDiscard(1, 1), 00836 this->linksAccess[index]->StatBits(0, 0), 00837 this->linksAccess[index]->StatBits(0, 1), 00838 this->linksAccess[index]->StatBits(1, 0), 00839 this->linksAccess[index]->StatBits(1, 1), 00840 this->linksAccess[index]->StatQueue(0, 0), 00841 this->linksAccess[index]->StatQueue(0, 1), 00842 this->linksAccess[index]->StatQueue(1, 0), 00843 this->linksAccess[index]->StatQueue(1, 1) 00844 ); 00845 } 00846 00847 // Save link statistics : core 00848 fprintf(out, "\n\nCore links\n"); 00849 fprintf(out, "\nLink Bw0 Bw1 Util00 Util01 Util10 Util11 Pack00 Disc00 Pack01 Disc01 Pack10 Disc10 Pack11 Disc11 Bits00 Bits01 Bits10 Bits11 Que00 Que01 Que10 Que11"); 00850 fprintf(out, "\n========================================================================================================================================================================"); 00851 for(__uint32 index = 0; index < this->topology->Edges(); index++) 00852 { 00853 this->linksCore[index]->Finalize(); 00854 fprintf(out, "\n%3u %10.0lf %10.0lf : %6.4lf %6.4lf %6.4lf %6.4lf %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6I64u %6.2lf %6.2lf %6.2lf %6.2lf ", 00855 index, 00856 this->linksCore[index]->Bandwidth(0), 00857 this->linksCore[index]->Bandwidth(1), 00858 this->linksCore[index]->StatUtilization(0, 0), 00859 this->linksCore[index]->StatUtilization(0, 1), 00860 this->linksCore[index]->StatUtilization(1, 0), 00861 this->linksCore[index]->StatUtilization(1, 1), 00862 this->linksCore[index]->StatPackets(0, 0), 00863 this->linksCore[index]->StatDiscard(0, 0), 00864 this->linksCore[index]->StatPackets(0, 1), 00865 this->linksCore[index]->StatDiscard(0, 1), 00866 this->linksCore[index]->StatPackets(1, 0), 00867 this->linksCore[index]->StatDiscard(1, 0), 00868 this->linksCore[index]->StatPackets(1, 1), 00869 this->linksCore[index]->StatDiscard(1, 1), 00870 this->linksCore[index]->StatBits(0, 0), 00871 this->linksCore[index]->StatBits(0, 1), 00872 this->linksCore[index]->StatBits(1, 0), 00873 this->linksCore[index]->StatBits(1, 1), 00874 this->linksCore[index]->StatQueue(0, 0), 00875 this->linksCore[index]->StatQueue(0, 1), 00876 this->linksCore[index]->StatQueue(1, 0), 00877 this->linksCore[index]->StatQueue(1, 1) 00878 ); 00879 } 00880 fclose(out); 00881 } 00882 00883 // Statistics file in computer form 00884 00885 // Hosts 00886 00887 sprintf(fileName, "hosts_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 00888 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 00889 else 00890 { 00891 // Save host statistics 00892 fprintf(out, "0 %u %I64u %I64u\n", 00893 this->gatewayServer, 00894 this->server->StatPacketsRead(), 00895 this->server->StatPacketsWrite()); 00896 00897 for(__uint32 index = 0; index < this->numHosts; index++) 00898 { 00899 fprintf(out, "%u %u %I64u %I64u\n", 00900 index, 00901 this->gateways[index], 00902 this->hosts[index]->StatPacketsRead(), 00903 this->hosts[index]->StatPacketsWrite() 00904 ); 00905 } 00906 00907 fclose(out); 00908 } 00909 // Routers 00910 00911 sprintf(fileName, "routers_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 00912 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 00913 else 00914 { 00915 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 00916 { 00917 fprintf(out, "%u %I64u %I64u %.9lf %.9lf\n", 00918 index, 00919 this->routers[index]->StatPacketsRead(), 00920 this->routers[index]->StatPacketsWrite(), 00921 this->routers[index]->StatMcastEntries(), 00922 this->routers[index]->StatMcastEntriesPimSm() 00923 ); 00924 } 00925 00926 fclose(out); 00927 } 00928 // Server link 00929 00930 sprintf(fileName, "slink_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 00931 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 00932 else 00933 { 00934 fprintf(out, "%u %.0lf %.0lf %.9lf %.9lf %.9lf %.9lf %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %.9lf %.9lf %.9lf %.9lf\n", 00935 0, 00936 this->linkServer->Bandwidth(0), 00937 this->linkServer->Bandwidth(1), 00938 this->linkServer->StatUtilization(0, 0), 00939 this->linkServer->StatUtilization(0, 1), 00940 this->linkServer->StatUtilization(1, 0), 00941 this->linkServer->StatUtilization(1, 1), 00942 this->linkServer->StatPackets(0, 0), 00943 this->linkServer->StatDiscard(0, 0), 00944 this->linkServer->StatPackets(0, 1), 00945 this->linkServer->StatDiscard(0, 1), 00946 this->linkServer->StatPackets(1, 0), 00947 this->linkServer->StatDiscard(1, 0), 00948 this->linkServer->StatPackets(1, 1), 00949 this->linkServer->StatDiscard(1, 1), 00950 this->linkServer->StatBits(0, 0), 00951 this->linkServer->StatBits(0, 1), 00952 this->linkServer->StatBits(1, 0), 00953 this->linkServer->StatBits(1, 1), 00954 this->linkServer->StatQueue(0, 0), 00955 this->linkServer->StatQueue(0, 1), 00956 this->linkServer->StatQueue(1, 0), 00957 this->linkServer->StatQueue(1, 1) 00958 ); 00959 00960 fclose(out); 00961 } 00962 // Access links 00963 00964 sprintf(fileName, "alink_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 00965 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 00966 else 00967 { 00968 for(__uint32 index = 0; index < this->numHosts; index++) 00969 { 00970 fprintf(out, "%u %.0lf %.0lf %.9lf %.9lf %.9lf %.9lf %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %.9lf %.9lf %.9lf %.9lf\n", 00971 index, 00972 this->linksAccess[index]->Bandwidth(0), 00973 this->linksAccess[index]->Bandwidth(1), 00974 this->linksAccess[index]->StatUtilization(0, 0), 00975 this->linksAccess[index]->StatUtilization(0, 1), 00976 this->linksAccess[index]->StatUtilization(1, 0), 00977 this->linksAccess[index]->StatUtilization(1, 1), 00978 this->linksAccess[index]->StatPackets(0, 0), 00979 this->linksAccess[index]->StatDiscard(0, 0), 00980 this->linksAccess[index]->StatPackets(0, 1), 00981 this->linksAccess[index]->StatDiscard(0, 1), 00982 this->linksAccess[index]->StatPackets(1, 0), 00983 this->linksAccess[index]->StatDiscard(1, 0), 00984 this->linksAccess[index]->StatPackets(1, 1), 00985 this->linksAccess[index]->StatDiscard(1, 1), 00986 this->linksAccess[index]->StatBits(0, 0), 00987 this->linksAccess[index]->StatBits(0, 1), 00988 this->linksAccess[index]->StatBits(1, 0), 00989 this->linksAccess[index]->StatBits(1, 1), 00990 this->linksAccess[index]->StatQueue(0, 0), 00991 this->linksAccess[index]->StatQueue(0, 1), 00992 this->linksAccess[index]->StatQueue(1, 0), 00993 this->linksAccess[index]->StatQueue(1, 1) 00994 ); 00995 } 00996 00997 fclose(out); 00998 } 00999 01000 // Core links 01001 01002 sprintf(fileName, "clink_%s_%u_%u.stat", this->name, this->topologyNumber, this->numChannelsMcast); 01003 if(fopen_s(&out, fileName, "w")) printf("\nCannot write to file %s.", fileName); 01004 else 01005 { 01006 for(__uint32 index = 0; index < this->topology->Edges(); index++) 01007 { 01008 fprintf(out, "%u %.0lf %.0lf %.9lf %.9lf %.9lf %.9lf %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %I64u %.9lf %.9lf %.9lf %.9lf\n", 01009 index, 01010 this->linksCore[index]->Bandwidth(0), 01011 this->linksCore[index]->Bandwidth(1), 01012 this->linksCore[index]->StatUtilization(0, 0), 01013 this->linksCore[index]->StatUtilization(0, 1), 01014 this->linksCore[index]->StatUtilization(1, 0), 01015 this->linksCore[index]->StatUtilization(1, 1), 01016 this->linksCore[index]->StatPackets(0, 0), 01017 this->linksCore[index]->StatDiscard(0, 0), 01018 this->linksCore[index]->StatPackets(0, 1), 01019 this->linksCore[index]->StatDiscard(0, 1), 01020 this->linksCore[index]->StatPackets(1, 0), 01021 this->linksCore[index]->StatDiscard(1, 0), 01022 this->linksCore[index]->StatPackets(1, 1), 01023 this->linksCore[index]->StatDiscard(1, 1), 01024 this->linksCore[index]->StatBits(0, 0), 01025 this->linksCore[index]->StatBits(0, 1), 01026 this->linksCore[index]->StatBits(1, 0), 01027 this->linksCore[index]->StatBits(1, 1), 01028 this->linksCore[index]->StatQueue(0, 0), 01029 this->linksCore[index]->StatQueue(0, 1), 01030 this->linksCore[index]->StatQueue(1, 0), 01031 this->linksCore[index]->StatQueue(1, 1) 01032 ); 01033 } 01034 01035 fclose(out); 01036 } 01037 #endif 01038 01039 /* 01040 * Cleanup objects created during simulation (objects that cannot be deleted in the destructor because they depend on the simulator) 01041 */ 01042 01043 // Delete hosts 01044 if(this->hosts) 01045 { 01046 for(__uint32 index = 0; index < this->numHosts; index++) 01047 delete this->hosts[index]; 01048 delete[] this->hosts; 01049 } 01050 01051 // Delete routers 01052 if(this->routers) 01053 { 01054 for(__uint32 index = 0; index < this->topology->Nodes(); index++) 01055 delete this->routers[index]; 01056 delete[] this->routers; 01057 } 01058 01059 // Delete server 01060 if(this->server) delete this->server; 01061 01062 // Delete links core 01063 if(this->linksCore) 01064 { 01065 for(__uint32 index = 0; index < this->topology->Edges(); index++) 01066 delete this->linksCore[index]; 01067 delete[] this->linksCore; 01068 } 01069 01070 // Delete links access 01071 if(this->linksAccess) 01072 { 01073 for(__uint32 index = 0; index < this->numHosts; index++) 01074 delete this->linksAccess[index]; 01075 delete[] this->linksAccess; 01076 } 01077 01078 // Delete link server 01079 if(this->linkServer) delete this->linkServer; 01080 } 01081 01082 int CModelPushMulti::Forward(CAddress node, CAddress dst) 01083 { 01084 // Calculates the outgoing link when the router receives a packet with a certain destination 01085 assert(node.Address() <= this->routeNodes); 01086 assert(dst.Address() <= this->routeDst); 01087 01088 return this->route[node.Address()][dst.Address()]; 01089 } 01090 01091 CChannel* CModelPushMulti::Channel(__uint32 index) 01092 { 01093 assert(index < this->numChannelsMcast + this->numChannelsUcast); 01094 01095 return (index < this->numChannelsMcast)?&this->channelsMcast[index]:&this->channelsUcast[index - this->numChannelsMcast]; 01096 }
Last updated: February 8, 2011