NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndn-app-face.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #include "ndn-app-face.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.AppFace");
31 
32 namespace ns3 {
33 namespace ndn {
34 
35 AppFace::AppFace(Ptr<App> app)
36  : LocalFace(FaceUri("appFace://"), FaceUri("appFace://"))
37  , m_node(app->GetNode())
38  , m_app(app)
39 {
40  NS_LOG_FUNCTION(this << app);
41 
42  NS_ASSERT(m_app != 0);
43 }
44 
46 {
47  NS_LOG_FUNCTION_NOARGS();
48 }
49 
50 void
52 {
53  this->fail("Close connection");
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION(this << &interest);
60 
61  this->onSendInterest(interest);
62 
63  // to decouple callbacks
64  Simulator::ScheduleNow(&App::OnInterest, m_app, interest.shared_from_this());
65 }
66 
67 void
68 AppFace::sendData(const Data& data)
69 {
70  NS_LOG_FUNCTION(this << &data);
71 
72  this->onSendData(data);
73 
74  // to decouple callbacks
75  Simulator::ScheduleNow(&App::OnData, m_app, data.shared_from_this());
76 }
77 
78 } // namespace ndn
79 } // namespace ns3
virtual void sendInterest(const Interest &interest)
Send Interest towards application.
EventEmitter< Interest > onSendInterest
fires when an Interest is sent out
Definition: face.hpp:87
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
Definition: ndn-app.cpp:88
void fail(const std::string &reason)
fail the face and raise onFail event if it's UP; otherwise do nothing
Definition: face.cpp:116
EventEmitter< Data > onSendData
fires when a Data is sent out
Definition: face.hpp:90
virtual void sendData(const Data &data)
Send Data towards application.
virtual void close()
Close the face.
AppFace(Ptr< App > app)
Default constructor.
virtual void OnData(shared_ptr< const Data > data)
Method that will be called every time new Data arrives.
Definition: ndn-app.cpp:95