Skip to content

Commit

Permalink
[ndnSIM] daemon: HopCount handling as a tag of an lp Packet
Browse files Browse the repository at this point in the history
Change-Id: I2c25bcf29f4858049d1040a3e421e1c7151b3ba2
  • Loading branch information
spirosmastorakis committed Nov 1, 2017
1 parent b17cf00 commit 9253fad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions daemon/face/generic-link-service.cpp
Expand Up @@ -128,6 +128,14 @@ GenericLinkService::encodeLpFields(const ndn::TagHost& netPkt, lp::Packet& lpPac
if (congestionMarkTag != nullptr) {
lpPacket.add<lp::CongestionMarkField>(*congestionMarkTag);
}

shared_ptr<lp::HopCountTag> hopCountTag = netPkt.getTag<lp::HopCountTag>();
if (hopCountTag != nullptr) {
lpPacket.add<lp::HopCountTagField>(*hopCountTag);
}
else {
lpPacket.add<lp::HopCountTagField>(0);
}
}

void
Expand Down Expand Up @@ -262,6 +270,11 @@ GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstP
// forwarding expects Interest to be created with make_shared
auto interest = make_shared<Interest>(netPkt);

// Increment HopCount
if (firstPkt.has<lp::HopCountTagField>()) {
interest->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
}

if (firstPkt.has<lp::NextHopFaceIdField>()) {
if (m_options.allowLocalFields) {
interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>()));
Expand Down Expand Up @@ -297,6 +310,10 @@ GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt)
// forwarding expects Data to be created with make_shared
auto data = make_shared<Data>(netPkt);

if (firstPkt.has<lp::HopCountTagField>()) {
data->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
}

if (firstPkt.has<lp::NackField>()) {
++this->nInNetInvalid;
NFD_LOG_FACE_WARN("received Nack with Data: DROP");
Expand Down
7 changes: 5 additions & 2 deletions daemon/fw/forwarder.cpp
Expand Up @@ -315,11 +315,14 @@ Forwarder::onIncomingData(Face& inFace, const Data& data)
return;
}

shared_ptr<Data> dataCopyWithoutTag = make_shared<Data>(data);
dataCopyWithoutTag->removeTag<lp::HopCountTag>();

// CS insert
if (m_csFromNdnSim == nullptr)
m_cs.insert(data);
m_cs.insert(*dataCopyWithoutTag);
else
m_csFromNdnSim->Add(data.shared_from_this());
m_csFromNdnSim->Add(dataCopyWithoutTag);

std::set<Face*> pendingDownstreams;
// foreach PitEntry
Expand Down

0 comments on commit 9253fad

Please sign in to comment.