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(
"TransmittedInterests",
"TransmittedInterests",
54 "ns3::ndn::App::InterestTraceCallback")
56 .AddTraceSource(
"TransmittedDatas",
"TransmittedDatas",
58 "ns3::ndn::App::DataTraceCallback");
65 ,
m_appId(
std::numeric_limits<uint32_t>::max())
76 NS_LOG_FUNCTION_NOARGS();
79 for (uint32_t
id = 0;
id < GetNode()->GetNApplications(); ++id) {
80 if (GetNode()->GetApplication(
id) ==
this) {
85 Application::DoInitialize();
91 NS_LOG_FUNCTION_NOARGS();
96 Application::DoDispose();
108 NS_LOG_FUNCTION(
this << interest);
115 NS_LOG_FUNCTION(
this << data);
122 NS_LOG_FUNCTION(
this << nack);
132 NS_LOG_FUNCTION_NOARGS();
137 NS_ASSERT_MSG(GetNode()->GetObject<L3Protocol>() != 0,
138 "Ndn stack should be installed on the node " << GetNode());
141 auto appLink = make_unique<AppLinkService>(
this);
142 auto transport = make_unique<NullTransport>(
"appFace://",
"appFace://",
145 m_face = std::make_shared<Face>(std::move(appLink), std::move(transport));
147 m_face->setMetric(1);
150 GetNode()->GetObject<
L3Protocol>()->addFace(m_face);
156 NS_LOG_FUNCTION_NOARGS();
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.
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.
uint32_t GetId() const
Get application ID (ID of applications face)
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.