NLSR icon indicating copy to clipboard operation
NLSR copied to clipboard

About the problems encountered when using nlsrc withdraw <name>

Open Morningstar678 opened this issue 2 years ago • 1 comments

Problem Description:On a simple NFD-connected topology, after a prefix is withdrawn using nlsrc withdraw , all routing information for that prefix on adjacent NFDs is removed. Cause of the problem: NLSR calculates routing information according to LSDB, forms FIB table, specifically: prefix+NextHops (faceID, cost), and registers routing information to NFD through Interest-Data, where the formal parameters of register() method are prefix, faceURI, Cost, and The formal parameters of the unregister() method are prefix, faceURI, and Cost, and the formal parameters of the unregister() method are prefix, faceURI, so it can be assumed that when NLSR registers the route with NFD, it registers all the route information under a certain prefix. Solution: Modify void Fib::update(const ndn::Name& name, const NexthopList& allHops) in the fib.cpp file in the NLSR-0.4.3\src\route directory(In fact every version of NLSR has this problem, version 0.4.3 has been tested)The code is modified as follows:

`void Fib::update(const ndn::Name& name, const NexthopList& allHops)
{ NLSR_LOG_DEBUG("Fib::update called");

// Get the max possible faces which is the minumum of the configuration setting and // the length of the list of all next hops. unsigned int maxFaces = getNumberOfFacesForName(allHops);

NexthopList hopsToAdd; unsigned int nFaces = 0;

// Create a list of next hops to be installed with length == maxFaces for (NexthopList::iterator it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces; ++it, ++nFaces) { hopsToAdd.addNextHop(*it); }

std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);

// New FIB entry that has nextHops if (entryIt == m_table.end() && hopsToAdd.size() != 0) { NLSR_LOG_DEBUG("New FIB Entry");

FibEntry entry(name);

addNextHopsToFibEntryAndNfd(entry, hopsToAdd);

m_table.emplace(name, entry);

entryIt = m_table.find(name);

} // Existing FIB entry that may or may not have nextHops else { // Existing FIB entry NLSR_LOG_DEBUG("Existing FIB Entry");

// Remove empty FIB entry
if (hopsToAdd.size() == 0) {
  remove(name);
  return;
}

FibEntry& entry = (entryIt->second);//

//**addNextHopsToFibEntryAndNfd(entry, hopsToAdd);**//Adjust the position of the row

std::set<NextHop, NextHopComparator> hopsToRemove;
std::set_difference(entry.getNexthopList().begin(), entry.getNexthopList().end(),
                    hopsToAdd.begin(), hopsToAdd.end(),
                    std::inserter(hopsToRemove, hopsToRemove.end()), NextHopComparator());

bool isUpdatable = isPrefixUpdatable(entry.getName());
// Remove the uninstalled next hops from NFD and FIB entry
for (const auto& hop: hopsToRemove){
  if (isUpdatable) {
    unregisterPrefix(entry.getName(), hop.getConnectingFaceUri());
  }
  NLSR_LOG_DEBUG("Removing " << hop.getConnectingFaceUri() << " from " << entry.getName());
  entry.getNexthopList().removeNextHop(hop);
}
  addNextHopsToFibEntryAndNfd(entry, hopsToAdd);         //  Adjust here
// Increment sequence number
entry.setSeqNo(entry.getSeqNo() + 1);

entryIt = m_table.find(name);

} if (entryIt != m_table.end() && !entryIt->second.getRefreshEventId()) { scheduleEntryRefresh(entryIt->second, [this] (FibEntry& entry) { scheduleLoop(entry); }); } }

Morningstar678 avatar Dec 21 '21 11:12 Morningstar678