NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
lp-reliability.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2019, Regents of the University of California,
4
* Arizona Board of Regents,
5
* Colorado State University,
6
* University Pierre & Marie Curie, Sorbonne University,
7
* Washington University in St. Louis,
8
* Beijing Institute of Technology,
9
* The University of Memphis.
10
*
11
* This file is part of NFD (Named Data Networking Forwarding Daemon).
12
* See AUTHORS.md for complete list of NFD authors and contributors.
13
*
14
* NFD is free software: you can redistribute it and/or modify it under the terms
15
* of the GNU General Public License as published by the Free Software Foundation,
16
* either version 3 of the License, or (at your option) any later version.
17
*
18
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
* PURPOSE. See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License along with
23
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24
*/
25
26
#ifndef NFD_DAEMON_FACE_LP_RELIABILITY_HPP
27
#define NFD_DAEMON_FACE_LP_RELIABILITY_HPP
28
29
#include "
core/common.hpp
"
30
31
#include <
ndn-cxx/lp/packet.hpp
>
32
#include <
ndn-cxx/lp/sequence.hpp
>
33
#include <
ndn-cxx/util/rtt-estimator.hpp
>
34
35
#include <queue>
36
37
namespace
nfd
{
38
namespace
face {
39
40
class
GenericLinkService
;
41
45
class
LpReliability
: noncopyable
46
{
47
public
:
48
struct
Options
49
{
52
bool
isEnabled
=
false
;
53
56
size_t
maxRetx
= 3;
57
60
time::nanoseconds
idleAckTimerPeriod
= 5_ms;
61
65
size_t
seqNumLossThreshold
= 3;
66
};
67
68
LpReliability
(
const
Options
& options,
GenericLinkService
* linkService);
69
72
signal::Signal<LpReliability, Interest>
onDroppedInterest
;
73
76
void
77
setOptions
(
const
Options
& options);
78
83
const
GenericLinkService
*
84
getLinkService
()
const
;
85
91
void
92
handleOutgoing
(std::vector<lp::Packet>& frags,
lp::Packet
&& pkt,
bool
isInterest);
93
97
void
98
processIncomingPacket
(
const
lp::Packet
& pkt);
99
104
void
105
piggyback
(
lp::Packet
& pkt, ssize_t mtu);
106
107
PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
108
class
UnackedFrag;
109
class
NetPkt;
110
using
UnackedFrags = std::map<lp::Sequence, UnackedFrag>;
111
112
PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
118
lp::Sequence
119
assignTxSequence(
lp::Packet
& frag);
120
127
void
128
startIdleAckTimer();
129
135
std::vector<lp::Sequence>
136
findLostLpPackets(UnackedFrags::iterator ackIt);
137
141
std::vector<lp::Sequence>
142
onLpPacketLost(
lp::Sequence
txSeq);
143
151
void
152
onLpPacketAcknowledged(UnackedFrags::iterator fragIt);
153
161
void
162
deleteUnackedFrag(UnackedFrags::iterator fragIt);
163
164
PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
167
class
UnackedFrag
168
{
169
public
:
170
explicit
171
UnackedFrag(
lp::Packet
pkt);
172
173
public
:
174
lp::Packet
pkt;
175
scheduler::ScopedEventId
rtoTimer;
176
time::steady_clock::TimePoint
sendTime;
177
size_t
retxCount;
178
size_t
nGreaterSeqAcks;
179
shared_ptr<NetPkt> netPkt;
180
};
181
184
class
NetPkt
185
{
186
public
:
187
NetPkt(
lp::Packet
&& pkt,
bool
isInterest);
188
189
public
:
190
std::vector<UnackedFrags::iterator> unackedFrags;
191
lp::Packet
pkt;
192
bool
isInterest;
193
bool
didRetx;
194
};
195
196
public
:
198
static
constexpr
size_t
RESERVED_HEADER_SPACE
=
tlv::sizeOfVarNumber
(
lp::tlv::TxSequence
) +
199
tlv::sizeOfVarNumber
(
sizeof
(
lp::Sequence
)) +
200
sizeof
(
lp::Sequence
);
201
202
PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
203
Options
m_options;
204
GenericLinkService
* m_linkService;
205
UnackedFrags m_unackedFrags;
211
UnackedFrags::iterator m_firstUnackedFrag;
212
std::queue<lp::Sequence> m_ackQueue;
213
lp::Sequence
m_lastTxSeqNo;
214
scheduler::ScopedEventId
m_idleAckTimer;
215
ndn::util::RttEstimator
m_rttEst;
216
};
217
218
}
// namespace face
219
}
// namespace nfd
220
221
#endif // NFD_DAEMON_FACE_LP_RELIABILITY_HPP
ndn::lp::Packet
Definition:
packet.hpp:31
nfd::face::LpReliability::Options::seqNumLossThreshold
size_t seqNumLossThreshold
a fragment is considered lost if this number of fragments with greater sequence numbers are acknowled...
Definition:
lp-reliability.hpp:65
PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition:
common.hpp:41
nfd::face::LpReliability
provides for reliable sending and receiving of link-layer packets
Definition:
lp-reliability.hpp:46
ndn::lp::tlv::TxSequence
@ TxSequence
Definition:
tlv.hpp:50
nfd::face::LpReliability::processIncomingPacket
void processIncomingPacket(const lp::Packet &pkt)
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue
Definition:
lp-reliability.cpp:97
rtt-estimator.hpp
nfd::face::LpReliability::handleOutgoing
void handleOutgoing(std::vector< lp::Packet > &frags, lp::Packet &&pkt, bool isInterest)
observe outgoing fragment(s) of a network packet and store for potential retransmission
Definition:
lp-reliability.cpp:63
sequence.hpp
packet.hpp
nfd::face::LpReliability::LpReliability
LpReliability(const Options &options, GenericLinkService *linkService)
Definition:
lp-reliability.cpp:34
nfd::face::LpReliability::setOptions
void setOptions(const Options &options)
set options for reliability
Definition:
lp-reliability.cpp:45
nfd::face::GenericLinkService
GenericLinkService
Definition:
generic-link-service.cpp:36
nfd::face::LpReliability::piggyback
void piggyback(lp::Packet &pkt, ssize_t mtu)
called by GenericLinkService to attach Acks onto an outgoing LpPacket
Definition:
lp-reliability.cpp:154
nfd::face::LpReliability::Options::maxRetx
size_t maxRetx
maximum number of retransmissions for an LpPacket
Definition:
lp-reliability.hpp:56
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition:
signal.hpp:52
common.hpp
nfd::face::LpReliability::Options::idleAckTimerPeriod
time::nanoseconds idleAckTimerPeriod
period between sending pending Acks in an IDLE packet
Definition:
lp-reliability.hpp:60
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
ndn::tlv::sizeOfVarNumber
constexpr size_t sizeOfVarNumber(uint64_t number) noexcept
Get the number of bytes necessary to hold the value of number encoded as VAR-NUMBER.
Definition:
tlv.hpp:450
nfd::face::LpReliability::Options
Definition:
lp-reliability.hpp:49
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition:
time.hpp:225
nfd::face::GenericLinkService
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
Definition:
generic-link-service.hpp:96
nfd::face::LpReliability::RESERVED_HEADER_SPACE
static constexpr size_t RESERVED_HEADER_SPACE
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets)
Definition:
lp-reliability.hpp:198
nfd::face::LpReliability::Options::isEnabled
bool isEnabled
enables link-layer reliability
Definition:
lp-reliability.hpp:52
ndn::util::RttEstimator
RTT/RTO estimator.
Definition:
rtt-estimator.hpp:42
ndn::lp::Sequence
uint64_t Sequence
represents a sequence number
Definition:
sequence.hpp:35
ndn::detail::ScopedCancelHandle< EventId >
nfd::face::LpReliability::onDroppedInterest
signal::Signal< LpReliability, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition:
lp-reliability.hpp:72
nfd::face::LpReliability::getLinkService
const GenericLinkService * getLinkService() const
Definition:
lp-reliability.cpp:57
ndnSIM
NFD
daemon
face
lp-reliability.hpp
Generated on Mon Jun 1 2020 22:32:16 for ndnSIM by
1.8.18