Junxiao Shi | 9b0d3e9 | 2014-02-15 12:27:12 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_FACE_NDNLP_SLICER_HPP |
| 8 | #define NFD_FACE_NDNLP_SLICER_HPP |
| 9 | |
| 10 | #include "ndnlp-tlv.hpp" |
| 11 | #include "ndnlp-sequence-generator.hpp" |
| 12 | |
| 13 | namespace nfd { |
| 14 | namespace ndnlp { |
| 15 | |
| 16 | typedef shared_ptr<std::vector<Block> > PacketArray; |
| 17 | |
| 18 | /** \brief provides fragmentation feature at sender |
| 19 | */ |
| 20 | class Slicer : noncopyable |
| 21 | { |
| 22 | public: |
| 23 | explicit |
| 24 | Slicer(size_t mtu); |
| 25 | |
| 26 | virtual |
| 27 | ~Slicer(); |
| 28 | |
| 29 | PacketArray |
| 30 | slice(const Block& block); |
| 31 | |
| 32 | private: |
| 33 | /// estimate the size of NDNLP header and maximum payload size per packet |
| 34 | void |
| 35 | estimateOverhead(); |
| 36 | |
| 37 | private: |
| 38 | SequenceGenerator m_seqgen; |
| 39 | |
| 40 | /// maximum packet size |
| 41 | size_t m_mtu; |
| 42 | |
| 43 | /// maximum payload size |
| 44 | size_t m_maxPayload; |
| 45 | }; |
| 46 | |
| 47 | } // namespace ndnlp |
| 48 | } // namespace nfd |
| 49 | |
| 50 | #endif // NFD_FACE_NDNLP_SLICER_HPP |