Fixing bugs related to NACKs implementation
diff --git a/model/fw/nacks.cc b/model/fw/nacks.cc
index 4e7894a..8c24157 100644
--- a/model/fw/nacks.cc
+++ b/model/fw/nacks.cc
@@ -56,14 +56,14 @@
   static TypeId tid = TypeId ("ns3::ndn::fw::Nacks")
     .SetGroupName ("Ndn")
     .SetParent<ForwardingStrategy> ()
-    
+
     ////////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////////
 
     .AddTraceSource ("OutNacks",  "OutNacks",  MakeTraceSourceAccessor (&Nacks::m_outNacks))
     .AddTraceSource ("InNacks",   "InNacks",   MakeTraceSourceAccessor (&Nacks::m_inNacks))
     .AddTraceSource ("DropNacks", "DropNacks", MakeTraceSourceAccessor (&Nacks::m_dropNacks))
-    
+
     .AddAttribute ("EnableNACKs", "Enabling support of NACKs",
                    BooleanValue (false),
                    MakeBooleanAccessor (&Nacks::m_nacksEnabled),
@@ -80,7 +80,7 @@
   if (header->GetNack () > 0)
     OnNack (inFace, header, origPacket/*original packet*/);
   else
-    super::OnInterest (inFace, header, origPacket/*original packet*/);  
+    super::OnInterest (inFace, header, origPacket/*original packet*/);
 }
 
 void
@@ -88,7 +88,7 @@
                Ptr<const InterestHeader> header,
                Ptr<const Packet> origPacket)
 {
-  // NS_LOG_FUNCTION (inFace << header << origPacket);
+  // NS_LOG_FUNCTION (inFace << header->GetName ());
   m_inNacks (header, inFace);
 
   Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
@@ -98,11 +98,6 @@
       m_dropNacks (header, inFace);
       return;
     }
-  
-  // This was done in error. Never, never do anything, except normal leakage. This way we ensure that we will not have losses,
-  // at least when there is only one client
-  //
-  // inFace->LeakBucketByOnePacket ();
 
   DidReceiveValidNack (inFace, header->GetNack (), header, origPacket, pitEntry);
 }
@@ -148,8 +143,10 @@
 
           m_outNacks (nackHeader, incoming.m_face);
         }
+
+      pitEntry->ClearOutgoing (); // to force erasure of the record
     }
-  
+
   super::DidExhaustForwardingOptions (inFace, header, origPacket, pitEntry);
 }
 
@@ -160,6 +157,8 @@
                             Ptr<const Packet> origPacket,
                             Ptr<pit::Entry> pitEntry)
 {
+  NS_LOG_DEBUG ("nackCode: " << nackCode << " for [" << header->GetName () << "]");
+
   // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
   // So, if we had an incoming entry to this neighbor, then we can remove it now
   if (nackCode == InterestHeader::NACK_GIVEUP_PIT)
@@ -181,12 +180,12 @@
           m_dropNacks (header, inFace);
           return;
         }
-  
+
       Ptr<Packet> nonNackInterest = Create<Packet> ();
       Ptr<InterestHeader> nonNackHeader = Create<InterestHeader> (*header);
       nonNackHeader->SetNack (InterestHeader::NORMAL_INTEREST);
       nonNackInterest->AddHeader (*nonNackHeader);
-  
+
       bool propagated = DoPropagateInterest (inFace, nonNackHeader, nonNackInterest, pitEntry);
       if (!propagated)
         {
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index 0e773f9..33f2942 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -71,7 +71,7 @@
     .AddTraceSource ("OutInterests",  "OutInterests",  MakeTraceSourceAccessor (&ForwardingStrategy::m_outInterests))
     .AddTraceSource ("InInterests",   "InInterests",   MakeTraceSourceAccessor (&ForwardingStrategy::m_inInterests))
     .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropInterests))
-    
+
     ////////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////////
 
@@ -161,7 +161,7 @@
       isDuplicated = false;
     }
 
-  if (isDuplicated) 
+  if (isDuplicated)
     {
       DidReceiveDuplicateInterest (inFace, header, origPacket, pitEntry);
       return;
@@ -221,7 +221,7 @@
 {
   NS_LOG_FUNCTION (inFace << header->GetName () << payload << origPacket);
   m_inData (header, payload, inFace);
-  
+
   // Lookup PIT entry
   Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
   if (pitEntry == 0)
@@ -236,7 +236,7 @@
         {
           Ptr<Packet> payloadCopy = payload->Copy ();
           payloadCopy->RemovePacketTag (hopCountTag);
-          
+
           // Add or update entry in the content store
           m_contentStore->Add (header, payloadCopy);
         }
@@ -314,7 +314,7 @@
                                                  Ptr<pit::Entry> pitEntry)
 {
   NS_LOG_FUNCTION (this << boost::cref (*inFace));
-  if (pitEntry->GetOutgoing ().size () == 0)
+  if (pitEntry->AreAllOutgoingInVain ())
     {
       m_dropInterests (header, inFace);
 
@@ -323,12 +323,12 @@
 
       // Remove also outgoing
       pitEntry->ClearOutgoing ();
-  
+
       // Set pruning timout on PIT entry (instead of deleting the record)
       m_pit->MarkErased (pitEntry);
     }
 }
-  
+
 
 
 bool
@@ -340,7 +340,7 @@
   pit::Entry::in_iterator existingInFace = pitEntry->GetIncoming ().find (inFace);
 
   bool isRetransmitted = false;
-  
+
   if (existingInFace != pitEntry->GetIncoming ().end ())
     {
       // this is almost definitely a retransmission. But should we trust the user on that?
@@ -368,7 +368,7 @@
         {
           m_outData (header, payload, inFace == 0, incoming.m_face);
           DidSendOutData (inFace, incoming.m_face, header, payload, origPacket, pitEntry);
-          
+
           NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
         }
       else
@@ -376,7 +376,7 @@
           m_dropData (header, payload, incoming.m_face);
           NS_LOG_DEBUG ("Cannot satisfy data to " << *incoming.m_face);
         }
-          
+
       // successfull forwarded data trace
     }
 
