blob: 716cddc1d7de8e34ad4b911fc6f56f931de4b84b [file] [log] [blame]
Junxiao Shi9b0d3e92014-02-15 12:27:12 -07001/* -*- 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
13namespace nfd {
14namespace ndnlp {
15
16typedef shared_ptr<std::vector<Block> > PacketArray;
17
18/** \brief provides fragmentation feature at sender
19 */
20class Slicer : noncopyable
21{
22public:
23 explicit
24 Slicer(size_t mtu);
Junxiao Shidf3b4382014-02-23 11:28:21 -070025
Junxiao Shi9b0d3e92014-02-15 12:27:12 -070026 virtual
27 ~Slicer();
Junxiao Shidf3b4382014-02-23 11:28:21 -070028
Junxiao Shi9b0d3e92014-02-15 12:27:12 -070029 PacketArray
30 slice(const Block& block);
31
32private:
33 /// estimate the size of NDNLP header and maximum payload size per packet
34 void
35 estimateOverhead();
Junxiao Shidf3b4382014-02-23 11:28:21 -070036
Junxiao Shi9b0d3e92014-02-15 12:27:12 -070037private:
38 SequenceGenerator m_seqgen;
Junxiao Shidf3b4382014-02-23 11:28:21 -070039
Junxiao Shi9b0d3e92014-02-15 12:27:12 -070040 /// maximum packet size
41 size_t m_mtu;
Junxiao Shidf3b4382014-02-23 11:28:21 -070042
Junxiao Shi9b0d3e92014-02-15 12:27:12 -070043 /// maximum payload size
44 size_t m_maxPayload;
45};
46
47} // namespace ndnlp
48} // namespace nfd
49
50#endif // NFD_FACE_NDNLP_SLICER_HPP