NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef NFD_DAEMON_TABLE_FIB_HPP
27 #define NFD_DAEMON_TABLE_FIB_HPP
28 
29 #include "fib-entry.hpp"
30 #include "name-tree.hpp"
31 
32 #include "core/fib-max-depth.hpp"
33 
34 #include <boost/range/adaptor/transformed.hpp>
35 
36 namespace nfd {
37 
38 namespace measurements {
39 class Entry;
40 } // namespace measurements
41 namespace pit {
42 class Entry;
43 } // namespace pit
44 
45 namespace fib {
46 
49 class Fib : noncopyable
50 {
51 public:
52  explicit
53  Fib(NameTree& nameTree);
54 
55  size_t
56  size() const
57  {
58  return m_nItems;
59  }
60 
61 public: // lookup
64  const Entry&
65  findLongestPrefixMatch(const Name& prefix) const;
66 
71  const Entry&
72  findLongestPrefixMatch(const pit::Entry& pitEntry) const;
73 
78  const Entry&
79  findLongestPrefixMatch(const measurements::Entry& measurementsEntry) const;
80 
83  Entry*
84  findExactMatch(const Name& prefix);
85 
86 public: // mutation
89  static constexpr size_t
91  {
92  return FIB_MAX_DEPTH;
93  }
94 
99  std::pair<Entry*, bool>
100  insert(const Name& prefix);
101 
102  void
103  erase(const Name& prefix);
104 
105  void
106  erase(const Entry& entry);
107 
110  void
111  removeNextHop(Entry& entry, const Face& face, uint64_t endpointId);
112 
115  void
116  removeNextHopByFace(Entry& entry, const Face& face);
117 
118 public: // enumeration
119  typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
120  typedef boost::range_iterator<Range>::type const_iterator;
121 
128  begin() const
129  {
130  return this->getRange().begin();
131  }
132 
137  end() const
138  {
139  return this->getRange().end();
140  }
141 
142 private:
145  template<typename K>
146  const Entry&
147  findLongestPrefixMatchImpl(const K& key) const;
148 
149  void
150  erase(name_tree::Entry* nte, bool canDeleteNte = true);
151 
154  void
155  eraseIfEmpty(Entry& entry);
156 
157  Range
158  getRange() const;
159 
160 private:
161  NameTree& m_nameTree;
162  size_t m_nItems;
163 
169  static const unique_ptr<Entry> s_emptyEntry;
170 };
171 
172 } // namespace fib
173 
174 using fib::Fib;
175 
176 } // namespace nfd
177 
178 #endif // NFD_DAEMON_TABLE_FIB_HPP
void removeNextHopByFace(Entry &entry, const Face &face)
removes the NextHop record for face for any endpointId
Definition: fib.cpp:153
std::pair< Entry *, bool > insert(const Name &prefix)
find or insert a FIB entry
Definition: fib.cpp:91
Fib(NameTree &nameTree)
Definition: fib.cpp:45
Entry * findExactMatch(const Name &prefix)
performs an exact match lookup
Definition: fib.cpp:81
void erase(const Name &prefix)
Definition: fib.cpp:117
generalization of a network interface
Definition: face.hpp:67
represents a FIB entry
Definition: fib-entry.hpp:51
const_iterator end() const
Definition: fib.hpp:137
static constexpr size_t getMaxDepth()
Maximum number of components in a FIB entry prefix.
Definition: fib.hpp:90
const Entry & findLongestPrefixMatch(const Name &prefix) const
performs a longest prefix match
Definition: fib.cpp:63
represents a Measurements entry
void removeNextHop(Entry &entry, const Face &face, uint64_t endpointId)
removes the NextHop record for face with a given endpointId
Definition: fib.cpp:146
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:59
represents the Forwarding Information Base (FIB)
Definition: fib.hpp:49
const_iterator begin() const
Definition: fib.hpp:128
Represents an absolute name.
Definition: name.hpp:43
boost::range_iterator< Range >::type const_iterator
Definition: fib.hpp:120
static const int FIB_MAX_DEPTH
Maximum number of components in a FIB entry prefix.
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:38
boost::iterator_range< Iterator > Range
a Forward Range of name tree entries
size_t size() const
Definition: fib.hpp:56
boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::Range > Range
Definition: fib.hpp:119
an entry in the name tree