NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-app-link-service.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #include "ndn-app-link-service.hpp"
21 
22 #include "ns3/log.h"
23 #include "ns3/packet.h"
24 #include "ns3/node.h"
25 #include "ns3/assert.h"
26 #include "ns3/simulator.h"
27 
28 #include "apps/ndn-app.hpp"
29 
30 NS_LOG_COMPONENT_DEFINE("ndn.AppLinkService");
31 
32 namespace ns3 {
33 namespace ndn {
34 
36  : m_node(app->GetNode())
37  , m_app(app)
38 {
39  NS_LOG_FUNCTION(this << app);
40 
41  NS_ASSERT(m_app != 0);
42 }
43 
45 {
46  NS_LOG_FUNCTION_NOARGS();
47 }
48 
49 void
50 AppLinkService::doSendInterest(const Interest& interest, const nfd::EndpointId& endpoint)
51 {
52  NS_LOG_FUNCTION(this << &interest);
53 
54  // to decouple callbacks
55  Simulator::ScheduleNow(&App::OnInterest, m_app, interest.shared_from_this());
56 }
57 
58 void
59 AppLinkService::doSendData(const Data& data, const nfd::EndpointId& endpoint)
60 {
61  NS_LOG_FUNCTION(this << &data);
62 
63  // to decouple callbacks
64  Simulator::ScheduleNow(&App::OnData, m_app, data.shared_from_this());
65 }
66 
67 void
68 AppLinkService::doSendNack(const lp::Nack& nack, const nfd::EndpointId& endpoint)
69 {
70  NS_LOG_FUNCTION(this << &nack);
71 
72  // to decouple callbacks
73  Simulator::ScheduleNow(&App::OnNack, m_app, make_shared<lp::Nack>(nack));
74 }
75 
76 //
77 
78 void
80 {
81  this->receiveInterest(interest, 0);
82 }
83 
84 void
86 {
87  this->receiveData(data, 0);
88 }
89 
90 void
92 {
93  this->receiveNack(nack, 0);
94 }
95 
96 } // namespace ndn
97 } // namespace ns3
ndn-app.hpp
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-app-link-service.cpp:32
nfd::face::LinkService::receiveData
void receiveData(const Data &data, const EndpointId &endpoint)
delivers received Data to forwarding
Definition: link-service.cpp:104
ns3::ndn::AppLinkService::onReceiveNack
void onReceiveNack(const lp::Nack &nack)
Definition: ndn-app-link-service.cpp:91
ns3::ndn::App::OnData
virtual void OnData(shared_ptr< const Data > data)
Method that will be called every time new Data arrives.
Definition: ndn-app.cpp:121
ns3::ndn::App::OnNack
virtual void OnNack(shared_ptr< const lp::Nack > nack)
Method that will be called every time new Nack arrives.
Definition: ndn-app.cpp:128
ns3::ndn::AppLinkService::onReceiveInterest
void onReceiveInterest(const Interest &interest)
Definition: ndn-app-link-service.cpp:79
nfd::face::LinkService::receiveInterest
void receiveInterest(const Interest &interest, const EndpointId &endpoint)
delivers received Interest to forwarding
Definition: link-service.cpp:94
ns3::ndn::AppLinkService::onReceiveData
void onReceiveData(const Data &data)
Definition: ndn-app-link-service.cpp:85
ns3::ndn::App::OnInterest
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
Definition: ndn-app.cpp:114
ndn::tlv::Data
@ Data
Definition: tlv.hpp:66
ns3::ndn::AppLinkService::AppLinkService
AppLinkService(Ptr< App > app)
Default constructor.
Definition: ndn-app-link-service.cpp:35
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
ns3::ndn::AppLinkService::~AppLinkService
virtual ~AppLinkService()
Definition: ndn-app-link-service.cpp:44
nfd::face::EndpointId
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:65
nfd::face::LinkService::receiveNack
void receiveNack(const lp::Nack &nack, const EndpointId &endpoint)
delivers received Nack to forwarding
Definition: link-service.cpp:114
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34