Start of serious reorganization
The whole forwarding logic is (will be) moved to the Forwarding Strategy
class.
diff --git a/model/ccnx-forwarding-strategy.cc b/model/ccnx-forwarding-strategy.cc
deleted file mode 100644
index df398c8..0000000
--- a/model/ccnx-forwarding-strategy.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ns3/assert.h"
-
-#include "ccnx-forwarding-strategy.h"
-#include "ns3/ptr.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-#include "ccnx-pit.h"
-#include "ccnx-pit-entry.h"
-
-#include "ccnx-interest-header.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("CcnxForwardingStrategy");
-
-namespace ns3 {
-
-using namespace __ccnx_private;
-
-NS_OBJECT_ENSURE_REGISTERED (CcnxForwardingStrategy);
-
-TypeId CcnxForwardingStrategy::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::CcnxForwardingStrategy")
- .SetGroupName ("Ccnx")
- .SetParent<Object> ()
-
- .AddTraceSource ("OutInterests", "Interests that were transmitted",
- MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_transmittedInterestsTrace))
-
- ;
- return tid;
-}
-
-CcnxForwardingStrategy::CcnxForwardingStrategy ()
-{
-}
-
-CcnxForwardingStrategy::~CcnxForwardingStrategy ()
-{
-}
-
-void
-CcnxForwardingStrategy::NotifyNewAggregate ()
-{
- if (m_pit == 0)
- {
- m_pit = GetObject<CcnxPit> ();
- }
-}
-
-void
-CcnxForwardingStrategy::DoDispose ()
-{
- // nothing to do...
-}
-
-bool
-CcnxForwardingStrategy::PropagateInterestViaGreen (Ptr<CcnxPitEntry> pitEntry,
- const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &packet)
-{
- NS_LOG_FUNCTION (this);
- NS_ASSERT_MSG (m_pit != 0, "PIT should be aggregated with forwarding strategy");
-
- int propagatedCount = 0;
-
- BOOST_FOREACH (const CcnxFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
- {
- if (metricFace.m_status == CcnxFibFaceMetric::NDN_FIB_RED ||
- metricFace.m_status == CcnxFibFaceMetric::NDN_FIB_YELLOW)
- break; //propagate only to green faces
-
- if (pitEntry->GetIncoming ().find (metricFace.m_face) != pitEntry->GetIncoming ().end ())
- continue; // don't forward to face that we received interest from
-
- CcnxPitEntryOutgoingFaceContainer::type::iterator outgoing =
- pitEntry->GetOutgoing ().find (metricFace.m_face);
-
- if (outgoing != pitEntry->GetOutgoing ().end () &&
- outgoing->m_retxCount >= pitEntry->GetMaxRetxCount ())
- {
- NS_LOG_DEBUG ("retxCount: " << outgoing->m_retxCount << ", maxRetxCount: " << pitEntry->GetMaxRetxCount ());
- continue;
- }
-
- bool faceAvailable = metricFace.m_face->IsBelowLimit ();
- if (!faceAvailable) // huh...
- {
- // let's try different green face
- continue;
- }
-
- pitEntry->AddOutgoing (metricFace.m_face);
-
- Ptr<Packet> packetToSend = packet->Copy ();
-
- //transmission
- metricFace.m_face->Send (packetToSend);
- m_transmittedInterestsTrace (header, metricFace.m_face);
-
- propagatedCount++;
- break; // propagate only one interest
- }
-
- return propagatedCount > 0;
-}
-
-} //namespace ns3
diff --git a/model/ccnx-forwarding-strategy.h b/model/ccnx-forwarding-strategy.h
deleted file mode 100644
index ed28fd4..0000000
--- a/model/ccnx-forwarding-strategy.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-#ifndef CCNX_FORWARDING_STRATEGY_H
-#define CCNX_FORWARDING_STRATEGY_H
-
-#include "ns3/packet.h"
-#include "ns3/callback.h"
-#include "ns3/object.h"
-#include "ns3/traced-callback.h"
-
-namespace ns3 {
-
-class CcnxFace;
-class CcnxInterestHeader;
-class CcnxPit;
-class CcnxPitEntry;
-class CcnxFibFaceMetric;
-
-/**
- * \ingroup ccnx
- * \brief Abstract base class for CCNx forwarding strategies
- */
-class CcnxForwardingStrategy : public Object
-{
-public:
- static TypeId GetTypeId (void);
-
- /**
- * @brief Default constructor
- */
- CcnxForwardingStrategy ();
- virtual ~CcnxForwardingStrategy ();
-
- /**
- * @brief Base method to propagate the interest according to the forwarding strategy
- *
- * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
- * @param incomingFace Incoming face
- * @param header CcnxInterestHeader
- * @param packet Original Interest packet
- * @param sendCallback Send callback
- *
- * @return true if interest was successfully propagated, false if all options have failed
- */
- virtual bool
- PropagateInterest (Ptr<CcnxPitEntry> pitEntry,
- const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &packet) = 0;
-
-protected:
- /**
- * @brief Propagate interest via a green interface. Fail, if no green interfaces available
- *
- * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
- * @param incomingFace Incoming face
- * @param header CcnxInterestHeader
- * @param packet Original Interest packet
- * @param sendCallback Send callback
- * @return true if interest was successfully propagated, false if all options have failed
- *
- * \see PropagateInterest
- */
- bool
- PropagateInterestViaGreen (Ptr<CcnxPitEntry> pitEntry,
- const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &packet);
-
- /// @brief Transmitted interests trace
- TracedCallback<Ptr<const CcnxInterestHeader>, Ptr<const CcnxFace> > m_transmittedInterestsTrace;
-
-protected:
- // inherited from Object class
- virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
- virtual void DoDispose (); ///< @brief Do cleanup
-
-protected:
- Ptr<CcnxPit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
-};
-
-} //namespace ns3
-
-#endif /* CCNX_FORWARDING_STRATEGY_H */
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index 8cebc00..312404d 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -29,27 +29,22 @@
#include "ns3/trace-source-accessor.h"
#include "ns3/object-vector.h"
#include "ns3/pointer.h"
-#include "ns3/boolean.h"
-#include "ns3/string.h"
#include "ns3/simulator.h"
#include "ns3/random-variable.h"
#include "ns3/ccnx-header-helper.h"
+#include "ns3/ccnx-pit.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
-#include "ccnx-face.h"
-#include "ccnx-forwarding-strategy.h"
-#include "ccnx-interest-header.h"
-#include "ccnx-content-object-header.h"
-#include "ccnx-fib-impl.h"
+#include "ns3/ccnx-face.h"
+#include "ns3/ccnx-forwarding-strategy.h"
+
+// #include "fib/ccnx-fib-impl.h"
#include "ccnx-net-device-face.h"
#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-
-using namespace boost::tuples;
-namespace ll = boost::lambda;
NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
@@ -71,15 +66,6 @@
ObjectVectorValue (),
MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces),
MakeObjectVectorChecker<CcnxFace> ())
-
- .AddAttribute ("EnableNACKs", "Enabling support of NACKs",
- BooleanValue (false),
- MakeBooleanAccessor (&CcnxL3Protocol::m_nacksEnabled),
- MakeBooleanChecker ())
- .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
- BooleanValue (false),
- MakeBooleanAccessor (&CcnxL3Protocol::m_cacheUnsolicitedData),
- MakeBooleanChecker ())
;
return tid;
}
@@ -108,26 +94,28 @@
m_node = GetObject<Node> ();
if (m_node != 0)
{
- NS_ASSERT_MSG (m_pit != 0 && m_fib != 0 && m_contentStore != 0 && m_forwardingStrategy != 0,
- "PIT, FIB, and ContentStore should be aggregated before CcnxL3Protocol");
+ // NS_ASSERT_MSG (m_pit != 0 && m_fib != 0 && m_contentStore != 0 && m_forwardingStrategy != 0,
+ // "PIT, FIB, and ContentStore should be aggregated before CcnxL3Protocol");
+ NS_ASSERT_MSG (m_forwardingStrategy != 0,
+ "Forwarding strategy should be aggregated before CcnxL3Protocol");
}
}
- if (m_pit == 0)
- {
- m_pit = GetObject<CcnxPit> ();
- }
- if (m_fib == 0)
- {
- m_fib = GetObject<CcnxFib> ();
- }
+ // if (m_pit == 0)
+ // {
+ // m_pit = GetObject<CcnxPit> ();
+ // }
+ // if (m_fib == 0)
+ // {
+ // m_fib = GetObject<CcnxFib> ();
+ // }
if (m_forwardingStrategy == 0)
{
m_forwardingStrategy = GetObject<CcnxForwardingStrategy> ();
}
- if (m_contentStore == 0)
- {
- m_contentStore = GetObject<CcnxContentStore> ();
- }
+ // if (m_contentStore == 0)
+ // {
+ // m_contentStore = GetObject<CcnxContentStore> ();
+ // }
Object::NotifyNewAggregate ();
}
@@ -146,9 +134,6 @@
// Force delete on objects
m_forwardingStrategy = 0; // there is a reference to PIT stored in here
- m_pit = 0;
- m_contentStore = 0;
- m_fib = 0;
Object::DoDispose ();
}
@@ -173,10 +158,11 @@
{
// ask face to register in lower-layer stack
face->RegisterProtocolHandler (MakeNullCallback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>&> ());
+ Ptr<CcnxPit> pit = GetObject<CcnxPit> ();
// just to be on a safe side. Do the process in two steps
std::list< Ptr<CcnxPitEntry> > entriesToRemoves;
- for (Ptr<CcnxPitEntry> pitEntry = m_pit->Begin (); pitEntry != 0; pitEntry = m_pit->Next (pitEntry))
+ for (Ptr<CcnxPitEntry> pitEntry = pit->Begin (); pitEntry != 0; pitEntry = pit->Next (pitEntry))
{
pitEntry->RemoveAllReferencesToFace (face);
@@ -190,7 +176,7 @@
}
BOOST_FOREACH (Ptr<CcnxPitEntry> removedEntry, entriesToRemoves)
{
- m_pit->MarkErased (removedEntry);
+ pit->MarkErased (removedEntry);
}
CcnxFaceList::iterator face_it = find (m_faces.begin(), m_faces.end(), face);
@@ -254,10 +240,11 @@
packet->RemoveHeader (*header);
NS_ASSERT_MSG (packet->GetSize () == 0, "Payload of Interests should be zero");
- if (header->GetNack () > 0)
- OnNack (face, header, p/*original packet*/);
- else
- OnInterest (face, header, p/*original packet*/);
+ m_forwardingStrategy->OnInterest (face, header, p/*original packet*/);
+ // if (header->GetNack () > 0)
+ // OnNack (face, header, p/*original packet*/);
+ // else
+ // OnInterest (face, header, p/*original packet*/);
break;
}
case CcnxHeaderHelper::CONTENT_OBJECT:
@@ -270,7 +257,7 @@
packet->RemoveHeader (*header);
packet->RemoveTrailer (contentObjectTrailer);
- OnData (face, header, packet/*payload*/, p/*original packet*/);
+ m_forwardingStrategy->OnData (face, header, packet/*payload*/, p/*original packet*/);
break;
}
}
@@ -285,405 +272,405 @@
}
}
-void
-CcnxL3Protocol::OnNack (const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &packet)
-{
- NS_LOG_FUNCTION (incomingFace << header << packet);
- m_inNacks (header, incomingFace);
+// void
+// CcnxL3Protocol::OnNack (const Ptr<CcnxFace> &incomingFace,
+// Ptr<CcnxInterestHeader> &header,
+// const Ptr<const Packet> &packet)
+// {
+// NS_LOG_FUNCTION (incomingFace << header << packet);
+// m_inNacks (header, incomingFace);
- Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
- if (pitEntry == 0)
- {
- // somebody is doing something bad
- m_dropNacks (header, NON_DUPLICATED, incomingFace);
- return;
- }
+// Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+// if (pitEntry == 0)
+// {
+// // somebody is doing something bad
+// m_dropNacks (header, NON_DUPLICATED, incomingFace);
+// return;
+// }
- // CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
- CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
+// // CcnxPitEntryIncomingFaceContainer::type::iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
+// CcnxPitEntryOutgoingFaceContainer::type::iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
- if (outFace == pitEntry->GetOutgoing ().end ())
- {
-// NS_ASSERT_MSG (false,
-// "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
-// "size: " << pitEntry.GetOutgoing ().size ());
+// if (outFace == pitEntry->GetOutgoing ().end ())
+// {
+// // NS_ASSERT_MSG (false,
+// // "Node " << GetObject<Node> ()->GetId () << ", outgoing entry should exist for face " << boost::cref(*incomingFace) << "\n" <<
+// // "size: " << pitEntry.GetOutgoing ().size ());
- // m_dropNacks (header, NON_DUPLICATE, incomingFace);
- return;
- }
+// // m_dropNacks (header, NON_DUPLICATE, incomingFace);
+// 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
- //
- // incomingFace->LeakBucketByOnePacket ();
+// // 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
+// //
+// // incomingFace->LeakBucketByOnePacket ();
- NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
+// NS_LOG_ERROR ("Nack on " << boost::cref(*incomingFace));
- pitEntry->SetWaitingInVain (outFace);
+// pitEntry->SetWaitingInVain (outFace);
- // 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 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 (header->GetNack () == CcnxInterestHeader::NACK_GIVEUP_PIT)
- {
- pitEntry->RemoveIncoming (incomingFace);
- }
+// if (header->GetNack () == CcnxInterestHeader::NACK_GIVEUP_PIT)
+// {
+// pitEntry->RemoveIncoming (incomingFace);
+// }
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
- // StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
- // ll::bind (&CcnxFibEntry::UpdateStatus,
- // ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
+// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
+// // StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
+// // ll::bind (&CcnxFibEntry::UpdateStatus,
+// // ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
- if (pitEntry->GetIncoming ().size () == 0) // interest was actually satisfied
- {
- // no need to do anything
- m_dropNacks (header, AFTER_SATISFIED, incomingFace);
- return;
- }
+// if (pitEntry->GetIncoming ().size () == 0) // interest was actually satisfied
+// {
+// // no need to do anything
+// m_dropNacks (header, AFTER_SATISFIED, incomingFace);
+// return;
+// }
- if (!pitEntry->AreAllOutgoingInVain ()) // not all ougtoing are in vain
- {
- NS_LOG_DEBUG ("Not all outgoing are in vain");
- // suppress
- // Don't do anything, we are still expecting data from some other face
- m_dropNacks (header, SUPPRESSED, incomingFace);
- return;
- }
+// if (!pitEntry->AreAllOutgoingInVain ()) // not all ougtoing are in vain
+// {
+// NS_LOG_DEBUG ("Not all outgoing are in vain");
+// // suppress
+// // Don't do anything, we are still expecting data from some other face
+// m_dropNacks (header, SUPPRESSED, incomingFace);
+// return;
+// }
- Ptr<Packet> nonNackInterest = Create<Packet> ();
- header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
- nonNackInterest->AddHeader (*header);
+// Ptr<Packet> nonNackInterest = Create<Packet> ();
+// header->SetNack (CcnxInterestHeader::NORMAL_INTEREST);
+// nonNackInterest->AddHeader (*header);
- bool propagated = m_forwardingStrategy->
- PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
+// bool propagated = m_forwardingStrategy->
+// PropagateInterest (pitEntry, incomingFace, header, nonNackInterest);
- // // 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)
- {
- m_dropNacks (header, NO_FACES, incomingFace); // this headers doesn't have NACK flag set
- GiveUpInterest (pitEntry, header);
- }
-}
+// // // 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)
+// {
+// m_dropNacks (header, NO_FACES, incomingFace); // this headers doesn't have NACK flag set
+// GiveUpInterest (pitEntry, header);
+// }
+// }
// Processing Interests
//
-// !!! Key point.
-// !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
-void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &packet)
-{
- m_inInterests (header, incomingFace);
+// // !!! Key point.
+// // !!! All interests should be answerred!!! Either later with data, immediately with data, or immediately with NACK
+// void CcnxL3Protocol::OnInterest (const Ptr<CcnxFace> &incomingFace,
+// Ptr<CcnxInterestHeader> &header,
+// const Ptr<const Packet> &packet)
+// {
+// m_inInterests (header, incomingFace);
- Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
- if (pitEntry == 0)
- {
- pitEntry = m_pit->Create (header);
- }
+// Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+// if (pitEntry == 0)
+// {
+// pitEntry = m_pit->Create (header);
+// }
- if (pitEntry == 0)
- {
- // if it is still not created, then give up processing
- m_dropInterests (header, PIT_LIMIT, incomingFace);
- return;
- }
+// if (pitEntry == 0)
+// {
+// // if it is still not created, then give up processing
+// m_dropInterests (header, PIT_LIMIT, incomingFace);
+// return;
+// }
- bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
- bool isDuplicated = true;
- if (!pitEntry->IsNonceSeen (header->GetNonce ()))
- {
- pitEntry->AddSeenNonce (header->GetNonce ());
- isDuplicated = false;
- }
+// bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
+// bool isDuplicated = true;
+// if (!pitEntry->IsNonceSeen (header->GetNonce ()))
+// {
+// pitEntry->AddSeenNonce (header->GetNonce ());
+// isDuplicated = false;
+// }
- NS_LOG_FUNCTION (header->GetName () << header->GetNonce () << boost::cref (*incomingFace) << isDuplicated);
+// NS_LOG_FUNCTION (header->GetName () << header->GetNonce () << boost::cref (*incomingFace) << isDuplicated);
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
- // //
- // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
- // //
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////////////////////////
+// // //
+// // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
+// // //
+// /////////////////////////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////////////////////////
- // Data is not in cache
- CcnxPitEntry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
- CcnxPitEntry::out_iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
+// // Data is not in cache
+// CcnxPitEntry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
+// CcnxPitEntry::out_iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
- bool isRetransmitted = false;
+// bool isRetransmitted = false;
- if (inFace != pitEntry->GetIncoming ().end ())
- {
- // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
+// if (inFace != pitEntry->GetIncoming ().end ())
+// {
+// // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
- isRetransmitted = true;
- // this is almost definitely a retransmission. But should we trust the user on that?
- }
- else
- {
- inFace = pitEntry->AddIncoming (incomingFace);
- }
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
+// isRetransmitted = true;
+// // this is almost definitely a retransmission. But should we trust the user on that?
+// }
+// else
+// {
+// inFace = pitEntry->AddIncoming (incomingFace);
+// }
+// //////////////////////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////////////////////
+// //////////////////////////////////////////////////////////////////////////////////
- if (isDuplicated)
- {
- NS_LOG_DEBUG ("Received duplicatie interest on " << *incomingFace);
- m_dropInterests (header, DUPLICATED, incomingFace);
+// if (isDuplicated)
+// {
+// NS_LOG_DEBUG ("Received duplicatie interest on " << *incomingFace);
+// m_dropInterests (header, DUPLICATED, incomingFace);
- /**
- * This condition will handle "routing" loops and also recently satisfied interests.
- * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
- * is kept for another small chunk of time.
- */
+// /**
+// * This condition will handle "routing" loops and also recently satisfied interests.
+// * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
+// * is kept for another small chunk of time.
+// */
- if (m_nacksEnabled)
- {
- NS_LOG_DEBUG ("Sending NACK_LOOP");
- header->SetNack (CcnxInterestHeader::NACK_LOOP);
- Ptr<Packet> nack = Create<Packet> ();
- nack->AddHeader (*header);
+// if (m_nacksEnabled)
+// {
+// NS_LOG_DEBUG ("Sending NACK_LOOP");
+// header->SetNack (CcnxInterestHeader::NACK_LOOP);
+// Ptr<Packet> nack = Create<Packet> ();
+// nack->AddHeader (*header);
- incomingFace->Send (nack);
- m_outNacks (header, incomingFace);
- }
+// incomingFace->Send (nack);
+// m_outNacks (header, incomingFace);
+// }
- return;
- }
+// return;
+// }
- Ptr<Packet> contentObject;
- Ptr<const CcnxContentObjectHeader> contentObjectHeader; // used for tracing
- Ptr<const Packet> payload; // used for tracing
- tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
- if (contentObject != 0)
- {
- NS_ASSERT (contentObjectHeader != 0);
- NS_LOG_LOGIC("Found in cache");
+// Ptr<Packet> contentObject;
+// Ptr<const CcnxContentObjectHeader> contentObjectHeader; // used for tracing
+// Ptr<const Packet> payload; // used for tracing
+// tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
+// if (contentObject != 0)
+// {
+// NS_ASSERT (contentObjectHeader != 0);
+// NS_LOG_LOGIC("Found in cache");
- OnDataDelayed (contentObjectHeader, payload, contentObject);
- return;
- }
+// OnDataDelayed (contentObjectHeader, payload, contentObject);
+// return;
+// }
- // update PIT entry lifetime
- pitEntry->UpdateLifetime (header->GetInterestLifetime ());
+// // update PIT entry lifetime
+// pitEntry->UpdateLifetime (header->GetInterestLifetime ());
- if (outFace != pitEntry->GetOutgoing ().end ())
- {
- NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
- // got a non-duplicate interest from the face we have sent interest to
- // Probably, there is no point in waiting data from that face... Not sure yet
+// if (outFace != pitEntry->GetOutgoing ().end ())
+// {
+// NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
+// // got a non-duplicate interest from the face we have sent interest to
+// // Probably, there is no point in waiting data from that face... Not sure yet
- // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
- // Mark interface YELLOW, but keep a small hope that data will come eventually.
+// // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
+// // Mark interface YELLOW, but keep a small hope that data will come eventually.
- // ?? not sure if we need to do that ?? ...
+// // ?? not sure if we need to do that ?? ...
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
- // StaticCast<CcnxFibImpl> (m_fib)->modify(pitEntry->GetFibEntry (),
- // ll::bind (&CcnxFibEntry::UpdateStatus,
- // ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
- }
- else
- if (!isNew && !isRetransmitted)
- {
- // Suppress this interest if we're still expecting data from some other face
- NS_LOG_DEBUG ("Suppress interests");
- m_dropInterests (header, SUPPRESSED, incomingFace);
- return;
- }
+// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
+// // StaticCast<CcnxFibImpl> (m_fib)->modify(pitEntry->GetFibEntry (),
+// // ll::bind (&CcnxFibEntry::UpdateStatus,
+// // ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
+// }
+// else
+// if (!isNew && !isRetransmitted)
+// {
+// // Suppress this interest if we're still expecting data from some other face
+// NS_LOG_DEBUG ("Suppress interests");
+// m_dropInterests (header, SUPPRESSED, incomingFace);
+// return;
+// }
- /////////////////////////////////////////////////////////////////////
- // Propagate
- /////////////////////////////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////////
+// // Propagate
+// /////////////////////////////////////////////////////////////////////
- bool propagated = m_forwardingStrategy->
- PropagateInterest (pitEntry, incomingFace, header, packet);
+// bool propagated = m_forwardingStrategy->
+// PropagateInterest (pitEntry, incomingFace, header, packet);
- if (!propagated && isRetransmitted) //give another chance if retransmitted
- {
- // increase max number of allowed retransmissions
- pitEntry->IncreaseAllowedRetxCount ();
+// if (!propagated && isRetransmitted) //give another chance if retransmitted
+// {
+// // increase max number of allowed retransmissions
+// pitEntry->IncreaseAllowedRetxCount ();
- // try again
- propagated = m_forwardingStrategy->
- PropagateInterest (pitEntry, incomingFace, header, packet);
- }
+// // try again
+// propagated = m_forwardingStrategy->
+// PropagateInterest (pitEntry, incomingFace, header, packet);
+// }
- // 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)
- {
- NS_LOG_DEBUG ("Not propagated");
- m_dropInterests (header, NO_FACES, incomingFace);
- GiveUpInterest (pitEntry, header);
- }
-}
+// // 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)
+// {
+// NS_LOG_DEBUG ("Not propagated");
+// m_dropInterests (header, NO_FACES, incomingFace);
+// GiveUpInterest (pitEntry, header);
+// }
+// }
-void
-CcnxL3Protocol::OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
- Ptr<const Packet> payload,
- const Ptr<const Packet> &packet)
-{
- // 1. Lookup PIT entry
- Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
- if (pitEntry != 0)
- {
- //satisfy all pending incoming Interests
- BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
- {
- incoming.m_face->Send (packet->Copy ());
- m_outData (header, payload, false, incoming.m_face);
- NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
+// void
+// CcnxL3Protocol::OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
+// Ptr<const Packet> payload,
+// const Ptr<const Packet> &packet)
+// {
+// // 1. Lookup PIT entry
+// Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+// if (pitEntry != 0)
+// {
+// //satisfy all pending incoming Interests
+// BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+// {
+// incoming.m_face->Send (packet->Copy ());
+// m_outData (header, payload, false, incoming.m_face);
+// NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
- // successfull forwarded data trace
- }
+// // successfull forwarded data trace
+// }
- if (pitEntry->GetIncoming ().size () > 0)
- {
- // All incoming interests are satisfied. Remove them
- pitEntry->ClearIncoming ();
+// if (pitEntry->GetIncoming ().size () > 0)
+// {
+// // All incoming interests are satisfied. Remove them
+// pitEntry->ClearIncoming ();
- // Remove all outgoing faces
- pitEntry->ClearOutgoing ();
+// // Remove all outgoing faces
+// pitEntry->ClearOutgoing ();
- // Set pruning timout on PIT entry (instead of deleting the record)
- m_pit->MarkErased (pitEntry);
- }
- }
- else
- {
- NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
- return; // do not process unsoliced data packets
- }
-}
+// // Set pruning timout on PIT entry (instead of deleting the record)
+// m_pit->MarkErased (pitEntry);
+// }
+// }
+// else
+// {
+// NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
+// return; // do not process unsoliced data packets
+// }
+// }
-// Processing ContentObjects
-void
-CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
- Ptr<CcnxContentObjectHeader> &header,
- Ptr<Packet> &payload,
- const Ptr<const Packet> &packet)
-{
+// // Processing ContentObjects
+// void
+// CcnxL3Protocol::OnData (const Ptr<CcnxFace> &incomingFace,
+// Ptr<CcnxContentObjectHeader> &header,
+// Ptr<Packet> &payload,
+// const Ptr<const Packet> &packet)
+// {
- NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
- m_inData (header, payload, incomingFace);
+// NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
+// m_inData (header, payload, incomingFace);
- // 1. Lookup PIT entry
- Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
- if (pitEntry != 0)
- {
- // Note that with MultiIndex we need to modify entries indirectly
+// // 1. Lookup PIT entry
+// Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+// if (pitEntry != 0)
+// {
+// // Note that with MultiIndex we need to modify entries indirectly
- CcnxPitEntry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
+// CcnxPitEntry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
- // If we have sent interest for this data via this face, then update stats.
- if (out != pitEntry->GetOutgoing ().end ())
- {
- pitEntry->GetFibEntry ()->UpdateFaceRtt (incomingFace, Simulator::Now () - out->m_sendTime);
- // StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
- // ll::bind (&CcnxFibEntry::UpdateFaceRtt,
- // ll::_1,
- // incomingFace,
- // Simulator::Now () - out->m_sendTime));
- }
- else
- {
- // Unsolicited data, but we're interested in it... should we get it?
- // Potential hole for attacks
+// // If we have sent interest for this data via this face, then update stats.
+// if (out != pitEntry->GetOutgoing ().end ())
+// {
+// pitEntry->GetFibEntry ()->UpdateFaceRtt (incomingFace, Simulator::Now () - out->m_sendTime);
+// // StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
+// // ll::bind (&CcnxFibEntry::UpdateFaceRtt,
+// // ll::_1,
+// // incomingFace,
+// // Simulator::Now () - out->m_sendTime));
+// }
+// else
+// {
+// // Unsolicited data, but we're interested in it... should we get it?
+// // Potential hole for attacks
- if (m_cacheUnsolicitedData)
- {
- // Optimistically add or update entry in the content store
- m_contentStore->Add (header, payload);
- }
- else
- {
- NS_LOG_ERROR ("Node "<< m_node->GetId() <<
- ". PIT entry for "<< header->GetName ()<<" is valid, "
- "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
- }
- // ignore unsolicited data
- return;
- }
+// if (m_cacheUnsolicitedData)
+// {
+// // Optimistically add or update entry in the content store
+// m_contentStore->Add (header, payload);
+// }
+// else
+// {
+// NS_LOG_ERROR ("Node "<< m_node->GetId() <<
+// ". PIT entry for "<< header->GetName ()<<" is valid, "
+// "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
+// }
+// // ignore unsolicited data
+// return;
+// }
- // Update metric status for the incoming interface in the corresponding FIB entry
- pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN);
- // StaticCast<CcnxFibImpl>(m_fib)->modify (pitEntry->GetFibEntry (),
- // ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
- // incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
+// // Update metric status for the incoming interface in the corresponding FIB entry
+// pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN);
+// // StaticCast<CcnxFibImpl>(m_fib)->modify (pitEntry->GetFibEntry (),
+// // ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
+// // incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
- // Add or update entry in the content store
- m_contentStore->Add (header, payload);
+// // Add or update entry in the content store
+// m_contentStore->Add (header, payload);
- pitEntry->RemoveIncoming (incomingFace);
+// pitEntry->RemoveIncoming (incomingFace);
- if (pitEntry->GetIncoming ().size () == 0)
- {
- // Set pruning timout on PIT entry (instead of deleting the record)
- m_pit->MarkErased (pitEntry);
- }
- else
- {
- OnDataDelayed (header, payload, packet);
- }
- }
- else
- {
- NS_LOG_DEBUG ("Pit entry not found");
- if (m_cacheUnsolicitedData)
- {
- // Optimistically add or update entry in the content store
- m_contentStore->Add (header, payload);
- }
- else
- {
- // Drop data packet if PIT entry is not found
- // (unsolicited data packets should not "poison" content store)
+// if (pitEntry->GetIncoming ().size () == 0)
+// {
+// // Set pruning timout on PIT entry (instead of deleting the record)
+// m_pit->MarkErased (pitEntry);
+// }
+// else
+// {
+// OnDataDelayed (header, payload, packet);
+// }
+// }
+// else
+// {
+// NS_LOG_DEBUG ("Pit entry not found");
+// if (m_cacheUnsolicitedData)
+// {
+// // Optimistically add or update entry in the content store
+// m_contentStore->Add (header, payload);
+// }
+// else
+// {
+// // 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, UNSOLICITED, incomingFace);
- }
- return; // do not process unsoliced data packets
- }
-}
+// //drop dulicated or not requested data packet
+// m_dropData (header, payload, UNSOLICITED, incomingFace);
+// }
+// return; // do not process unsoliced data packets
+// }
+// }
-void
-CcnxL3Protocol::GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
- Ptr<CcnxInterestHeader> header)
-{
- NS_LOG_FUNCTION (this);
+// void
+// CcnxL3Protocol::GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
+// Ptr<CcnxInterestHeader> header)
+// {
+// NS_LOG_FUNCTION (this);
- if (m_nacksEnabled)
- {
- Ptr<Packet> packet = Create<Packet> ();
- header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
- packet->AddHeader (*header);
+// if (m_nacksEnabled)
+// {
+// Ptr<Packet> packet = Create<Packet> ();
+// header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
+// packet->AddHeader (*header);
- BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
- {
- NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
- incoming.m_face->Send (packet->Copy ());
+// BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+// {
+// NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
+// incoming.m_face->Send (packet->Copy ());
- m_outNacks (header, incoming.m_face);
- }
+// m_outNacks (header, incoming.m_face);
+// }
- // All incoming interests cannot be satisfied. Remove them
- pitEntry->ClearIncoming ();
+// // All incoming interests cannot be satisfied. Remove them
+// pitEntry->ClearIncoming ();
- // Remove also outgoing
- pitEntry->ClearOutgoing ();
+// // Remove also outgoing
+// pitEntry->ClearOutgoing ();
- // Set pruning timout on PIT entry (instead of deleting the record)
- m_pit->MarkErased (pitEntry);
- }
-}
+// // Set pruning timout on PIT entry (instead of deleting the record)
+// m_pit->MarkErased (pitEntry);
+// }
+// }
} //namespace ns3
diff --git a/model/ccnx-l3-protocol.h b/model/ccnx-l3-protocol.h
index 9731c8e..3525db5 100644
--- a/model/ccnx-l3-protocol.h
+++ b/model/ccnx-l3-protocol.h
@@ -28,9 +28,9 @@
#include "ns3/net-device.h"
#include "ns3/nstime.h"
-#include "ccnx-content-store.h"
-#include "ccnx-pit.h"
-#include "ccnx-fib.h"
+// #include "ccnx-content-store.h"
+// #include "ccnx-pit.h"
+// #include "ccnx-fib.h"
#include "ccnx.h"
@@ -106,46 +106,46 @@
void
Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p);
- /**
- * \brief Actual processing of incoming CCNx interests. Note, interests do not have payload
- *
- * Processing Interest packets
- * @param face incoming face
- * @param header deserialized Interest header
- * @param packet original packet
- */
- void
- OnInterest (const Ptr<CcnxFace> &face,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &p);
+ // /**
+ // * \brief Actual processing of incoming CCNx interests. Note, interests do not have payload
+ // *
+ // * Processing Interest packets
+ // * @param face incoming face
+ // * @param header deserialized Interest header
+ // * @param packet original packet
+ // */
+ // void
+ // OnInterest (const Ptr<CcnxFace> &face,
+ // Ptr<CcnxInterestHeader> &header,
+ // const Ptr<const Packet> &p);
- /**
- * \brief Processing of incoming CCNx NACKs. Note, these packets, like interests, do not have payload
- *
- * Processing NACK packets
- * @param face incoming face
- * @param header deserialized Interest header
- * @param packet original packet
- */
- void
- OnNack (const Ptr<CcnxFace> &face,
- Ptr<CcnxInterestHeader> &header,
- const Ptr<const Packet> &p);
+ // /**
+ // * \brief Processing of incoming CCNx NACKs. Note, these packets, like interests, do not have payload
+ // *
+ // * Processing NACK packets
+ // * @param face incoming face
+ // * @param header deserialized Interest header
+ // * @param packet original packet
+ // */
+ // void
+ // OnNack (const Ptr<CcnxFace> &face,
+ // Ptr<CcnxInterestHeader> &header,
+ // const Ptr<const Packet> &p);
- /**
- * \brief Actual processing of incoming CCNx content objects
- *
- * Processing ContentObject packets
- * @param face incoming face
- * @param header deserialized ContentObject header
- * @param payload data packet payload
- * @param packet original packet
- */
- void
- OnData (const Ptr<CcnxFace> &face,
- Ptr<CcnxContentObjectHeader> &header,
- Ptr<Packet> &payload,
- const Ptr<const Packet> &packet);
+ // /**
+ // * \brief Actual processing of incoming CCNx content objects
+ // *
+ // * Processing ContentObject packets
+ // * @param face incoming face
+ // * @param header deserialized ContentObject header
+ // * @param payload data packet payload
+ // * @param packet original packet
+ // */
+ // void
+ // OnData (const Ptr<CcnxFace> &face,
+ // Ptr<CcnxContentObjectHeader> &header,
+ // Ptr<Packet> &payload,
+ // const Ptr<const Packet> &packet);
protected:
virtual void DoDispose (void); ///< @brief Do cleanup
@@ -160,14 +160,14 @@
CcnxL3Protocol(const CcnxL3Protocol &); ///< copy constructor is disabled
CcnxL3Protocol &operator = (const CcnxL3Protocol &); ///< copy operator is disabled
- void
- GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
- Ptr<CcnxInterestHeader> header);
+ // void
+ // GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
+ // Ptr<CcnxInterestHeader> header);
- void
- OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
- Ptr<const Packet> payload,
- const Ptr<const Packet> &packet);
+ // void
+ // OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
+ // Ptr<const Packet> payload,
+ // const Ptr<const Packet> &packet);
private:
uint32_t m_faceCounter; ///< \brief counter of faces. Increased every time a new face is added to the stack
@@ -177,12 +177,9 @@
// These objects are aggregated, but for optimization, get them here
Ptr<Node> m_node; ///< \brief node on which ccnx stack is installed
Ptr<CcnxForwardingStrategy> m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
- Ptr<CcnxPit> m_pit; ///< \brief PIT (pending interest table)
- Ptr<CcnxFib> m_fib; ///< \brief FIB
- Ptr<CcnxContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
- bool m_nacksEnabled;
- bool m_cacheUnsolicitedData;
+ // bool m_nacksEnabled;
+ // bool m_cacheUnsolicitedData;
};
} // Namespace ns3
diff --git a/model/ccnx.cc b/model/ccnx.cc
index 2e30e7f..79452bf 100644
--- a/model/ccnx.cc
+++ b/model/ccnx.cc
@@ -24,7 +24,7 @@
#include "ccnx.h"
#include "ccnx-face.h"
-#include "ccnx-forwarding-strategy.h"
+#include "forwarding-strategy/ccnx-forwarding-strategy.h"
#include "ccnx-interest-header.h"
#include "ccnx-content-object-header.h"
@@ -38,29 +38,6 @@
static TypeId tid = TypeId ("ns3::Ccnx")
.SetGroupName ("Ccnx")
.SetParent<Object> ()
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- // "OutInterests" trace is inside CcnxForwardingStrategy
- .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&Ccnx::m_inInterests))
- .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&Ccnx::m_dropInterests))
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("OutNacks", "OutNacks", MakeTraceSourceAccessor (&Ccnx::m_outNacks))
- .AddTraceSource ("InNacks", "InNacks", MakeTraceSourceAccessor (&Ccnx::m_inNacks))
- .AddTraceSource ("DropNacks", "DropNacks", MakeTraceSourceAccessor (&Ccnx::m_dropNacks))
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&Ccnx::m_outData))
- .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&Ccnx::m_inData))
- .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&Ccnx::m_dropData))
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
;
return tid;
}
diff --git a/model/ccnx.h b/model/ccnx.h
index 573a567..ca36c1f 100644
--- a/model/ccnx.h
+++ b/model/ccnx.h
@@ -131,64 +131,21 @@
virtual Ptr<CcnxFace>
GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
- /**
- * \enum DropReason
- * \brief A reason why the packet has been dropped
- */
- enum DropReason
- {
- DUPLICATED, // Interests
- SUPPRESSED, // Interests and Nacks
- NO_FACES, // Interests
- NON_DUPLICATED, // Nacks
- AFTER_SATISFIED, // Nacks
- UNSOLICITED, // data
- PIT_LIMIT // PIT limit reached
- };
-
-protected:
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- // transmittedInterestTrace is inside ForwardingStrategy
-
- TracedCallback<Ptr<const CcnxInterestHeader>,
- Ptr<const CcnxFace> > m_inInterests; ///< @brief trace of incoming Interests
-
- TracedCallback<Ptr<const CcnxInterestHeader>,
- DropReason,
- Ptr<const CcnxFace> > m_dropInterests; ///< @brief trace of dropped Interests
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- TracedCallback<Ptr<const CcnxInterestHeader>,
- Ptr<const CcnxFace> > m_outNacks; ///< @brief trace of outgoing NACKs
-
- TracedCallback<Ptr<const CcnxInterestHeader>,
- Ptr<const CcnxFace> > m_inNacks; ///< @brief trace of incoming NACKs
-
- TracedCallback<Ptr<const CcnxInterestHeader>,
- DropReason,
- Ptr<const CcnxFace> > m_dropNacks; ///< @brief trace of dropped NACKs
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
- bool /*from cache*/,
- Ptr<const CcnxFace> > m_outData; ///< @brief trace of outgoing Data
-
- TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
- Ptr<const CcnxFace> > m_inData; ///< @brief trace of incoming Data
-
- TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
- DropReason,
- Ptr<const CcnxFace> > m_dropData; ///< @brief trace of dropped Data
-};
+ // /**
+ // * \enum DropReason
+ // * \brief A reason why the packet has been dropped
+ // */
+ // enum DropReason
+ // {
+ // DUPLICATED, // Interests
+ // SUPPRESSED, // Interests and Nacks
+ // NO_FACES, // Interests
+ // NON_DUPLICATED, // Nacks
+ // AFTER_SATISFIED, // Nacks
+ // UNSOLICITED, // data
+ // PIT_LIMIT // PIT limit reached
+ // };
+ };
} // namespace ns3
diff --git a/model/ccnx-content-store-impl.h b/model/content-store/ccnx-content-store-impl.h
similarity index 100%
rename from model/ccnx-content-store-impl.h
rename to model/content-store/ccnx-content-store-impl.h
diff --git a/model/ccnx-content-store-policies.cc b/model/content-store/ccnx-content-store-policies.cc
similarity index 100%
rename from model/ccnx-content-store-policies.cc
rename to model/content-store/ccnx-content-store-policies.cc
diff --git a/model/ccnx-content-store-policies.h b/model/content-store/ccnx-content-store-policies.h
similarity index 93%
rename from model/ccnx-content-store-policies.h
rename to model/content-store/ccnx-content-store-policies.h
index ca7c3c7..cb8ee10 100644
--- a/model/ccnx-content-store-policies.h
+++ b/model/content-store/ccnx-content-store-policies.h
@@ -26,12 +26,12 @@
#include "ccnx-content-store-impl.h"
-#include "../utils/trie.h"
-#include "../utils/trie-with-policy.h"
+#include "../../utils/trie.h"
+#include "../../utils/trie-with-policy.h"
-#include "../utils/lru-policy.h"
-#include "../utils/random-policy.h"
-#include "../utils/fifo-policy.h"
+#include "../../utils/lru-policy.h"
+#include "../../utils/random-policy.h"
+#include "../../utils/fifo-policy.h"
namespace ns3
{
diff --git a/model/ccnx-content-store.cc b/model/content-store/ccnx-content-store.cc
similarity index 100%
rename from model/ccnx-content-store.cc
rename to model/content-store/ccnx-content-store.cc
diff --git a/model/ccnx-content-store.h b/model/content-store/ccnx-content-store.h
similarity index 100%
rename from model/ccnx-content-store.h
rename to model/content-store/ccnx-content-store.h
diff --git a/model/ccnx-fib-entry.cc b/model/fib/ccnx-fib-entry.cc
similarity index 100%
rename from model/ccnx-fib-entry.cc
rename to model/fib/ccnx-fib-entry.cc
diff --git a/model/ccnx-fib-entry.h b/model/fib/ccnx-fib-entry.h
similarity index 100%
rename from model/ccnx-fib-entry.h
rename to model/fib/ccnx-fib-entry.h
diff --git a/model/ccnx-fib-impl.cc b/model/fib/ccnx-fib-impl.cc
similarity index 98%
rename from model/ccnx-fib-impl.cc
rename to model/fib/ccnx-fib-impl.cc
index 10217e3..107f072 100644
--- a/model/ccnx-fib-impl.cc
+++ b/model/fib/ccnx-fib-impl.cc
@@ -20,9 +20,9 @@
#include "ccnx-fib-impl.h"
-#include "ccnx.h"
-#include "ccnx-face.h"
-#include "ccnx-interest-header.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-face.h"
+#include "ns3/ccnx-interest-header.h"
#include "ns3/node.h"
#include "ns3/assert.h"
diff --git a/model/ccnx-fib-impl.h b/model/fib/ccnx-fib-impl.h
similarity index 97%
rename from model/ccnx-fib-impl.h
rename to model/fib/ccnx-fib-impl.h
index eaedeee..d85dcfd 100644
--- a/model/ccnx-fib-impl.h
+++ b/model/fib/ccnx-fib-impl.h
@@ -24,8 +24,8 @@
#include "ns3/ccnx-fib.h"
#include "ns3/ccnx-name-components.h"
-#include "../utils/trie-with-policy.h"
-#include "../utils/counting-policy.h"
+#include "../../utils/trie-with-policy.h"
+#include "../../utils/counting-policy.h"
namespace ns3 {
diff --git a/model/ccnx-fib.cc b/model/fib/ccnx-fib.cc
similarity index 92%
rename from model/ccnx-fib.cc
rename to model/fib/ccnx-fib.cc
index e25f161..fdd1aea 100644
--- a/model/ccnx-fib.cc
+++ b/model/fib/ccnx-fib.cc
@@ -20,13 +20,13 @@
#include "ccnx-fib.h"
-#include "ccnx.h"
-#include "ccnx-face.h"
-#include "ccnx-interest-header.h"
-
-#include "ccnx-name-components.h"
#include "ccnx-fib-impl.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-face.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-name-components.h"
+
#include "ns3/node.h"
#include "ns3/names.h"
diff --git a/model/ccnx-fib.h b/model/fib/ccnx-fib.h
similarity index 100%
rename from model/ccnx-fib.h
rename to model/fib/ccnx-fib.h
diff --git a/model/ccnx-bestroute-strategy.cc b/model/forwarding-strategy/ccnx-bestroute-strategy.cc
similarity index 95%
rename from model/ccnx-bestroute-strategy.cc
rename to model/forwarding-strategy/ccnx-bestroute-strategy.cc
index 6548ae5..75efdd4 100644
--- a/model/ccnx-bestroute-strategy.cc
+++ b/model/forwarding-strategy/ccnx-bestroute-strategy.cc
@@ -21,9 +21,9 @@
#include "ccnx-bestroute-strategy.h"
-#include "ccnx-interest-header.h"
-#include "ccnx-pit.h"
-#include "ccnx-pit-entry.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-pit.h"
+#include "ns3/ccnx-pit-entry.h"
#include "ns3/assert.h"
#include "ns3/log.h"
@@ -106,7 +106,7 @@
//transmission
metricFace.m_face->Send (packetToSend);
- m_transmittedInterestsTrace (header, metricFace.m_face);
+ m_outInterests (header, metricFace.m_face);
propagatedCount++;
break; // do only once
diff --git a/model/ccnx-bestroute-strategy.h b/model/forwarding-strategy/ccnx-bestroute-strategy.h
similarity index 100%
rename from model/ccnx-bestroute-strategy.h
rename to model/forwarding-strategy/ccnx-bestroute-strategy.h
diff --git a/model/ccnx-flooding-strategy.cc b/model/forwarding-strategy/ccnx-flooding-strategy.cc
similarity index 96%
rename from model/ccnx-flooding-strategy.cc
rename to model/forwarding-strategy/ccnx-flooding-strategy.cc
index 3531249..c803560 100644
--- a/model/ccnx-flooding-strategy.cc
+++ b/model/forwarding-strategy/ccnx-flooding-strategy.cc
@@ -20,9 +20,10 @@
*/
#include "ccnx-flooding-strategy.h"
-#include "ccnx-interest-header.h"
-#include "ccnx-pit.h"
-#include "ccnx-pit-entry.h"
+
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-pit.h"
+#include "ns3/ccnx-pit-entry.h"
#include "ns3/assert.h"
#include "ns3/log.h"
@@ -119,7 +120,7 @@
//transmission
metricFace.m_face->Send (packetToSend);
- m_transmittedInterestsTrace (header, metricFace.m_face);
+ m_outInterests (header, metricFace.m_face);
propagatedCount++;
}
diff --git a/model/ccnx-flooding-strategy.h b/model/forwarding-strategy/ccnx-flooding-strategy.h
similarity index 100%
rename from model/ccnx-flooding-strategy.h
rename to model/forwarding-strategy/ccnx-flooding-strategy.h
diff --git a/model/forwarding-strategy/ccnx-forwarding-strategy.cc b/model/forwarding-strategy/ccnx-forwarding-strategy.cc
new file mode 100644
index 0000000..9cdfa4d
--- /dev/null
+++ b/model/forwarding-strategy/ccnx-forwarding-strategy.cc
@@ -0,0 +1,494 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+#include "ccnx-forwarding-strategy.h"
+
+#include "ns3/ccnx-pit.h"
+#include "ns3/ccnx-pit-entry.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx-pit.h"
+#include "ns3/ccnx-fib.h"
+#include "ns3/ccnx-content-store.h"
+
+#include "ns3/assert.h"
+#include "ns3/ptr.h"
+#include "ns3/log.h"
+#include "ns3/simulator.h"
+#include "ns3/boolean.h"
+#include "ns3/string.h"
+
+#include <boost/ref.hpp>
+#include <boost/foreach.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
+#include <boost/tuple/tuple.hpp>
+namespace ll = boost::lambda;
+
+NS_LOG_COMPONENT_DEFINE ("CcnxForwardingStrategy");
+
+namespace ns3 {
+
+using namespace __ccnx_private;
+
+NS_OBJECT_ENSURE_REGISTERED (CcnxForwardingStrategy);
+
+TypeId CcnxForwardingStrategy::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::CcnxForwardingStrategy")
+ .SetGroupName ("Ccnx")
+ .SetParent<Object> ()
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ .AddTraceSource ("OutInterests", "OutInterests", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_outInterests))
+ .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_inInterests))
+ .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_dropInterests))
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ .AddTraceSource ("OutNacks", "OutNacks", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_outNacks))
+ .AddTraceSource ("InNacks", "InNacks", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_inNacks))
+ .AddTraceSource ("DropNacks", "DropNacks", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_dropNacks))
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_outData))
+ .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_inData))
+ .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&CcnxForwardingStrategy::m_dropData))
+
+ .AddAttribute ("EnableNACKs", "Enabling support of NACKs",
+ BooleanValue (false),
+ MakeBooleanAccessor (&CcnxForwardingStrategy::m_nacksEnabled),
+ MakeBooleanChecker ())
+ .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
+ BooleanValue (false),
+ MakeBooleanAccessor (&CcnxForwardingStrategy::m_cacheUnsolicitedData),
+ MakeBooleanChecker ())
+
+ ;
+ return tid;
+}
+
+CcnxForwardingStrategy::CcnxForwardingStrategy ()
+{
+}
+
+CcnxForwardingStrategy::~CcnxForwardingStrategy ()
+{
+}
+
+void
+CcnxForwardingStrategy::NotifyNewAggregate ()
+{
+ if (m_pit == 0)
+ {
+ m_pit = GetObject<CcnxPit> ();
+ }
+ if (m_fib == 0)
+ {
+ m_fib = GetObject<CcnxFib> ();
+ }
+ if (m_contentStore == 0)
+ {
+ m_contentStore = GetObject<CcnxContentStore> ();
+ }
+
+ Object::NotifyNewAggregate ();
+}
+
+void
+CcnxForwardingStrategy::DoDispose ()
+{
+ m_pit = 0;
+ m_contentStore = 0;
+ m_fib = 0;
+
+ Object::DoDispose ();
+}
+
+void
+CcnxForwardingStrategy::OnInterest (const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet)
+{
+ m_inInterests (header, incomingFace);
+
+ Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+ if (pitEntry == 0)
+ {
+ pitEntry = m_pit->Create (header);
+ }
+
+ if (pitEntry == 0)
+ {
+ // if it is still not created, then give up processing
+ m_dropInterests (header, incomingFace);
+ return;
+ }
+
+ bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
+ bool isDuplicated = true;
+ if (!pitEntry->IsNonceSeen (header->GetNonce ()))
+ {
+ pitEntry->AddSeenNonce (header->GetNonce ());
+ isDuplicated = false;
+ }
+
+ NS_LOG_FUNCTION (header->GetName () << header->GetNonce () << boost::cref (*incomingFace) << isDuplicated);
+
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////
+ // //
+ // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
+ // //
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////
+
+ // Data is not in cache
+ CcnxPitEntry::in_iterator inFace = pitEntry->GetIncoming ().find (incomingFace);
+ CcnxPitEntry::out_iterator outFace = pitEntry->GetOutgoing ().find (incomingFace);
+
+ bool isRetransmitted = false;
+
+ if (inFace != pitEntry->GetIncoming ().end ())
+ {
+ // CcnxPitEntryIncomingFace.m_arrivalTime keeps track arrival time of the first packet... why?
+
+ isRetransmitted = true;
+ // this is almost definitely a retransmission. But should we trust the user on that?
+ }
+ else
+ {
+ inFace = pitEntry->AddIncoming (incomingFace);
+ }
+ //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////
+
+ if (isDuplicated)
+ {
+ NS_LOG_DEBUG ("Received duplicatie interest on " << *incomingFace);
+ m_dropInterests (header, incomingFace);
+
+ /**
+ * This condition will handle "routing" loops and also recently satisfied interests.
+ * Every time interest is satisfied, PIT entry (with empty incoming and outgoing faces)
+ * is kept for another small chunk of time.
+ */
+
+ if (m_nacksEnabled)
+ {
+ NS_LOG_DEBUG ("Sending NACK_LOOP");
+ header->SetNack (CcnxInterestHeader::NACK_LOOP);
+ Ptr<Packet> nack = Create<Packet> ();
+ nack->AddHeader (*header);
+
+ incomingFace->Send (nack);
+ m_outNacks (header, incomingFace);
+ }
+
+ return;
+ }
+
+ Ptr<Packet> contentObject;
+ Ptr<const CcnxContentObjectHeader> contentObjectHeader; // used for tracing
+ Ptr<const Packet> payload; // used for tracing
+ boost::tie (contentObject, contentObjectHeader, payload) = m_contentStore->Lookup (header);
+ if (contentObject != 0)
+ {
+ NS_ASSERT (contentObjectHeader != 0);
+ NS_LOG_LOGIC("Found in cache");
+
+ OnDataDelayed (contentObjectHeader, payload, contentObject);
+ return;
+ }
+
+ // update PIT entry lifetime
+ pitEntry->UpdateLifetime (header->GetInterestLifetime ());
+
+ if (outFace != pitEntry->GetOutgoing ().end ())
+ {
+ NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
+ // got a non-duplicate interest from the face we have sent interest to
+ // Probably, there is no point in waiting data from that face... Not sure yet
+
+ // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
+ // Mark interface YELLOW, but keep a small hope that data will come eventually.
+
+ // ?? not sure if we need to do that ?? ...
+
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW);
+ // StaticCast<CcnxFibImpl> (m_fib)->modify(pitEntry->GetFibEntry (),
+ // ll::bind (&CcnxFibEntry::UpdateStatus,
+ // ll::_1, incomingFace, CcnxFibFaceMetric::NDN_FIB_YELLOW));
+ }
+ else
+ if (!isNew && !isRetransmitted)
+ {
+ // Suppress this interest if we're still expecting data from some other face
+ NS_LOG_DEBUG ("Suppress interests");
+ m_dropInterests (header, incomingFace);
+ return;
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ // Propagate
+ /////////////////////////////////////////////////////////////////////
+
+ bool propagated = PropagateInterest (pitEntry, incomingFace, header, packet);
+
+ if (!propagated && isRetransmitted) //give another chance if retransmitted
+ {
+ // increase max number of allowed retransmissions
+ pitEntry->IncreaseAllowedRetxCount ();
+
+ // try again
+ propagated = PropagateInterest (pitEntry, incomingFace, header, packet);
+ }
+
+ // 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)
+ {
+ NS_LOG_DEBUG ("Not propagated");
+ m_dropInterests (header, incomingFace);
+ GiveUpInterest (pitEntry, header);
+ }
+}
+
+void
+CcnxForwardingStrategy::OnData (const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxContentObjectHeader> &header,
+ Ptr<Packet> &payload,
+ const Ptr<const Packet> &packet)
+{
+ NS_LOG_FUNCTION (incomingFace << header->GetName () << payload << packet);
+ m_inData (header, payload, incomingFace);
+
+ // 1. Lookup PIT entry
+ Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+ if (pitEntry != 0)
+ {
+ // Note that with MultiIndex we need to modify entries indirectly
+
+ CcnxPitEntry::out_iterator out = pitEntry->GetOutgoing ().find (incomingFace);
+
+ // If we have sent interest for this data via this face, then update stats.
+ if (out != pitEntry->GetOutgoing ().end ())
+ {
+ pitEntry->GetFibEntry ()->UpdateFaceRtt (incomingFace, Simulator::Now () - out->m_sendTime);
+ // StaticCast<CcnxFibImpl> (m_fib)->modify (pitEntry->GetFibEntry (),
+ // ll::bind (&CcnxFibEntry::UpdateFaceRtt,
+ // ll::_1,
+ // incomingFace,
+ // Simulator::Now () - out->m_sendTime));
+ }
+ else
+ {
+ // Unsolicited data, but we're interested in it... should we get it?
+ // Potential hole for attacks
+
+ if (m_cacheUnsolicitedData)
+ {
+ // Optimistically add or update entry in the content store
+ m_contentStore->Add (header, payload);
+ }
+ else
+ {
+ NS_LOG_ERROR ("PIT entry for "<< header->GetName ()<<" is valid, "
+ "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
+ }
+ // ignore unsolicited data
+ return;
+ }
+
+ // Update metric status for the incoming interface in the corresponding FIB entry
+ pitEntry->GetFibEntry ()->UpdateStatus (incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN);
+ // StaticCast<CcnxFibImpl>(m_fib)->modify (pitEntry->GetFibEntry (),
+ // ll::bind (&CcnxFibEntry::UpdateStatus, ll::_1,
+ // incomingFace, CcnxFibFaceMetric::NDN_FIB_GREEN));
+
+ // Add or update entry in the content store
+ m_contentStore->Add (header, payload);
+
+ pitEntry->RemoveIncoming (incomingFace);
+
+ if (pitEntry->GetIncoming ().size () == 0)
+ {
+ // Set pruning timout on PIT entry (instead of deleting the record)
+ m_pit->MarkErased (pitEntry);
+ }
+ else
+ {
+ OnDataDelayed (header, payload, packet);
+ }
+ }
+ else
+ {
+ NS_LOG_DEBUG ("Pit entry not found");
+ if (m_cacheUnsolicitedData)
+ {
+ // Optimistically add or update entry in the content store
+ m_contentStore->Add (header, payload);
+ }
+ else
+ {
+ // 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, incomingFace);
+ }
+ return; // do not process unsoliced data packets
+ }
+}
+
+
+bool
+CcnxForwardingStrategy::PropagateInterestViaGreen (Ptr<CcnxPitEntry> pitEntry,
+ const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet)
+{
+ NS_LOG_FUNCTION (this);
+ NS_ASSERT_MSG (m_pit != 0, "PIT should be aggregated with forwarding strategy");
+
+ int propagatedCount = 0;
+
+ BOOST_FOREACH (const CcnxFibFaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<i_metric> ())
+ {
+ if (metricFace.m_status == CcnxFibFaceMetric::NDN_FIB_RED ||
+ metricFace.m_status == CcnxFibFaceMetric::NDN_FIB_YELLOW)
+ break; //propagate only to green faces
+
+ if (pitEntry->GetIncoming ().find (metricFace.m_face) != pitEntry->GetIncoming ().end ())
+ continue; // don't forward to face that we received interest from
+
+ CcnxPitEntryOutgoingFaceContainer::type::iterator outgoing =
+ pitEntry->GetOutgoing ().find (metricFace.m_face);
+
+ if (outgoing != pitEntry->GetOutgoing ().end () &&
+ outgoing->m_retxCount >= pitEntry->GetMaxRetxCount ())
+ {
+ NS_LOG_DEBUG ("retxCount: " << outgoing->m_retxCount << ", maxRetxCount: " << pitEntry->GetMaxRetxCount ());
+ continue;
+ }
+
+ bool faceAvailable = metricFace.m_face->IsBelowLimit ();
+ if (!faceAvailable) // huh...
+ {
+ // let's try different green face
+ continue;
+ }
+
+ pitEntry->AddOutgoing (metricFace.m_face);
+
+ Ptr<Packet> packetToSend = packet->Copy ();
+
+ //transmission
+ metricFace.m_face->Send (packetToSend);
+ m_outInterests (header, metricFace.m_face);
+
+ propagatedCount++;
+ break; // propagate only one interest
+ }
+
+ return propagatedCount > 0;
+}
+
+void
+CcnxForwardingStrategy::OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
+ Ptr<const Packet> payload,
+ const Ptr<const Packet> &packet)
+{
+ // 1. Lookup PIT entry
+ Ptr<CcnxPitEntry> pitEntry = m_pit->Lookup (*header);
+ if (pitEntry != 0)
+ {
+ //satisfy all pending incoming Interests
+ BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+ {
+ incoming.m_face->Send (packet->Copy ());
+ m_outData (header, payload, false, incoming.m_face);
+ NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
+
+ // successfull forwarded data trace
+ }
+
+ if (pitEntry->GetIncoming ().size () > 0)
+ {
+ // All incoming interests are satisfied. Remove them
+ pitEntry->ClearIncoming ();
+
+ // Remove all outgoing faces
+ pitEntry->ClearOutgoing ();
+
+ // Set pruning timout on PIT entry (instead of deleting the record)
+ m_pit->MarkErased (pitEntry);
+ }
+ }
+ else
+ {
+ NS_LOG_DEBUG ("Pit entry not found (was satisfied and removed before)");
+ return; // do not process unsoliced data packets
+ }
+}
+
+void
+CcnxForwardingStrategy::GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
+ Ptr<CcnxInterestHeader> header)
+{
+ NS_LOG_FUNCTION (this);
+
+ if (m_nacksEnabled)
+ {
+ Ptr<Packet> packet = Create<Packet> ();
+ header->SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
+ packet->AddHeader (*header);
+
+ BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry->GetIncoming ())
+ {
+ NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
+ incoming.m_face->Send (packet->Copy ());
+
+ m_outNacks (header, incoming.m_face);
+ }
+
+ // All incoming interests cannot be satisfied. Remove them
+ pitEntry->ClearIncoming ();
+
+ // Remove also outgoing
+ pitEntry->ClearOutgoing ();
+
+ // Set pruning timout on PIT entry (instead of deleting the record)
+ m_pit->MarkErased (pitEntry);
+ }
+}
+
+
+} //namespace ns3
diff --git a/model/forwarding-strategy/ccnx-forwarding-strategy.h b/model/forwarding-strategy/ccnx-forwarding-strategy.h
new file mode 100644
index 0000000..20d92a4
--- /dev/null
+++ b/model/forwarding-strategy/ccnx-forwarding-strategy.h
@@ -0,0 +1,184 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+#ifndef CCNX_FORWARDING_STRATEGY_H
+#define CCNX_FORWARDING_STRATEGY_H
+
+#include "ns3/packet.h"
+#include "ns3/callback.h"
+#include "ns3/object.h"
+#include "ns3/traced-callback.h"
+
+namespace ns3 {
+
+class CcnxFace;
+class CcnxInterestHeader;
+class CcnxContentObjectHeader;
+class CcnxPit;
+class CcnxPitEntry;
+class CcnxFibFaceMetric;
+class CcnxFib;
+class CcnxContentStore;
+
+/**
+ * \ingroup ccnx
+ * \brief Abstract base class for CCNx forwarding strategies
+ */
+class CcnxForwardingStrategy : public Object
+{
+public:
+ static TypeId GetTypeId (void);
+
+ /**
+ * @brief Default constructor
+ */
+ CcnxForwardingStrategy ();
+ virtual ~CcnxForwardingStrategy ();
+
+ /**
+ * \brief Actual processing of incoming CCNx interests. Note, interests do not have payload
+ *
+ * Processing Interest packets
+ * @param face incoming face
+ * @param header deserialized Interest header
+ * @param packet original packet
+ */
+ virtual void
+ OnInterest (const Ptr<CcnxFace> &face,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &p);
+
+ /**
+ * \brief Actual processing of incoming CCNx content objects
+ *
+ * Processing ContentObject packets
+ * @param face incoming face
+ * @param header deserialized ContentObject header
+ * @param payload data packet payload
+ * @param packet original packet
+ */
+ virtual void
+ OnData (const Ptr<CcnxFace> &face,
+ Ptr<CcnxContentObjectHeader> &header,
+ Ptr<Packet> &payload,
+ const Ptr<const Packet> &packet);
+
+// protected:
+ /**
+ * @brief Base method to propagate the interest according to the forwarding strategy
+ *
+ * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
+ * @param incomingFace Incoming face
+ * @param header CcnxInterestHeader
+ * @param packet Original Interest packet
+ * @param sendCallback Send callback
+ *
+ * @return true if interest was successfully propagated, false if all options have failed
+ */
+ virtual bool
+ PropagateInterest (Ptr<CcnxPitEntry> pitEntry,
+ const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet) = 0;
+
+protected:
+ /**
+ * @brief Propagate interest via a green interface. Fail, if no green interfaces available
+ *
+ * @param pitEntry Reference to PIT entry (reference to corresponding FIB entry inside)
+ * @param incomingFace Incoming face
+ * @param header CcnxInterestHeader
+ * @param packet Original Interest packet
+ * @param sendCallback Send callback
+ * @return true if interest was successfully propagated, false if all options have failed
+ *
+ * \see PropagateInterest
+ */
+ bool
+ PropagateInterestViaGreen (Ptr<CcnxPitEntry> pitEntry,
+ const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet);
+
+ virtual void
+ GiveUpInterest (Ptr<CcnxPitEntry> pitEntry,
+ Ptr<CcnxInterestHeader> header);
+
+ virtual void
+ OnDataDelayed (Ptr<const CcnxContentObjectHeader> header,
+ Ptr<const Packet> payload,
+ const Ptr<const Packet> &packet);
+
+protected:
+ // inherited from Object class
+ virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
+ virtual void DoDispose (); ///< @brief Do cleanup
+
+protected:
+ Ptr<CcnxPit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
+ Ptr<CcnxFib> m_fib; ///< \brief FIB
+ Ptr<CcnxContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
+
+ bool m_nacksEnabled;
+ bool m_cacheUnsolicitedData;
+
+ // transmittedInterestTrace is inside ForwardingStrategy
+
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_outInterests; ///< @brief Transmitted interests trace
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_inInterests; ///< @brief trace of incoming Interests
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_dropInterests; ///< @brief trace of dropped Interests
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_outNacks; ///< @brief trace of outgoing NACKs
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_inNacks; ///< @brief trace of incoming NACKs
+
+ TracedCallback<Ptr<const CcnxInterestHeader>,
+ Ptr<const CcnxFace> > m_dropNacks; ///< @brief trace of dropped NACKs
+
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
+
+ TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
+ bool /*from cache*/,
+ Ptr<const CcnxFace> > m_outData; ///< @brief trace of outgoing Data
+
+ TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
+ Ptr<const CcnxFace> > m_inData; ///< @brief trace of incoming Data
+
+ TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
+ Ptr<const CcnxFace> > m_dropData; ///< @brief trace of dropped Data
+};
+
+} //namespace ns3
+
+#endif /* CCNX_FORWARDING_STRATEGY_H */
diff --git a/model/ccnx-pit-entry-impl.h b/model/pit/ccnx-pit-entry-impl.h
similarity index 100%
rename from model/ccnx-pit-entry-impl.h
rename to model/pit/ccnx-pit-entry-impl.h
diff --git a/model/ccnx-pit-entry-incoming-face.cc b/model/pit/ccnx-pit-entry-incoming-face.cc
similarity index 100%
rename from model/ccnx-pit-entry-incoming-face.cc
rename to model/pit/ccnx-pit-entry-incoming-face.cc
diff --git a/model/ccnx-pit-entry-incoming-face.h b/model/pit/ccnx-pit-entry-incoming-face.h
similarity index 98%
rename from model/ccnx-pit-entry-incoming-face.h
rename to model/pit/ccnx-pit-entry-incoming-face.h
index f88ad8a..7c5e17d 100644
--- a/model/ccnx-pit-entry-incoming-face.h
+++ b/model/pit/ccnx-pit-entry-incoming-face.h
@@ -24,7 +24,7 @@
#include "ns3/nstime.h"
#include "ns3/ptr.h"
-#include "ccnx-face.h"
+#include "ns3/ccnx-face.h"
// #include <iostream>
namespace ns3 {
diff --git a/model/ccnx-pit-entry-outgoing-face.cc b/model/pit/ccnx-pit-entry-outgoing-face.cc
similarity index 100%
rename from model/ccnx-pit-entry-outgoing-face.cc
rename to model/pit/ccnx-pit-entry-outgoing-face.cc
diff --git a/model/ccnx-pit-entry-outgoing-face.h b/model/pit/ccnx-pit-entry-outgoing-face.h
similarity index 98%
rename from model/ccnx-pit-entry-outgoing-face.h
rename to model/pit/ccnx-pit-entry-outgoing-face.h
index fbd13c5..b16b4fd 100644
--- a/model/ccnx-pit-entry-outgoing-face.h
+++ b/model/pit/ccnx-pit-entry-outgoing-face.h
@@ -24,7 +24,7 @@
#include "ns3/nstime.h"
#include "ns3/ptr.h"
-#include "ccnx-face.h"
+#include "ns3/ccnx-face.h"
namespace ns3 {
diff --git a/model/ccnx-pit-entry.cc b/model/pit/ccnx-pit-entry.cc
similarity index 97%
rename from model/ccnx-pit-entry.cc
rename to model/pit/ccnx-pit-entry.cc
index 73f966c..081b155 100644
--- a/model/ccnx-pit-entry.cc
+++ b/model/pit/ccnx-pit-entry.cc
@@ -19,9 +19,10 @@
*/
#include "ccnx-pit-entry.h"
-#include "ccnx-name-components.h"
-#include "ccnx-fib.h"
-#include "ccnx-interest-header.h"
+
+#include "ns3/ccnx-fib.h"
+#include "ns3/ccnx-name-components.h"
+#include "ns3/ccnx-interest-header.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
diff --git a/model/ccnx-pit-entry.h b/model/pit/ccnx-pit-entry.h
similarity index 99%
rename from model/ccnx-pit-entry.h
rename to model/pit/ccnx-pit-entry.h
index 1ccb6b4..37de28e 100644
--- a/model/ccnx-pit-entry.h
+++ b/model/pit/ccnx-pit-entry.h
@@ -24,9 +24,9 @@
#include "ns3/ptr.h"
#include "ns3/simple-ref-count.h"
+#include "ns3/ccnx-fib.h"
#include "ccnx-pit-entry-incoming-face.h"
#include "ccnx-pit-entry-outgoing-face.h"
-#include "ccnx-fib.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
diff --git a/model/ccnx-pit-impl.cc b/model/pit/ccnx-pit-impl.cc
similarity index 98%
rename from model/ccnx-pit-impl.cc
rename to model/pit/ccnx-pit-impl.cc
index f68f9dd..c1867f0 100644
--- a/model/ccnx-pit-impl.cc
+++ b/model/pit/ccnx-pit-impl.cc
@@ -19,12 +19,14 @@
*/
#include "ccnx-pit-impl.h"
+
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
+
#include "ns3/log.h"
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/simulator.h"
-#include "ccnx-interest-header.h"
-#include "ccnx-content-object-header.h"
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
diff --git a/model/ccnx-pit-impl.h b/model/pit/ccnx-pit-impl.h
similarity index 96%
rename from model/ccnx-pit-impl.h
rename to model/pit/ccnx-pit-impl.h
index 123ed85..692f78b 100644
--- a/model/ccnx-pit-impl.h
+++ b/model/pit/ccnx-pit-impl.h
@@ -22,9 +22,10 @@
#define _CCNX_PIT_IMPL_H_
#include "ccnx-pit.h"
-#include "../utils/trie-with-policy.h"
-#include "../utils/empty-policy.h"
-#include "../utils/persistent-policy.h"
+
+#include "../../utils/trie-with-policy.h"
+#include "../../utils/empty-policy.h"
+#include "../../utils/persistent-policy.h"
#include "ccnx-pit-entry-impl.h"
diff --git a/model/ccnx-pit.cc b/model/pit/ccnx-pit.cc
similarity index 96%
rename from model/ccnx-pit.cc
rename to model/pit/ccnx-pit.cc
index 00b892d..00e58c7 100644
--- a/model/ccnx-pit.cc
+++ b/model/pit/ccnx-pit.cc
@@ -19,12 +19,14 @@
*/
#include "ccnx-pit.h"
+
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
+
#include "ns3/log.h"
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/simulator.h"
-#include "ccnx-interest-header.h"
-#include "ccnx-content-object-header.h"
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
diff --git a/model/ccnx-pit.h b/model/pit/ccnx-pit.h
similarity index 100%
rename from model/ccnx-pit.h
rename to model/pit/ccnx-pit.h