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-app.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_APP_H
22 #define NDN_APP_H
23 
24 #include "ns3/application.h"
25 #include "ns3/ptr.h"
26 #include "ns3/callback.h"
27 #include "ns3/traced-callback.h"
28 
29 namespace ns3 {
30 
31 class Packet;
32 
33 namespace ndn {
34 
35 class Interest;
36 class Data;
37 
38 class Face;
39 
50 class App: public Application
51 {
52 public:
53  static TypeId GetTypeId ();
54 
58  App ();
59  virtual ~App ();
60 
64  uint32_t
65  GetId () const;
66 
73  virtual void
74  OnInterest (Ptr<const Interest> interest);
75 
80  virtual void
81  OnNack (Ptr<const Interest> interest);
82 
88  virtual void
89  OnData (Ptr<const Data> contentObject);
90 
91 protected:
95  virtual void
96  DoDispose ();
97 
98  // inherited from Application base class. Originally they were private
99  virtual void
100  StartApplication ();
101 
102  virtual void
103  StopApplication ();
104 
105 protected:
106  bool m_active;
107  Ptr<Face> m_face;
108 
109  TracedCallback<Ptr<const Interest>,
110  Ptr<App>, Ptr<Face> > m_receivedInterests;
111 
112  TracedCallback<Ptr<const Interest>,
113  Ptr<App>, Ptr<Face> > m_receivedNacks;
114 
115  TracedCallback<Ptr<const Data>,
116  Ptr<App>, Ptr<Face> > m_receivedDatas;
117 
118 
119  TracedCallback<Ptr<const Interest>,
120  Ptr<App>, Ptr<Face> > m_transmittedInterests;
121 
122  TracedCallback<Ptr<const Data>,
123  Ptr<App>, Ptr<Face> > m_transmittedDatas;
124 };
125 
126 } // namespace ndn
127 } // namespace ns3
128 
129 #endif // NDN_APP_H
bool m_active
Flag to indicate that application is active (set by StartApplication and StopApplication) ...
Definition: ndn-app.h:106
virtual void DoDispose()
Do cleanup when application is destroyed.
Definition: ndn-app.cc:77
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_receivedNacks
App-level trace of received NACKs.
Definition: ndn-app.h:113
virtual void StartApplication()
Called at time specified by Start.
Definition: ndn-app.cc:119
uint32_t GetId() const
Get application ID (ID of applications face)
Definition: ndn-app.cc:88
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_transmittedInterests
App-level trace of transmitted Interests.
Definition: ndn-app.h:120
Base class that all NDN applications should be derived from.
Definition: ndn-app.h:50
TracedCallback< Ptr< const Data >, Ptr< App >, Ptr< Face > > m_receivedDatas
App-level trace of received Data.
Definition: ndn-app.h:116
virtual void OnNack(Ptr< const Interest > interest)
Method that will be called every time new NACK arrives.
Definition: ndn-app.cc:104
virtual void OnData(Ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
Definition: ndn-app.cc:111
virtual void StopApplication()
Called at time specified by Stop.
Definition: ndn-app.cc:140
virtual void OnInterest(Ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
Definition: ndn-app.cc:97
App()
Default constructor.
Definition: ndn-app.cc:66
Ptr< Face > m_face
automatically created application face through which application communicates
Definition: ndn-app.h:107
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_receivedInterests
App-level trace of received Interests.
Definition: ndn-app.h:110
TracedCallback< Ptr< const Data >, Ptr< App >, Ptr< Face > > m_transmittedDatas
App-level trace of transmitted Data.
Definition: ndn-app.h:123