Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 1 | \section{Name Prefix Table} |
| 2 | \label{sec:npt} |
| 3 | |
| 4 | \begin{figure}[!h] |
| 5 | \center |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 6 | \includegraphics[width=0.8\linewidth]{npt.pdf} |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 7 | \begin{caption} |
| 8 | A diagram of the NPT and Routing Table. |
| 9 | |
| 10 | \begin{footnotesize} |
| 11 | The ``wire'' arrows represent references (i.e. ``x has y''), |
Nick Gordon | eafb2a2 | 2017-01-24 14:55:56 -0600 | [diff] [blame] | 12 | whereas the ``solid'' arrows represent inheritance (i.e. ``y subclasses x''). \\ |
| 13 | The quantification (e.g. 0..*) is standard UML. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 14 | \end{footnotesize} |
| 15 | \end{caption} |
| 16 | \label{fig:npt-class-diagram} |
| 17 | \end{figure} |
| 18 | |
| 19 | The Name Prefix Table (NPT) is used by NLSR to maintain a list of all known name prefixes advertised by other routers, including router names. |
| 20 | The NPT maintains a collection of NPT entries, where each entry represents a name prefix and all of its associated routing table entries. |
| 21 | Additionally, to optimize the storage and association of the routing table entries, the NPT also maintains a collection of duplicated routing table entries, called routing table pool entries, which have an additional use count attribute. |
| 22 | The NPT entries keep shared pointers to the appropriate routing table pool entries. |
| 23 | If a name prefix is advertised by multiple routers, the name prefix will be represented by only one Name Prefix Table Entry, but will have multiple routing table pool entries which correspond with each origin router. |
| 24 | |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 25 | If a Name LSA exists with some advertised name prefix, then that prefix must have an entry in the NPT. So, if two routers advertise the same name prefix, i.e. their name LSAs contain a common name prefix, even if one router withdraws that common name prefix, the entry must remain in the NPT, because the other router still advertises it. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 26 | |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 27 | If any type of LSA for a remote router exists in the LSDB, the remote router's name prefix must be in the NPT. |
| 28 | An NPT Entry for a router name can only be removed when there are no more LSAs in the LSDB from the origin router. Note, even if some NPT entry nas no next hops, it will \emph{not} be removed from the NPT; it may later become possible to route to this prefix. These prefixes will be removed from the FIB, however. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 29 | |
| 30 | \subsection{Adding an NPT Entry} |
| 31 | \label{sec:npt-add} |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 32 | The \texttt{NamePrefixTable::addEntry()} method is the public |
| 33 | interface for name prefixes to be added to the NPT. |
| 34 | The name prefix as well as the router's prefix which originates the |
| 35 | name prefix are passed as parameters to the method. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 36 | |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 37 | If the name prefix is new, there will be no NPT entry for it, so one |
| 38 | will be created. If the name prefix is not new, the existing entry |
| 39 | will be updated, so the existing entry will also store this new origin |
| 40 | router's prefix, too. If after updating, the NPT entry has any next |
| 41 | hops, which are associated to each of the origin router prefixes, the |
| 42 | NPT will update the FIB to include that prefix and its next hops. The |
| 43 | next hop list is sorted and truncated to be only as long as the |
| 44 | \texttt{max-faces-per-prefix} variable. |
| 45 | n |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 46 | \subsection{Removing an NPT Entry} |
| 47 | \label{sec:npt-del} |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 48 | The \texttt{NamePrefixTable::removeEntry()} method is the public |
| 49 | interface for name prefixes to be removed from the NPT. |
| 50 | The name prefix as well as the router's prefix which originates the |
| 51 | name prefix are passed as parameters to the interface. |
| 52 | |
| 53 | This method removes an origin router prefix from some advertised name |
| 54 | prefix. After this, there may be other origin routers that serve this |
| 55 | name prefix, so this does not guarantee that the NPT entry will be |
| 56 | deleted. If after updating the entry has any next hops, the NPT will |
| 57 | update the FIB to reflect the change. Since the next hop list is |
| 58 | sorted by ascending cost and its length truncated to |
| 59 | \texttt{max-faces-per-prefix}, the contents of next hop list will not |
| 60 | change if the removed origin router prefix was not already in the list |
| 61 | passed to the FIB. |
| 62 | |
| 63 | Note that even if the entry no longer has any next hops, it will be retained. All FIB entries for this prefix will be removed from the FIB, which will result in unregistrations from NFD, but the NPT entry will be retained. This is because it may become possible later to route to these origin routers again. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 64 | |
| 65 | \subsection{Updating an NPT Entry with New Routing Table Entries} |
| 66 | \label{sec:npt-update-with-new-route} |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 67 | When the Routing Table module has finished calculating, it will notify |
| 68 | the NPT using the \texttt{NamePrefixTable::updateWithNewRoute()} |
| 69 | method. |
| 70 | The NPT will then make approximately $m \times n$ calls to |
| 71 | \texttt{addEntry}, where $m$ is the number of NPT entries and $n$ is |
| 72 | the number of origin routers for each m. That is, $n$ will vary from |
| 73 | one NPT entry to the next in most cases. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 74 | |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 75 | \subsection{Routing Table Entry Pool} |
| 76 | The Name Prefix Table has an internal data structure to help |
| 77 | de-duplicate Routing Table information. Without this, each Routing |
| 78 | Table entry has to be stored $n$ times, if $n$ is the number of |
| 79 | prefixes that origin router advertises. Instead, each time a Routing |
| 80 | Table entry would be fetched, the NPT first checks its internal data |
| 81 | structure to see if that Routing Table entry is being used by another |
| 82 | NPT entry. In that case those two NPT entries can share a pointer to |
| 83 | that cached copy of the Routing Table entry. |
Nick Gordon | f3a9ecb | 2017-01-24 13:55:14 -0600 | [diff] [blame] | 84 | |
Nick Gordon | 221531c | 2017-06-08 11:44:45 -0500 | [diff] [blame] | 85 | This internal cache is smart, and will clean up from the cache unused |
| 86 | entries when they are removed from the last NPT entry. |