Semi success with NACK enabled. Now need more NACK types and different processing
diff --git a/model/fw/per-fib-limits.cc b/model/fw/per-fib-limits.cc
index 8190329..43355e3 100644
--- a/model/fw/per-fib-limits.cc
+++ b/model/fw/per-fib-limits.cc
@@ -151,17 +151,20 @@
NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
super::WillEraseTimedOutPendingInterest (pitEntry);
- // Ptr<Packet> pkt = Create<Packet> ();
- // Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ());
- // nackHeader->SetNack (99);
- // pkt->AddHeader (*nackHeader);
+ if (pitEntry->GetOutgoing ().size () == 0)
+ {
+ Ptr<Packet> pkt = Create<Packet> ();
+ Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ());
+ nackHeader->SetNack (99);
+ pkt->AddHeader (*nackHeader);
- // for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin ();
- // face != pitEntry->GetIncoming ().end ();
- // face ++)
- // {
- // face->m_face->Send (pkt->Copy ());
- // }
+ for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin ();
+ face != pitEntry->GetIncoming ().end ();
+ face ++)
+ {
+ face->m_face->Send (pkt->Copy ());
+ }
+ }
PitQueue::Remove (pitEntry);
@@ -246,33 +249,32 @@
uint32_t nackCode,
Ptr<pit::Entry> pitEntry)
{
- // super::DidReceiveValidNack (inFace, nackCode, pitEntry);
// NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
- // Ptr<Packet> pkt = Create<Packet> ();
- // Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ());
- // nackHeader->SetNack (99);
- // pkt->AddHeader (*nackHeader);
+ Ptr<Packet> pkt = Create<Packet> ();
+ Ptr<InterestHeader> nackHeader = Create<InterestHeader> (*pitEntry->GetInterest ());
+ nackHeader->SetNack (99);
+ pkt->AddHeader (*nackHeader);
- // for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin ();
- // face != pitEntry->GetIncoming ().end ();
- // face ++)
- // {
- // face->m_face->Send (pkt->Copy ());
- // }
+ for (pit::Entry::in_container::iterator face = pitEntry->GetIncoming ().begin ();
+ face != pitEntry->GetIncoming ().end ();
+ face ++)
+ {
+ face->m_face->Send (pkt->Copy ());
+ }
- // PitQueue::Remove (pitEntry);
+ PitQueue::Remove (pitEntry);
- // for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- // face != pitEntry->GetOutgoing ().end ();
- // face ++)
- // {
- // face->m_face->GetLimits ().RemoveOutstanding ();
- // }
+ for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
+ face != pitEntry->GetOutgoing ().end ();
+ face ++)
+ {
+ face->m_face->GetLimits ().RemoveOutstanding ();
+ }
- // m_pit->MarkErased (pitEntry);
+ m_pit->MarkErased (pitEntry);
- // ProcessFromQueue ();
+ ProcessFromQueue ();
}
diff --git a/utils/ndn-pit-queue.cc b/utils/ndn-pit-queue.cc
index d8e810d..34410ba 100644
--- a/utils/ndn-pit-queue.cc
+++ b/utils/ndn-pit-queue.cc
@@ -146,7 +146,7 @@
shared_ptr<fw::PitQueueTag> tag = (*pitEntry)->GetFwTag<fw::PitQueueTag> ();
NS_ASSERT (tag != shared_ptr<fw::PitQueueTag> ());
- tag->RemoveFromQueue (queue->second);
+ tag->RemoveFromQueuesExcept (queue->second);
}
NS_ASSERT_MSG (queue->second->size () == 0, "Queue size should be 0 by now");
@@ -208,5 +208,26 @@
m_items.erase (item);
}
+void
+fw::PitQueueTag::RemoveFromQueuesExcept (boost::shared_ptr<PitQueue::Queue> queue)
+{
+ for (MapOfItems::iterator item = m_items.begin ();
+ item != m_items.end (); )
+ {
+ if (item->first == queue)
+ {
+ item ++;
+ continue;
+ }
+
+ item->first->erase (item->second);
+
+ MapOfItems::iterator itemToDelete = item;
+ item ++;
+ m_items.erase (itemToDelete);
+ }
+}
+
+
} // namespace ndn
} // namespace ns3
diff --git a/utils/ndn-pit-queue.h b/utils/ndn-pit-queue.h
index 993cb83..ebac04a 100644
--- a/utils/ndn-pit-queue.h
+++ b/utils/ndn-pit-queue.h
@@ -154,6 +154,13 @@
*/
void
RemoveFromQueue (boost::shared_ptr<PitQueue::Queue> queue);
+
+ /**
+ * @brief Remove reference to PIT from queues except the queue in parameter
+ * @param queue Queue from which PIT entry should not be removed (to preserve iterator)
+ */
+ void
+ RemoveFromQueuesExcept (boost::shared_ptr<PitQueue::Queue> queue);
private:
MapOfItems m_items;