|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
44 , m_fragmenter(m_options.fragmenterOptions, this)
45 , m_reassembler(m_options.reassemblerOptions, this)
46 , m_reliability(m_options.reliabilityOptions, this)
48 , m_nextMarkTime(
time::steady_clock::TimePoint::max())
49 , m_nMarkedSinceInMarkingState(0)
66 GenericLinkService::requestIdlePacket(
const EndpointId& endpointId)
70 this->sendLpPacket({}, endpointId);
83 checkCongestionLevel(pkt);
86 auto block = pkt.wireEncode();
87 if (mtu !=
MTU_UNLIMITED && block.size() >
static_cast<size_t>(mtu)) {
96 GenericLinkService::doSendInterest(
const Interest& interest,
const EndpointId& endpointId)
100 encodeLpFields(interest, lpPacket);
102 this->sendNetPacket(
std::move(lpPacket), endpointId,
true);
106 GenericLinkService::doSendData(
const Data& data,
const EndpointId& endpointId)
110 encodeLpFields(data, lpPacket);
112 this->sendNetPacket(
std::move(lpPacket), endpointId,
false);
121 encodeLpFields(nack, lpPacket);
123 this->sendNetPacket(
std::move(lpPacket), endpointId,
false);
131 if (incomingFaceIdTag !=
nullptr) {
137 if (congestionMarkTag !=
nullptr) {
143 if (nonDiscoveryTag !=
nullptr) {
148 if (prefixAnnouncementTag !=
nullptr) {
154 if (pitToken !=
nullptr) {
159 if (hopCountTag !=
nullptr) {
168 if (geoTag !=
nullptr) {
175 GenericLinkService::sendNetPacket(
lp::Packet&& pkt,
const EndpointId& endpointId,
bool isInterest)
177 std::vector<lp::Packet> frags;
202 frags.push_back(pkt);
209 if (frags.size() == 1) {
217 if (frags.size() > 1) {
219 this->assignSequences(frags);
227 this->sendLpPacket(
std::move(frag), endpointId);
232 GenericLinkService::assignSequence(
lp::Packet& pkt)
238 GenericLinkService::assignSequences(std::vector<lp::Packet>& pkts)
240 std::for_each(pkts.begin(), pkts.end(), [
this] (
auto& pkt) { this->assignSequence(pkt); });
244 GenericLinkService::checkCongestionLevel(
lp::Packet& pkt)
248 if (sendQueueLength < 0) {
252 if (sendQueueLength > 0) {
262 if (m_nextMarkTime == time::steady_clock::TimePoint::max()) {
266 else if (now >= m_nextMarkTime) {
271 ++m_nMarkedSinceInMarkingState;
274 time::nanoseconds interval(
static_cast<time::nanoseconds::rep
>(
276 std::sqrt(m_nMarkedSinceInMarkingState + 1)));
277 m_nextMarkTime += interval;
280 else if (m_nextMarkTime != time::steady_clock::TimePoint::max()) {
283 m_nextMarkTime = time::steady_clock::TimePoint::max();
284 m_nMarkedSinceInMarkingState = 0;
289 GenericLinkService::doReceivePacket(
const Block& packet,
const EndpointId& endpoint)
309 bool isReassembled =
false;
312 std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.
receiveFragment(endpoint, pkt);
314 this->decodeNetPacket(netPkt, firstPkt, endpoint);
317 catch (
const tlv::Error& e) {
324 GenericLinkService::decodeNetPacket(
const Block& netPkt,
const lp::Packet& firstPkt,
328 switch (netPkt.type()) {
331 this->decodeNack(netPkt, firstPkt, endpointId);
334 this->decodeInterest(netPkt, firstPkt, endpointId);
338 this->decodeData(netPkt, firstPkt, endpointId);
342 NFD_LOG_FACE_WARN(
"unrecognized network-layer packet TLV-TYPE " << netPkt.type() <<
": DROP");
346 catch (
const tlv::Error& e) {
353 GenericLinkService::decodeInterest(
const Block& netPkt,
const lp::Packet& firstPkt,
360 auto interest = make_shared<Interest>(netPkt);
418 GenericLinkService::decodeData(
const Block& netPkt,
const lp::Packet& firstPkt,
421 BOOST_ASSERT(netPkt.type() ==
tlv::Data);
424 auto data = make_shared<Data>(netPkt);
472 NFD_LOG_FACE_WARN(
"received PrefixAnnouncement, but self-learning disabled: IGNORE");
480 GenericLinkService::decodeNack(
const Block& netPkt,
const lp::Packet& firstPkt,
constexpr size_t sizeOfNonNegativeInteger(uint64_t integer) noexcept
Get the number of bytes necessary to hold the value of integer encoded as nonNegativeInteger.
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void setOptions(const Options &options)
sets Options used by GenericLinkService
void receiveData(const Data &data, const EndpointId &endpoint)
delivers received Data to forwarding
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
NDN_CXX_NODISCARD bool has() const
bool allowCongestionMarking
enables send queue congestion detection and marking
void processIncomingPacket(const lp::Packet &pkt)
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue
provides a tag type for simple types
static time_point now() noexcept
bool allowSelfLearning
enables self-learning forwarding support
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
bool allowFragmentation
enables fragmentation
void notifyDroppedInterest(const Interest &packet)
void setTag(shared_ptr< T > tag) const
set a tag item
SizeCounter< LpReassembler > nReassembling
count of network-layer packets currently being reassembled
shared_ptr< T > getTag() const
get a tag item
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
PacketCounter nFragmentationErrors
count of failed fragmentations
GenericLinkService(const Options &options={})
size_t defaultCongestionThreshold
default congestion threshold in bytes
void receiveInterest(const Interest &interest, const EndpointId &endpoint)
delivers received Interest to forwarding
void setOptions(const Options &options)
set options for reliability
void piggyback(lp::Packet &pkt, ssize_t mtu)
called by GenericLinkService to attach Acks onto an outgoing LpPacket
PacketCounter nReassemblyTimeouts
count of dropped partial network-layer packets due to reassembly timeout
LpFragmenter::Options fragmenterOptions
options for fragmentation
Packet & set(const typename FIELD::ValueType &value)
remove all occurrences of FIELD, and add a FIELD with value
Copyright (c) 2011-2015 Regents of the University of California.
Nack & setHeader(const NackHeader &header)
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
PacketCounter nInNetInvalid
count of invalid reassembled network-layer packets dropped
constexpr size_t sizeOfVarNumber(uint64_t number) noexcept
Get the number of bytes necessary to hold the value of number encoded as VAR-NUMBER.
Options that control the behavior of GenericLinkService.
LpReassembler::Options reassemblerOptions
options for reassembly
PacketCounter nInLpInvalid
count of invalid LpPackets dropped before reassembly
const Transport * getTransport() const
void setOptions(const Options &options)
set options for reassembler
represent a PIT token field
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
const NackHeader & getHeader() const
static constexpr size_t RESERVED_HEADER_SPACE
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets)
LpReliability::Options reliabilityOptions
options for reliability
time::nanoseconds baseCongestionMarkingInterval
starting value for congestion marking interval
void setOptions(const Options &options)
set options for fragmenter
std::tuple< bool, std::vector< lp::Packet > > fragmentPacket(const lp::Packet &packet, size_t mtu)
fragments a network-layer packet into link-layer packets
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
represents a Network Nack
bool isEnabled
enables link-layer reliability
std::tuple< bool, Block, lp::Packet > receiveFragment(EndpointId remoteEndpoint, const lp::Packet &packet)
adds received fragment to the buffer
constexpr size_t CONGESTION_MARK_SIZE
PacketCounter nCongestionMarked
count of outgoing LpPackets that were marked with congestion marks
void sendPacket(const Block &packet, const EndpointId &endpoint)
send a lower-layer packet via Transport to endpoint
base class to allow simple management of packet tags
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder according to NDN Packet Format v0.3.
uint64_t EndpointId
Identifies a remote endpoint on the link.
bool allowReassembly
enables reassembly
std::function< std::shared_ptr< ndn::lp::GeoTag >)> enableGeoTags
Enable encoding and decoding of GeoTags.
void receiveNack(const lp::Nack &nack, const EndpointId &endpoint)
delivers received Nack to forwarding
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
const Interest & getInterest() const
FIELD::ValueType get(size_t index=0) const
#define NFD_LOG_INIT(name)
signal::Signal< LpReliability, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
virtual ssize_t getSendQueueLength()
signal::Signal< LpReassembler, EndpointId, size_t > beforeTimeout
signals before a partial packet is dropped due to timeout