27 #include <ndn-cxx/lp/tags.hpp> 35 : allowLocalFields(false)
36 , allowFragmentation(false)
37 , allowReassembly(false)
62 GenericLinkService::requestIdlePacket()
66 this->sendLpPacket({});
70 GenericLinkService::sendLpPacket(
lp::Packet&& pkt)
78 if (mtu !=
MTU_UNLIMITED && tp.packet.size() >
static_cast<size_t>(mtu)) {
87 GenericLinkService::doSendInterest(
const Interest& interest)
91 encodeLpFields(interest, lpPacket);
93 this->sendNetPacket(std::move(lpPacket));
97 GenericLinkService::doSendData(
const Data& data)
101 encodeLpFields(data, lpPacket);
103 this->sendNetPacket(std::move(lpPacket));
107 GenericLinkService::doSendNack(
const lp::Nack& nack)
112 encodeLpFields(nack, lpPacket);
114 this->sendNetPacket(std::move(lpPacket));
122 if (incomingFaceIdTag !=
nullptr) {
128 if (congestionMarkTag !=
nullptr) {
133 if (hopCountTag !=
nullptr) {
142 GenericLinkService::sendNetPacket(
lp::Packet&& pkt)
144 std::vector<lp::Packet> frags;
150 BOOST_ASSERT(mtu > 0);
163 frags.push_back(std::move(pkt));
166 if (frags.size() == 1) {
174 if (frags.size() > 1) {
176 this->assignSequences(frags);
184 this->sendLpPacket(std::move(frag));
189 GenericLinkService::assignSequence(
lp::Packet& pkt)
195 GenericLinkService::assignSequences(std::vector<lp::Packet>& pkts)
197 std::for_each(pkts.begin(), pkts.end(), bind(&GenericLinkService::assignSequence,
this, _1));
221 bool isReassembled =
false;
224 std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.
receiveFragment(packet.remoteEndpoint,
227 this->decodeNetPacket(netPkt, firstPkt);
237 GenericLinkService::decodeNetPacket(
const Block& netPkt,
const lp::Packet& firstPkt)
240 switch (netPkt.
type()) {
243 this->decodeNack(netPkt, firstPkt);
246 this->decodeInterest(netPkt, firstPkt);
250 this->decodeData(netPkt, firstPkt);
265 GenericLinkService::decodeInterest(
const Block& netPkt,
const lp::Packet& firstPkt)
271 auto interest = make_shared<Interest>(netPkt);
306 GenericLinkService::decodeData(
const Block& netPkt,
const lp::Packet& firstPkt)
311 auto data = make_shared<Data>(netPkt);
348 GenericLinkService::decodeNack(
const Block& netPkt,
const lp::Packet& firstPkt)
LpFragmenter::Options fragmenterOptions
options for fragmentation
signal::Signal< LpReassembler, Transport::EndpointId, size_t > beforeTimeout
signals before a partial packet is dropped due to timeout
const NackHeader & getHeader() const
void setOptions(const Options &options)
set options for reliability
bool allowReassembly
enables reassembly
void processIncomingPacket(const lp::Packet &pkt)
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue ...
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy ...
Packet & set(const typename FIELD::ValueType &value)
remove all occurrences of FIELD, and add a FIELD with value
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void piggyback(lp::Packet &pkt, ssize_t mtu)
called by GenericLinkService to attach Acks onto an outgoing LpPacket
Base class to store tag information (e.g., inside Interest and Data packets)
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
Nack & setHeader(const NackHeader &header)
stores a packet along with the remote endpoint
PacketCounter nReassemblyTimeouts
count of dropped partial network-layer packets due to reassembly timeout
LpReliability::Options reliabilityOptions
options for reliability
const Interest & getInterest() const
Represents a TLV element of NDN packet format.
represents an Interest packet
void sendPacket(Transport::Packet &&packet)
sends a lower-layer packet via Transport
bool isEnabled
enables link-layer reliability
void setTag(shared_ptr< T > tag) const
set a tag item
static constexpr size_t RESERVED_HEADER_SPACE
TxSequence TLV-TYPE (3 octets) + TxSequence TLV-LENGTH (1 octet) + sizeof(lp::Sequence) ...
represents a Network Nack
void setOptions(const Options &options)
set options for fragmenter
provides a tag type for simple types
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
FIELD::ValueType get(size_t index=0) const
Copyright (c) 2011-2015 Regents of the University of California.
void handleOutgoing(std::vector< lp::Packet > &frags)
observe outgoing fragment(s) of a network packet and store for potential retransmission ...
const Transport * getTransport() const
void receiveNack(const lp::Nack &nack)
delivers received Nack to forwarding
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
SizeCounter< LpReassembler > nReassembling
count of network-layer packets currently being reassembled
void setOptions(const Options &options)
set options for reassembler
void setOptions(const Options &options)
sets Options used by GenericLinkService
uint32_t type() const
Get TLV-TYPE.
Options that control the behavior of GenericLinkService.
void receiveData(const Data &data)
delivers received Data to forwarding
std::tuple< bool, Block, lp::Packet > receiveFragment(Transport::EndpointId remoteEndpoint, const lp::Packet &packet)
adds received fragment to buffer
PacketCounter nInNetInvalid
count of invalid reassembled network-layer packets dropped
shared_ptr< T > getTag() const
get a tag item
std::tuple< bool, std::vector< lp::Packet > > fragmentPacket(const lp::Packet &packet, size_t mtu)
fragments a network-layer packet into link-layer packets
LpReassembler::Options reassemblerOptions
options for reassembly
#define NFD_LOG_INIT(name)
Represents a Data packet.
GenericLinkService(const Options &options=Options())
represents an error in TLV encoding or decoding
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
PacketCounter nInLpInvalid
count of invalid LpPackets dropped before reassembly
void receiveInterest(const Interest &interest)
delivers received Interest to forwarding
PacketCounter nFragmentationErrors
count of failed fragmentations
bool allowFragmentation
enables fragmentation