NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
notification-stream.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
48 #ifndef NDN_UTIL_NOTIFICATION_STREAM_HPP
49 #define NDN_UTIL_NOTIFICATION_STREAM_HPP
50 
51 #include "../name.hpp"
52 #include "../face.hpp"
53 #include "../security/key-chain.hpp"
54 
55 #include "concepts.hpp"
56 
57 namespace ndn {
58 
59 namespace util {
60 
64 template<typename Notification>
65 class NotificationStream : noncopyable
66 {
67 public:
68  BOOST_CONCEPT_ASSERT((WireEncodable<Notification>));
69 
70  NotificationStream(Face& face, const Name& prefix, KeyChain& keyChain)
71  : m_face(face)
72  , m_prefix(prefix)
73  , m_keyChain(keyChain)
74  , m_sequenceNo(0)
75  {
76  }
77 
78  virtual
80  {
81  }
82 
83  void
84  postNotification(const Notification& notification)
85  {
86  Name dataName = m_prefix;
87  dataName.appendSequenceNumber(m_sequenceNo);
88 
89  shared_ptr<Data> data = make_shared<Data>(dataName);
90  data->setContent(notification.wireEncode());
91  data->setFreshnessPeriod(time::seconds(1));
92 
93  m_keyChain.sign(*data);
94  m_face.put(*data);
95 
96  ++m_sequenceNo;
97  }
98 
99 private:
100  Face& m_face;
101  const Name m_prefix;
102  KeyChain& m_keyChain;
103  uint64_t m_sequenceNo;
104 };
105 
106 } // namespace util
107 } // namespace ndn
108 
109 #endif // NDN_UTIL_NOTIFICATION_STREAM_HPP
Copyright (c) 2011-2015 Regents of the University of California.
provides a publisher of Notification Stream
The packet signing interface.
Definition: key-chain.hpp:48
void sign(Data &data, const SigningInfo &params=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
Definition: key-chain.cpp:517
Name & appendSequenceNumber(uint64_t seqNo)
Append sequence number using NDN naming conventions.
Definition: name.cpp:253
void postNotification(const Notification &notification)
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:100
NotificationStream(Face &face, const Name &prefix, KeyChain &keyChain)
Name abstraction to represent an absolute name.
Definition: name.hpp:46
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:34
void put(const Data &data)
Publish data packet.
Definition: face.cpp:87