11.05.2013 Views

Evaluación de Algoritmos de Ruteamiento Multipunto en Redes de ...

Evaluación de Algoritmos de Ruteamiento Multipunto en Redes de ...

Evaluación de Algoritmos de Ruteamiento Multipunto en Redes de ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ANEXO D: Código BC para MCRSIM<br />

A continuación se muestra el código <strong>en</strong> C++ para las distintas heurísticas <strong>de</strong> la familia<br />

BC. El código <strong>de</strong> BCL es análogo y sólo se modifican un par <strong>de</strong> líneas. Para ello se pue<strong>de</strong><br />

revisar el pseudocódigo <strong>en</strong> 4.2.2.<br />

//<strong>de</strong>fine Heuristicas<br />

#<strong>de</strong>fine ANCHOBANDA 1<br />

#<strong>de</strong>fine ALCANCE 2<br />

#<strong>de</strong>fine SALTOS 3<br />

#<strong>de</strong>fine DISTVIRTUAL 4<br />

double TheNo<strong>de</strong>List::routerBC(int alg, No<strong>de</strong> *source, int addr, double &d,<br />

double &maxd, double &mind, double &h,<br />

double &no<strong>de</strong>s) {<br />

//Primero se borra cualquier ruteami<strong>en</strong>to previo para este grupo y fu<strong>en</strong>te.<br />

removeTree(source, addr);<br />

int heuristica;<br />

//TIPO HEURISTICA<br />

if (alg == bc) heuristica = 1;<br />

if (alg == bcal) heuristica = 2;<br />

if (alg == bcsal) heuristica = 3;<br />

if (alg == bcdvir) heuristica = 4;<br />

//Localiza la fu<strong>en</strong>te y obti<strong>en</strong>e el peak rate<br />

SourceList *ss = source->sourceList();<br />

int Foundd = False;<br />

while ((ss != NULL) && (Foundd == False)) {<br />

if ((ss->source()->type() != Background) &&<br />

(ss->source()->address() == addr)) Foundd = True;<br />

else ss = ss->next();<br />

};<br />

double pk = ss->source()->peak();<br />

double avg = ss->source()->average();<br />

//Localiza el grupo Mcast que conti<strong>en</strong>e el grupo <strong>de</strong> <strong>de</strong>stinos<br />

MCGroup *group = groupsHd;<br />

while ((group != NULL) && (group->address() != addr))<br />

group = group->next();<br />

if (group == NULL) {<br />

//printf("Group = NULL");<br />

return(NOGROUP);<br />

}<br />

//si el grupo ti<strong>en</strong>e solo a la fu<strong>en</strong>te, el costo <strong>de</strong>l arbol es 0<br />

if ((group->count() == 1) &&<br />

(group->headm()->no<strong>de</strong>Ptr()->name() == source->name())) {<br />

source->addRoutingEntry(addr, source);<br />

h = d = maxd = mind = 0;<br />

no<strong>de</strong>s = 1;<br />

return(0);<br />

};<br />

////variables ///////////////////<br />

double CostAdy = 0.0;<br />

double CostoAd = 0.0;<br />

double *CostAdj = new double[num]; //arreglo con costos <strong>de</strong> los nodos adyac<strong>en</strong>tes<br />

int AllDestinInTree = False;<br />

104

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!