22 #include "ns3/assert.h" 23 #include "ns3/packet.h" 29 NS_LOG_COMPONENT_DEFINE(
"ndn.App");
39 static TypeId tid = TypeId(
"ns3::ndn::App")
41 .SetParent<Application>()
42 .AddConstructor<App>()
44 .AddTraceSource(
"ReceivedInterests",
"ReceivedInterests",
46 "ns3::ndn::App::InterestTraceCallback")
48 .AddTraceSource(
"ReceivedDatas",
"ReceivedDatas",
50 "ns3::ndn::App::DataTraceCallback")
52 .AddTraceSource(
"ReceivedNacks",
"ReceivedNacks",
54 "ns3::ndn::App::NackTraceCallback")
56 .AddTraceSource(
"TransmittedInterests",
"TransmittedInterests",
58 "ns3::ndn::App::InterestTraceCallback")
60 .AddTraceSource(
"TransmittedDatas",
"TransmittedDatas",
62 "ns3::ndn::App::DataTraceCallback")
64 .AddTraceSource(
"TransmittedNacks",
"TransmittedNacks",
66 "ns3::ndn::App::NackTraceCallback");
73 ,
m_appId(
std::numeric_limits<uint32_t>::max())
84 NS_LOG_FUNCTION_NOARGS();
87 for (uint32_t
id = 0;
id < GetNode()->GetNApplications(); ++id) {
88 if (GetNode()->GetApplication(
id) ==
this) {
93 Application::DoInitialize();
99 NS_LOG_FUNCTION_NOARGS();
104 Application::DoDispose();
116 NS_LOG_FUNCTION(
this << interest);
123 NS_LOG_FUNCTION(
this << data);
130 NS_LOG_FUNCTION(
this << nack);
140 NS_LOG_FUNCTION_NOARGS();
145 NS_ASSERT_MSG(GetNode()->GetObject<L3Protocol>() != 0,
146 "Ndn stack should be installed on the node " << GetNode());
149 auto appLink = make_unique<AppLinkService>(
this);
150 auto transport = make_unique<NullTransport>(
"appFace://",
"appFace://",
153 m_face = std::make_shared<Face>(std::move(appLink), std::move(transport));
155 m_face->setMetric(1);
158 GetNode()->GetObject<
L3Protocol>()->addFace(m_face);
164 NS_LOG_FUNCTION_NOARGS();
TracedCallback< shared_ptr< const lp::Nack >, Ptr< App >, shared_ptr< Face > > m_receivedNacks
App-level trace of received Nacks.
Copyright (c) 2011-2015 Regents of the University of California.
virtual void StopApplication()
Called at time specified by Stop.
Implementation of LinkService for ndnSIM application.
TracedCallback< shared_ptr< const lp::Nack >, Ptr< App >, shared_ptr< Face > > m_transmittedNacks
App-level trace of transmitted Nacks.
ndn App
Copyright (c) 2011-2015 Regents of the University of California.
NS_OBJECT_ENSURE_REGISTERED(ContentStore)
virtual void DoInitialize()
virtual void StartApplication()
Called at time specified by Start.
TracedCallback< shared_ptr< const Interest >, Ptr< App >, shared_ptr< Face > > m_receivedInterests
App-level trace of received Interests.
static TypeId GetTypeId()
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
virtual void OnNack(shared_ptr< const lp::Nack > nack)
Method that will be called every time new Nack arrives.
Copyright (c) 2011-2015 Regents of the University of California.
TracedCallback< shared_ptr< const Interest >, Ptr< App >, shared_ptr< Face > > m_transmittedInterests
App-level trace of transmitted Interests.
shared_ptr< Face > m_face
TracedCallback< shared_ptr< const Data >, Ptr< App >, shared_ptr< Face > > m_transmittedDatas
App-level trace of transmitted Data.
Implementation network-layer of NDN stack.
AppLinkService * m_appLink
App()
Default constructor.
TracedCallback< shared_ptr< const Data >, Ptr< App >, shared_ptr< Face > > m_receivedDatas
App-level trace of received Data.
bool m_active
Flag to indicate that application is active (set by StartApplication and StopApplication) ...
virtual void OnData(shared_ptr< const Data > data)
Method that will be called every time new Data arrives.
uint32_t GetId() const
Get application ID (ID of applications face)