NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndnlp-partial-message-store.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
27 #define NFD_DAEMON_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
28 
29 #include "ndnlp-data.hpp"
30 #include "core/scheduler.hpp"
31 
32 namespace nfd {
33 namespace ndnlp {
34 
38 {
39 public:
41 
42  PartialMessage(const PartialMessage&) = delete;
43 
45  operator=(const PartialMessage&) = delete;
46 
47  PartialMessage(PartialMessage&&) = default;
48 
50  operator=(PartialMessage&&) = default;
51 
52  bool
53  add(uint16_t fragIndex, uint16_t fragCount, const Block& payload);
54 
55  bool
56  isComplete() const;
57 
62  std::tuple<bool, Block>
63  reassemble();
64 
69  static std::tuple<bool, Block>
70  reassembleSingle(const NdnlpData& fragment);
71 
72 public:
74 
75 private:
76  size_t m_fragCount;
77  size_t m_received;
78  std::vector<Block> m_payloads;
79  size_t m_totalLength;
80 };
81 
84 class PartialMessageStore : noncopyable
85 {
86 public:
87  explicit
88  PartialMessageStore(const time::nanoseconds& idleDuration = time::milliseconds(100));
89 
94  void
95  receive(const NdnlpData& pkt);
96 
100 
101 private:
102  void
103  scheduleCleanup(uint64_t messageIdentifier, PartialMessage& partialMessage);
104 
105  void
106  cleanup(uint64_t messageIdentifier);
107 
108 private:
109  std::unordered_map<uint64_t, PartialMessage> m_partialMessages;
110 
111  time::nanoseconds m_idleDuration;
112 };
113 
114 } // namespace ndnlp
115 } // namespace nfd
116 
117 #endif // NFD_DAEMON_FACE_NDNLP_PARTIAL_MESSAGE_STORE_HPP
bool add(uint16_t fragIndex, uint16_t fragCount, const Block &payload)
PartialMessage & operator=(const PartialMessage &)=delete
static std::tuple< bool, Block > reassembleSingle(const NdnlpData &fragment)
reassemble network layer packet from a single fragment
represents a NdnlpData packet
Definition: ndnlp-data.hpp:43
signal::Signal< PartialMessageStore, Block > onReceive
fires when network layer packet is received
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
represents a partially received message
provides a lightweight signal / event system
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
cancels an event automatically upon destruction
Definition: scheduler.hpp:53
std::tuple< bool, Block > reassemble()
reassemble network layer packet
PartialMessageStore(const time::nanoseconds &idleDuration=time::milliseconds(100))
provides reassembly feature at receiver
void receive(const NdnlpData &pkt)
receive a NdnlpData packet