Skip to content

Commit d73e3bc

Browse files
chenlijun99levy
andauthored
NeighborListCache: don't build neighbor list during initialization (#983)
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 <[email protected]>
1 parent 503728a commit d73e3bc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/inet/physicallayer/wireless/common/neighborcache/NeighborListNeighborCache.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ void NeighborListNeighborCache::addRadio(const IRadio *radio)
9696
RadioEntry *newEntry = new RadioEntry(radio);
9797
radios.push_back(newEntry);
9898
radioToEntry[radio] = newEntry;
99-
updateNeighborLists();
100-
maxSpeed = radioMedium->getMediumLimitCache()->getMaxSpeed().get<mps>();
101-
if (maxSpeed != 0 && !updateNeighborListsTimer->isScheduled() && initialized())
102-
scheduleAfter(refillPeriod, updateNeighborListsTimer);
99+
if (initialized()) {
100+
updateNeighborLists();
101+
maxSpeed = radioMedium->getMediumLimitCache()->getMaxSpeed().get<mps>();
102+
if (maxSpeed != 0 && !updateNeighborListsTimer->isScheduled()) {
103+
scheduleAfter(refillPeriod, updateNeighborListsTimer);
104+
}
105+
}
103106
}
104107

105108
void NeighborListNeighborCache::removeRadio(const IRadio *radio)
@@ -144,4 +147,3 @@ NeighborListNeighborCache::~NeighborListNeighborCache()
144147

145148
} // namespace physicallayer
146149
} // namespace inet
147-

0 commit comments

Comments
 (0)