23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
26 #include "ns3/ndn-interest.h"
27 #include "ns3/ndn-data.h"
28 #include "ns3/ndn-l3-protocol.h"
29 #include "ns3/ndn-fib.h"
30 #include "ns3/ndn-app-face.h"
31 #include "ns3/ndn-forwarding-strategy.h"
33 NS_LOG_COMPONENT_DEFINE (
"ndn.App");
38 NS_OBJECT_ENSURE_REGISTERED (App);
43 static TypeId tid = TypeId (
"ns3::ndn::App")
45 .SetParent<Application> ()
46 .AddConstructor<App> ()
48 .AddTraceSource (
"ReceivedInterests",
"ReceivedInterests",
51 .AddTraceSource (
"ReceivedNacks",
"ReceivedNacks",
54 .AddTraceSource (
"ReceivedDatas",
"ReceivedDatas",
57 .AddTraceSource (
"TransmittedInterests",
"TransmittedInterests",
60 .AddTraceSource (
"TransmittedDatas",
"TransmittedDatas",
79 NS_LOG_FUNCTION_NOARGS ();
84 Application::DoDispose ();
99 NS_LOG_FUNCTION (
this << interest);
106 NS_LOG_FUNCTION (
this << interest);
113 NS_LOG_FUNCTION (
this << contentObject);
121 NS_LOG_FUNCTION_NOARGS ();
126 NS_ASSERT_MSG (GetNode ()->GetObject<L3Protocol> () != 0,
127 "Ndn stack should be installed on the node " << GetNode ());
130 m_face = CreateObject<AppFace> (
this);
142 NS_LOG_FUNCTION_NOARGS ();
146 NS_ASSERT (GetNode ()->GetObject<L3Protocol> () != 0);
157 if (
m_face->GetReferenceCount () != 1)
159 NS_LOG_ERROR (
"Please a bug report on https://github.com/NDN-Routing/ndnSIM/issues");
160 NS_LOG_ERROR (
"At this point, nobody else should have referenced this face, but we have "
161 <<
m_face->GetReferenceCount () <<
" references");
bool m_active
Flag to indicate that application is active (set by StartApplication and StopApplication) ...
virtual void DoDispose()
Do cleanup when application is destroyed.
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_receivedNacks
App-level trace of received NACKs.
virtual void StartApplication()
Called at time specified by Start.
uint32_t GetId() const
Get application ID (ID of applications face)
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_transmittedInterests
App-level trace of transmitted Interests.
Implementation network-layer of NDN stack.
TracedCallback< Ptr< const Data >, Ptr< App >, Ptr< Face > > m_receivedDatas
App-level trace of received Data.
virtual void OnNack(Ptr< const Interest > interest)
Method that will be called every time new NACK arrives.
virtual void OnData(Ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
virtual void StopApplication()
Called at time specified by Stop.
virtual void OnInterest(Ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
App()
Default constructor.
Ptr< Face > m_face
automatically created application face through which application communicates
TracedCallback< Ptr< const Interest >, Ptr< App >, Ptr< Face > > m_receivedInterests
App-level trace of received Interests.
TracedCallback< Ptr< const Data >, Ptr< App >, Ptr< Face > > m_transmittedDatas
App-level trace of transmitted Data.