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-pit.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_PIT_H_
22 #define _NDN_PIT_H_
23 
24 #include "ns3/object.h"
25 #include "ns3/nstime.h"
26 #include "ns3/event-id.h"
27 
28 #include "ndn-pit-entry.h"
29 
30 namespace ns3 {
31 namespace ndn {
32 
42 namespace pit {
43 }
44 
45 class L3Protocol;
46 class Face;
47 class Data;
48 class Interest;
49 
50 typedef Interest InterestHeader;
51 typedef Data DataHeader;
52 
55 
60 class Pit : public Object
61 {
62 public:
68  static TypeId GetTypeId ();
69 
73  Pit ();
74 
78  virtual ~Pit ();
79 
91  virtual Ptr<pit::Entry>
92  Lookup (const Data &header) = 0;
93 
100  virtual Ptr<pit::Entry>
101  Lookup (const Interest &header) = 0;
102 
109  virtual Ptr<pit::Entry>
110  Find (const Name &prefix) = 0;
111 
120  virtual Ptr<pit::Entry>
121  Create (Ptr<const Interest> header) = 0;
122 
130  virtual void
131  MarkErased (Ptr<pit::Entry> entry) = 0;
132 
138  virtual void
139  Print (std::ostream &os) const = 0;
140 
144  virtual uint32_t
145  GetSize () const = 0;
146 
150  virtual Ptr<pit::Entry>
151  Begin () = 0;
152 
156  virtual Ptr<pit::Entry>
157  End () = 0;
158 
162  virtual Ptr<pit::Entry>
163  Next (Ptr<pit::Entry>) = 0;
164 
168 
172  static inline Ptr<Pit>
173  GetPit (Ptr<Object> node);
174 
178  inline const Time&
179  GetMaxPitEntryLifetime () const;
180 
184  inline void
185  SetMaxPitEntryLifetime (const Time &maxLifetime);
186 
187 protected:
188  // configuration variables. Check implementation of GetTypeId for more details
189  Time m_PitEntryPruningTimout;
190 
191  Time m_maxPitEntryLifetime;
192 };
193 
196 
197 inline std::ostream&
198 operator<< (std::ostream& os, const Pit &pit)
199 {
200  pit.Print (os);
201  return os;
202 }
203 
204 inline Ptr<Pit>
205 Pit::GetPit (Ptr<Object> node)
206 {
207  return node->GetObject<Pit> ();
208 }
209 
210 inline const Time&
212 {
213  return m_maxPitEntryLifetime;
214 }
215 
216 inline void
217 Pit::SetMaxPitEntryLifetime (const Time &maxLifetime)
218 {
219  m_maxPitEntryLifetime = maxLifetime;
220 }
221 
222 
223 } // namespace ndn
224 } // namespace ns3
225 
226 #endif /* NDN_PIT_H */
Class for NDN Name.
Definition: name.h:29
virtual Ptr< pit::Entry > Lookup(const Data &header)=0
Find corresponding PIT entry for the given content name.
virtual void Print(std::ostream &os) const =0
Print out PIT contents for debugging purposes.
Class implementing Pending Interests Table.
Definition: ndn-pit.h:60
virtual uint32_t GetSize() const =0
Get number of entries in PIT.
const Time & GetMaxPitEntryLifetime() const
Get maximum PIT entry lifetime.
Definition: ndn-pit.h:211
Pit()
PIT constructor.
Definition: ndn-pit.cc:66
virtual Ptr< pit::Entry > Begin()=0
Return first element of FIB (no order guaranteed)
Data header.
Definition: ndn-data.h:39
virtual void MarkErased(Ptr< pit::Entry > entry)=0
Mark PIT entry deleted.
virtual Ptr< pit::Entry > Next(Ptr< pit::Entry >)=0
Advance the iterator.
static TypeId GetTypeId()
Interface ID.
Definition: ndn-pit.cc:43
virtual Ptr< pit::Entry > Find(const Name &prefix)=0
Get PIT entry for the prefix (exact match)
static Ptr< Pit > GetPit(Ptr< Object > node)
Static call to cheat python bindings.
Definition: ndn-pit.h:205
NDN Interest (wire formats are defined in wire)
Definition: ndn-interest.h:43
virtual Ptr< pit::Entry > End()=0
Return item next after last (no order guaranteed)
void SetMaxPitEntryLifetime(const Time &maxLifetime)
Set maximum PIT entry lifetime.
Definition: ndn-pit.h:217
virtual Ptr< pit::Entry > Create(Ptr< const Interest > header)=0
Creates a PIT entry for the given interest.
virtual ~Pit()
Destructor.
Definition: ndn-pit.cc:70