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-global-router.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 UCLA
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_GLOBAL_ROUTER_H
22 #define NDN_GLOBAL_ROUTER_H
23 
24 #include "ns3/object.h"
25 #include "ns3/ptr.h"
26 
27 #include <list>
28 #include <boost/tuple/tuple.hpp>
29 
30 namespace ns3 {
31 
32 class Channel;
33 
34 namespace ndn {
35 
36 class L3Protocol;
37 class Face;
38 class Name;
39 
40 typedef Name NameComponents;
41 
46 class GlobalRouter : public Object
47 {
48 public:
52  typedef boost::tuple< Ptr< GlobalRouter >, Ptr< Face >, Ptr< GlobalRouter > > Incidency;
56  typedef std::list< Incidency > IncidencyList;
60  typedef std::list< Ptr<Name> > LocalPrefixList;
61 
67  static TypeId
68  GetTypeId ();
69 
73  GlobalRouter ();
74 
78  uint32_t
79  GetId () const;
80 
84  Ptr<L3Protocol>
85  GetL3Protocol () const;
86 
91  void
92  AddLocalPrefix (Ptr< Name > prefix);
93 
99  void
100  AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > ndn);
101 
105  IncidencyList &
106  GetIncidencies ();
107 
111  const LocalPrefixList &
112  GetLocalPrefixes () const;
113 
114  // ??
115 protected:
116  virtual void
117  NotifyNewAggregate ();
118 
119 private:
120  uint32_t m_id;
121 
122  Ptr<L3Protocol> m_ndn;
123  LocalPrefixList m_localPrefixes;
124  IncidencyList m_incidencies;
125 
126  static uint32_t m_idCounter;
127 };
128 
129 inline bool
130 operator == (const GlobalRouter::Incidency &a,
131  const GlobalRouter::Incidency &b)
132 {
133  return a.get<0> () == b.get<0> () &&
134  a.get<1> () == b.get<1> () &&
135  a.get<2> () == b.get<2> ();
136 }
137 
138 inline bool
139 operator != (const GlobalRouter::Incidency &a,
140  const GlobalRouter::Incidency &b)
141 {
142  return ! (a == b);
143 }
144 
145 } // namespace ndn
146 } // namespace ns3
147 
148 #endif // NDN_GLOBAL_ROUTER_H
const LocalPrefixList & GetLocalPrefixes() const
Get list of locally exported prefixes.
std::list< Ptr< Name > > LocalPrefixList
List of locally exported prefixes.
uint32_t GetId() const
Get numeric ID of the node (internally assigned)
virtual void NotifyNewAggregate()
Notify when the object is aggregated to another object (e.g., Node)
void AddIncidency(Ptr< Face > face, Ptr< GlobalRouter > ndn)
Add edge to the node.
Ptr< L3Protocol > GetL3Protocol() const
Helper function to get smart pointer to ndn::L3Protocol object (basically, self)
Class representing global router interface for ndnSIM.
GlobalRouter()
Default constructor.
boost::tuple< Ptr< GlobalRouter >, Ptr< Face >, Ptr< GlobalRouter > > Incidency
Graph edge.
void AddLocalPrefix(Ptr< Name > prefix)
Add new locally exported prefix.
static TypeId GetTypeId()
Interface ID.
IncidencyList & GetIncidencies()
Get list of edges that are connected to this node.
std::list< Incidency > IncidencyList
List of graph edges.