WirelessChannel::WirelessChannel(void) : Channel(), numNodes_(0),
xListHead_(NULL), sorted_(0) {
// Multi-channel Multi-interface
for(int i = 0; i < 100; i++) {
myList[i] = NULL;
}
}
void
WirelessChannel::sendUp(Packet* p, Phy *tifp)
{
......
if(!sorted_) {
// sort list not implemented
// sortLists();
}
......
affectedNodes = getAffectedNodes(mtnode, distCST_ + /* safety */ 5, &numAffectedNodes);
for (i=0; i < numAffectedNodes; i++) {
rnode = affectedNodes[i];
if(rnode == tnode)
continue;
newp = p->copy();
propdelay = get_pdelay(tnode, rnode);
rifp = (rnode->ifhead()).lh_first;
/*==============original================================
for(; rifp; rifp = rifp->nextnode()){
s.schedule(rifp, newp, propdelay);
}
==============original================================*/
//Multi-channel Multi-interface
for(; rifp; rifp = rifp->nextnode()){
// Only the right channel gets the copy
if (rifp->channel() == this) {
s.schedule(rifp, newp, propdelay);
break;
}
}
}
delete [] affectedNodes;
......
}
void
WirelessChannel::addNodeToList(MobileNode *mn)
{
// Multi-channel Multi-interface
myList[numNodes_] = mn;
......
}
MobileNode **
WirelessChannel::getAffectedNodes(MobileNode *mn, double radius,
int *numAffectedNodes)
{
......
/*==============original================================
for(tmp = xListHead_; tmp != NULL; tmp = tmp->nextX_) tmpList[n++] = tmp;
for(int i = 0; i < n; ++i)
if(tmpList[i]->speed()!=0.0 && (Scheduler::instance().clock() -
tmpList[i]->getUpdateTime()) > XLIST_POSITION_UPDATE_INTERVAL )
tmpList[i]->update_position();
n=0;
for(tmp = mn; tmp != NULL && tmp->X() >= xmin; tmp=tmp->prevX_)
if(tmp->Y() >= ymin && tmp->Y() <= ymax){
tmpList[n++] = tmp;
}
for(tmp = mn->nextX_; tmp != NULL && tmp->X() <= xmax; tmp=tmp->nextX_){
if(tmp->Y() >= ymin && tmp->Y() <= ymax){
tmpList[n++] = tmp;
}
}
===========original==========================================*/
//Multi-channel Multi-interface
for(int i = 0; i < numNodes_; i++) {
if(myList[i]->X() >= xmin && myList[i]->X() <= xmax && myList[i]->Y() >= ymin && myList[i]->Y() <= ymax) {
tmpList[n++] = myList[i];
}
}
} |