@@ -385,7 +385,7 @@
 
   // Remove all outgoing faces
   pitEntry->ClearOutgoing ();
-          
+
   // Set pruning timout on PIT entry (instead of deleting the record)
   m_pit->MarkErased (pitEntry);
 }
@@ -405,7 +405,7 @@
     {
       // Drop data packet if PIT entry is not found
       // (unsolicited data packets should not "poison" content store)
-      
+
       //drop dulicated or not requested data packet
       m_dropData (header, payload, inFace);
     }
@@ -416,12 +416,12 @@
                                                 Ptr<pit::Entry> pitEntry)
 {
   pit::Entry::out_iterator out = pitEntry->GetOutgoing ().find (inFace);
-  
+
   // If we have sent interest for this data via this face, then update stats.
   if (out != pitEntry->GetOutgoing ().end ())
     {
       pitEntry->GetFibEntry ()->UpdateFaceRtt (inFace, Simulator::Now () - out->m_sendTime);
-    } 
+    }
 }
 
 bool
@@ -433,9 +433,9 @@
   bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
 
   if (isNew) return false; // never suppress new interests
-  
+
   bool isRetransmitted = m_detectRetransmissions && // a small guard
-                         DetectRetransmittedInterest (inFace, header, origPacket, pitEntry);  
+                         DetectRetransmittedInterest (inFace, header, origPacket, pitEntry);
 
   if (pitEntry->GetOutgoing ().find (inFace) != pitEntry->GetOutgoing ().end ())
     {
@@ -447,7 +447,7 @@
       // Mark interface YELLOW, but keep a small hope that data will come eventually.
 
       // ?? not sure if we need to do that ?? ...
-      
+
       // pitEntry->GetFibEntry ()->UpdateStatus (inFace, fib::FaceMetric::NDN_FIB_YELLOW);
     }
   else
@@ -466,12 +466,12 @@
                                        Ptr<pit::Entry> pitEntry)
 {
   bool isRetransmitted = m_detectRetransmissions && // a small guard
-                         DetectRetransmittedInterest (inFace, header, origPacket, pitEntry);  
-  
+                         DetectRetransmittedInterest (inFace, header, origPacket, pitEntry);
+
   pitEntry->AddIncoming (inFace/*, header->GetInterestLifetime ()*/);
   /// @todo Make lifetime per incoming interface
   pitEntry->UpdateLifetime (header->GetInterestLifetime ());
-  
+
   bool propagated = DoPropagateInterest (inFace, header, origPacket, pitEntry);
 
   if (!propagated && isRetransmitted) //give another chance if retransmitted
@@ -483,10 +483,17 @@
       propagated = DoPropagateInterest (inFace, header, origPacket, pitEntry);
     }
 
+  // if (!propagated)
+  //   {
+  //     NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+  //     NS_LOG_DEBUG ("+++ Not propagated ["<< header->GetName () <<"], but number of outgoing faces: " << pitEntry->GetOutgoing ().size ());
+  //     NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+  //   }
+
   // ForwardingStrategy will try its best to forward packet to at least one interface.
   // If no interests was propagated, then there is not other option for forwarding or
-  // ForwardingStrategy failed to find it. 
-  if (!propagated && pitEntry->GetOutgoing ().size () == 0)
+  // ForwardingStrategy failed to find it.
+  if (!propagated && pitEntry->AreAllOutgoingInVain ())
     {
       DidExhaustForwardingOptions (inFace, header, origPacket, pitEntry);
     }
@@ -499,12 +506,12 @@
                                         Ptr<const Packet> origPacket,
                                         Ptr<pit::Entry> pitEntry)
 {
-  if (outFace == inFace) 
+  if (outFace == inFace)
     {
-      NS_LOG_DEBUG ("Same as incoming");
+      // NS_LOG_DEBUG ("Same as incoming");
       return false; // same face as incoming, don't forward
     }
-  
+
   pit::Entry::out_iterator outgoing =
     pitEntry->GetOutgoing ().find (outFace);
 
@@ -514,7 +521,7 @@
         return false; // suppress
       else if (outgoing->m_retxCount >= pitEntry->GetMaxRetxCount ())
         {
-          NS_LOG_ERROR (outgoing->m_retxCount << " >= " << pitEntry->GetMaxRetxCount ());
+          // NS_LOG_DEBUG ("Already forwarded before during this retransmission cycle (" <<outgoing->m_retxCount << " >= " << pitEntry->GetMaxRetxCount () << ")");
           return false; // already forwarded before during this retransmission cycle
         }
    }
@@ -534,7 +541,7 @@
     {
       return false;
     }
-  
+
   pitEntry->AddOutgoing (outFace);
 
   //transmission