BREAKING: Change Name LSAs to propagate cost which are applied to remote routes
This is a stopgap change to address a lack of functionality in the NDN testbed.
Current restrictions:
-Cost must be set from NFD readvertisement
-Cost is applied after routing calculations but before FIB insertion; lowest cost
nexthop will be chosen but may not be the optimal path given this cost.
Further work will be required to move the application of cost as part of routing
and to make this functionality more easily accessible.
Refs #5349
Change-Id: I914dc5c2d5d3cb6bfa13f5730df0eae66d115c60
diff --git a/src/lsa/name-lsa.cpp b/src/lsa/name-lsa.cpp
index 7867b68..2efe86e 100644
--- a/src/lsa/name-lsa.cpp
+++ b/src/lsa/name-lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2024, The University of Memphis,
+ * Copyright (c) 2014-2025, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,7 +29,7 @@
const NamePrefixList& npl)
: Lsa(originRouter, seqNo, timepoint)
{
- for (const auto& name : npl.getNames()) {
+ for (const auto& name : npl.getPrefixInfo()) {
addName(name);
}
}
@@ -45,7 +45,7 @@
{
size_t totalLength = 0;
- auto names = m_npl.getNames();
+ auto names = m_npl.getPrefixInfo();
for (auto it = names.rbegin(); it != names.rend(); ++it) {
totalLength += it->wireEncode(block);
@@ -102,8 +102,9 @@
NamePrefixList npl;
for (; val != m_wire.elements_end(); ++val) {
- if (val->type() == ndn::tlv::Name) {
- npl.insert(ndn::Name(*val));
+ if (val->type() == nlsr::tlv::PrefixInfo) {
+ //TODO: Implement this structure as a type instead and add decoding
+ npl.insert(PrefixInfo(*val));
}
else {
NDN_THROW(Error("Name", val->type()));
@@ -117,12 +118,14 @@
{
os << " Names:\n";
int i = 0;
- for (const auto& name : m_npl.getNames()) {
- os << " Name " << i++ << ": " << name << "\n";
+ for (const auto& name : m_npl.getPrefixInfo()) {
+ os << " Name " << i << ": " << name.getName()
+ << " | Cost: " << name.getCost() << "\n";
+ i++;
}
}
-std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
NameLsa::update(const std::shared_ptr<Lsa>& lsa)
{
auto nlsa = std::static_pointer_cast<NameLsa>(lsa);
@@ -130,25 +133,31 @@
// Obtain the set difference of the current and the incoming
// name prefix sets, and add those.
+
std::list<ndn::Name> newNames = nlsa->getNpl().getNames();
std::list<ndn::Name> oldNames = m_npl.getNames();
- std::list<ndn::Name> namesToAdd;
+ std::list<ndn::Name> nameRefToAdd;
+ std::list<PrefixInfo> namesToAdd;
+
std::set_difference(newNames.begin(), newNames.end(), oldNames.begin(), oldNames.end(),
- std::inserter(namesToAdd, namesToAdd.begin()));
- for (const auto& name : namesToAdd) {
- addName(name);
+ std::inserter(nameRefToAdd, nameRefToAdd.begin()));
+ for (const auto& name : nameRefToAdd) {
+ namesToAdd.push_back(nlsa->getNpl().getPrefixInfoForName(name));
+ addName(nlsa->getNpl().getPrefixInfoForName(name));
updated = true;
}
// Also remove any names that are no longer being advertised.
- std::list<ndn::Name> namesToRemove;
+ std::list<ndn::Name> nameRefToRemove;
+ std::list<PrefixInfo> namesToRemove;
std::set_difference(oldNames.begin(), oldNames.end(), newNames.begin(), newNames.end(),
- std::inserter(namesToRemove, namesToRemove.begin()));
- for (const auto& name : namesToRemove) {
- removeName(name);
+ std::inserter(nameRefToRemove, nameRefToRemove.begin()));
+ for (const auto& name : nameRefToRemove) {
+ namesToRemove.push_back(m_npl.getPrefixInfoForName(name));
+ removeName(m_npl.getPrefixInfoForName(name));
+
updated = true;
}
-
return {updated, namesToAdd, namesToRemove};
}