NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-fib-impl.h
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 University of California, Los Angeles
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  */
20 
21 #ifndef _NDN_FIB_IMPL_H_
22 #define _NDN_FIB_IMPL_H_
23 
24 #include "ns3/ndn-fib.h"
25 #include "ns3/ndn-name.h"
26 
27 #include "../../utils/trie/trie-with-policy.h"
28 #include "../../utils/trie/counting-policy.h"
29 
30 namespace ns3 {
31 namespace ndn {
32 namespace fib {
33 
38 class EntryImpl : public Entry
39 {
40 public:
42  Name,
45  > trie;
46 
47  EntryImpl (Ptr<Fib> fib, const Ptr<const Name> &prefix)
48  : Entry (fib, prefix)
49  , item_ (0)
50  {
51  }
52 
53  void
54  SetTrie (trie::iterator item)
55  {
56  item_ = item;
57  }
58 
59  trie::iterator to_iterator () { return item_; }
60  trie::const_iterator to_iterator () const { return item_; }
61 
62 private:
63  trie::iterator item_;
64 };
65 
70 class FibImpl : public Fib,
71  protected ndnSIM::trie_with_policy< Name,
72  ndnSIM::smart_pointer_payload_traits< EntryImpl >,
73  ndnSIM::counting_policy_traits >
74 {
75 public:
79 
85  static TypeId GetTypeId ();
86 
90  FibImpl ();
91 
92  virtual Ptr<Entry>
93  LongestPrefixMatch (const Interest &interest);
94 
95  virtual Ptr<fib::Entry>
96  Find (const Name &prefix);
97 
98  virtual Ptr<Entry>
99  Add (const Name &prefix, Ptr<Face> face, int32_t metric);
100 
101  virtual Ptr<Entry>
102  Add (const Ptr<const Name> &prefix, Ptr<Face> face, int32_t metric);
103 
104  virtual void
105  Remove (const Ptr<const Name> &prefix);
106 
107  virtual void
108  InvalidateAll ();
109 
110  virtual void
111  RemoveFromAll (Ptr<Face> face);
112 
113  virtual void
114  Print (std::ostream &os) const;
115 
116  virtual uint32_t
117  GetSize () const;
118 
119  virtual Ptr<const Entry>
120  Begin () const;
121 
122  virtual Ptr<Entry>
123  Begin ();
124 
125  virtual Ptr<const Entry>
126  End () const;
127 
128  virtual Ptr<Entry>
129  End ();
130 
131  virtual Ptr<const Entry>
132  Next (Ptr<const Entry> item) const;
133 
134  virtual Ptr<Entry>
135  Next (Ptr<Entry> item);
136 
137 protected:
138  // inherited from Object class
139  virtual void NotifyNewAggregate ();
140  virtual void DoDispose ();
141 
142 private:
147  void
148  RemoveFace (super::parent_trie &item, Ptr<Face> face);
149 };
150 
151 } // namespace fib
152 } // namespace ndn
153 } // namespace ns3
154 
155 #endif /* _NDN_FIB_IMPL_H_ */
Entry(Ptr< Fib > fib, const Ptr< const Name > &prefix)
Constructor.
virtual void DoDispose()
Perform cleanup.
Definition: ndn-fib-impl.cc:67
Class for NDN Name.
Definition: name.h:29
virtual Ptr< Entry > LongestPrefixMatch(const Interest &interest)
Perform longest prefix match.
Definition: ndn-fib-impl.cc:75
FIB entry implementation with with additional references to the base container.
Definition: ndn-fib-impl.h:38
Class implementing FIB functionality.
Definition: ndn-fib-impl.h:70
Structure for FIB table entry, holding indexed list of available faces and their respective metrics...
virtual Ptr< const Entry > Begin() const
Return first element of FIB (no order guaranteed)
Traits for policy that just keeps track of number of elements It's doing a rather expensive job...
virtual void InvalidateAll()
Invalidate all FIB entries.
virtual void NotifyNewAggregate()
Notify when object is aggregated.
Definition: ndn-fib-impl.cc:61
virtual Ptr< fib::Entry > Find(const Name &prefix)
Get FIB entry for the prefix (exact match)
Definition: ndn-fib-impl.cc:87
FibImpl()
Constructor.
Definition: ndn-fib-impl.cc:56
virtual Ptr< Entry > Add(const Name &prefix, Ptr< Face > face, int32_t metric)
Add or update FIB entry.
Definition: ndn-fib-impl.cc:99
virtual uint32_t GetSize() const
Get number of entries in FIB.
static TypeId GetTypeId()
Interface ID.
Definition: ndn-fib-impl.cc:46
virtual void Print(std::ostream &os) const
Print out entries in FIB.
Class implementing FIB functionality.
Definition: ndn-fib.h:44
virtual void RemoveFromAll(Ptr< Face > face)
Remove all references to a face from FIB.
NDN Interest (wire formats are defined in wire)
Definition: ndn-interest.h:43
virtual Ptr< const Entry > End() const
Return item next after last (no order guaranteed)
virtual void Remove(const Ptr< const Name > &prefix)
Remove FIB entry.