NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
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->emitSignal(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->emitSignal(onSendData, data);
73 
74  // to decouple callbacks
75  Simulator::ScheduleNow(&App::OnData, m_app, data.shared_from_this());
76 }
77 
78 void
80 {
81  this->emitSignal(onReceiveInterest, interest);
82 }
83 
84 void
86 {
87  this->emitSignal(onReceiveData, data);
88 }
89 
90 } // namespace ndn
91 } // namespace ns3
virtual void sendInterest(const Interest &interest)
Send Interest towards application.
Copyright (c) 2011-2015 Regents of the University of California.
signal::Signal< Face, Interest > onSendInterest
fires when an Interest is sent out
Definition: face.hpp:86
void onReceiveData(const Data &data)
Send Data towards NFD.
signal::Signal< Face, Data > onSendData
fires when a Data is sent out
Definition: face.hpp:89
#define emitSignal(...)
(implementation detail)
Definition: signal-emit.hpp:76
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
Definition: ndn-app.cpp:105
void fail(const std::string &reason)
fail the face and raise onFail event if it&#39;s UP; otherwise do nothing
Definition: face.cpp:87
void onReceiveInterest(const Interest &interest)
Send Interest towards NFD.
Copyright (c) 2011-2015 Regents of the University of California.
LocalFace
Definition: tcp-face.cpp:31
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:112