Skip to content

Commit

Permalink
NeighborListCache: don't build neighbor list during initialization (#983
Browse files Browse the repository at this point in the history
)

Given n radios, neighbor list construction has O(n^2) complexity.
If, during initialization, when each radio is added, the neighbor list
is reconstructed, we end up having a simulation initialization with
O(n^3) complexity.
Sidenote: In one of our tests, without this patch, when running a WiFi
simulation of 5000 nodes, it took ~40 minutes to just initialize the
simulation.

Co-authored-by: Levente Mészáros <levy@omnetpp.org>
  • Loading branch information
chenlijun99 and levy authored Nov 29, 2024
1 parent 503728a commit d73e3bc
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ void NeighborListNeighborCache::addRadio(const IRadio *radio)
RadioEntry *newEntry = new RadioEntry(radio);
radios.push_back(newEntry);
radioToEntry[radio] = newEntry;
updateNeighborLists();
maxSpeed = radioMedium->getMediumLimitCache()->getMaxSpeed().get<mps>();
if (maxSpeed != 0 && !updateNeighborListsTimer->isScheduled() && initialized())
scheduleAfter(refillPeriod, updateNeighborListsTimer);
if (initialized()) {
updateNeighborLists();
maxSpeed = radioMedium->getMediumLimitCache()->getMaxSpeed().get<mps>();
if (maxSpeed != 0 && !updateNeighborListsTimer->isScheduled()) {
scheduleAfter(refillPeriod, updateNeighborListsTimer);
}
}
}

void NeighborListNeighborCache::removeRadio(const IRadio *radio)
Expand Down Expand Up @@ -144,4 +147,3 @@ NeighborListNeighborCache::~NeighborListNeighborCache()

} // namespace physicallayer
} // namespace inet

0 comments on commit d73e3bc

Please sign in to comment.