NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
segment-fetcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_UTIL_SEGMENT_FETCHER_HPP
23 #define NDN_UTIL_SEGMENT_FETCHER_HPP
24 
25 #include "scheduler.hpp"
26 #include "../common.hpp"
27 #include "../face.hpp"
28 #include "../security/validator.hpp"
29 
30 namespace ndn {
31 
32 class OBufferStream;
33 
34 namespace util {
35 
101 class SegmentFetcher : noncopyable
102 {
103 public:
107  static const uint32_t MAX_INTEREST_REEXPRESS;
108 
109  typedef function<void (const ConstBufferPtr& data)> CompleteCallback;
110  typedef function<void (uint32_t code, const std::string& msg)> ErrorCallback;
111 
115  enum ErrorCode {
120  };
121 
139  static
140  void
141  fetch(Face& face,
142  const Interest& baseInterest,
143  Validator& validator,
144  const CompleteCallback& completeCallback,
145  const ErrorCallback& errorCallback);
146 
162  static
163  void
164  fetch(Face& face,
165  const Interest& baseInterest,
166  shared_ptr<Validator> validator,
167  const CompleteCallback& completeCallback,
168  const ErrorCallback& errorCallback);
169 
170 private:
172  shared_ptr<Validator> validator,
173  const CompleteCallback& completeCallback,
174  const ErrorCallback& errorCallback);
175 
176  void
177  fetchFirstSegment(const Interest& baseInterest, shared_ptr<SegmentFetcher> self);
178 
179  void
180  fetchNextSegment(const Interest& origInterest, const Name& dataName, uint64_t segmentNo,
181  shared_ptr<SegmentFetcher> self);
182 
183  void
184  afterSegmentReceived(const Interest& origInterest,
185  const Data& data, bool isSegmentZeroExpected,
186  shared_ptr<SegmentFetcher> self);
187  void
188  afterValidationSuccess(const shared_ptr<const Data> data,
189  bool isSegmentZeroExpected,
190  const Interest& origInterest,
191  shared_ptr<SegmentFetcher> self);
192 
193  void
194  afterValidationFailure(const shared_ptr<const Data> data);
195 
196  void
197  afterNackReceived(const Interest& origInterest, const lp::Nack& nack,
198  uint32_t reExpressCount, shared_ptr<SegmentFetcher> self);
199 
200  void
201  reExpressInterest(Interest interest, uint32_t reExpressCount,
202  shared_ptr<SegmentFetcher> self);
203 
204 private:
205  Face& m_face;
206  Scheduler m_scheduler;
207  shared_ptr<Validator> m_validator;
208  CompleteCallback m_completeCallback;
209  ErrorCallback m_errorCallback;
210 
211  shared_ptr<OBufferStream> m_buffer;
212 };
213 
214 } // namespace util
215 } // namespace ndn
216 
217 #endif // NDN_UTIL_SEGMENT_FETCHER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
function< void(uint32_t code, const std::string &msg)> ErrorCallback
Utility class to fetch latest version of the segmented data.
represents an Interest packet
Definition: interest.hpp:45
represents a Network Nack
Definition: nack.hpp:40
ErrorCode
Error codes that can be passed to ErrorCallback.
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:119
Name abstraction to represent an absolute name.
Definition: name.hpp:46
static void fetch(Face &face, const Interest &baseInterest, Validator &validator, const CompleteCallback &completeCallback, const ErrorCallback &errorCallback)
Initiate segment fetching.
static const uint32_t MAX_INTEREST_REEXPRESS
Maximum number of times an interest will be reexpressed incase of NackCallback.
represents a Data packet
Definition: data.hpp:39
Validator is one of the main classes of the security library.
Definition: validator.hpp:46
function< void(const ConstBufferPtr &data)> CompleteCallback