Flooding forwarding strategy added
diff --git a/model/ccnx-flooding-strategy.cc b/model/ccnx-flooding-strategy.cc
new file mode 100644
index 0000000..5bb4647
--- /dev/null
+++ b/model/ccnx-flooding-strategy.cc
@@ -0,0 +1,131 @@
+/* -*- 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+#include "ccnx-flooding-strategy.h"
+#include "ns3/assert.h"
+
+#include "ccnx-route.h"
+
+NS_LOG_COMPONENT_DEFINE ("CcnxFloodingStrategy");
+
+namespace ns3
+{
+
+NS_OBJECT_ENSURE_REGISTERED (CcnxFloodingStrategy);
+
+TypeId CcnxFloodingStrategy::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::CcnxFloodingStrategy")
+ .SetGroupName ("Ccnx")
+ .SetParent<Object> ()
+ ;
+ return tid;
+}
+
+CcnxFloodingStrategy::CcnxFloodingStrategy ()
+{
+}
+
+
+bool
+CcnxFloodingStrategy::PropagateInterest (const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet,
+ SendCallback ucb)
+{
+ //CcnxFibEntryContainer::type::iterator fibEntryArray = GetFib()->LongestPrefixMatch(*header);
+ NS_LOG_FUNCTION(this);
+
+ CcnxFibEntryContainer::type::iterator fibEntryArray = GetCcnx()->GetObject<CcnxFib>()->LongestPrefixMatch(*header);
+ NS_LOG_INFO(*fibEntryArray);
+
+ int count = 0;
+ for(CcnxFibFaceMetricContainer::type::iterator face = fibEntryArray->m_faces.begin ();
+ face != fibEntryArray->m_faces.end ();
+ face++)
+ {
+ if(face->m_face == incomingFace)
+ continue;
+
+ NS_LOG_INFO("count="<<count);
+ ucb (face->m_face, header, packet->Copy());
+ count++;
+ }
+
+ /*const CcnxFibEntryContainer& s,
+
+ for (CcnxFibEntryContainer::type::iterator entry = fibEntryArray.begin ();
+ entry != fibEntryArray.end ();
+ entry++)
+ {
+
+ const typename boost::multi_index::index<CcnxFibEntryContainer, Tag>::type& i = get<Tag>(s);
+
+ typedef typename CcnxFibEntryContainer::value_type value_type;
+
+ for(const CcnxFibEntryContainer& c = i.begin(); c != i.end (); c++)
+ {
+ c->
+ }
+
+ for(nth_index<CcnxFibEntryContainer,1>::type::iterator it1=get<i_prefix>(entry).begin();
+ it1!=get<i_prefix>(entry).end();++it1)
+ {
+ //std::cout<<it1->name()<<std::endl;
+
+ CcnxFibFaceMetricContainer faceContainer = it1->m_faces;
+
+ const typename boost::multi_index::index<CcnxFibFaceMetricContainer, __ccnx_private::i_face>::type& i = get<__ccnx_private::i_face>(faceContainer);
+
+ //typedef typename CcnxFibEntryContainer::value_type value_type;
+
+ for(const CcnxFibFaceMetricContainer& c = i.begin(); c != i.end (); c++)
+ {
+ Ptr<CcnxFace> face = c->m_face;
+
+ typedef
+ Callback<void, const Ptr<CcnxFace> &, const Ptr<CcnxInterestHeader> &, const Ptr<Packet> &>
+ SendCallback;
+
+ ucb (face, header, packet);
+ }
+
+ }
+
+
+ // obtain a reference to the index tagged by Tag
+
+ const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& i=
+ get<Tag>(s);
+
+ typedef typename MultiIndexContainer::value_type value_type;
+
+ // dump the elements of the index to cout
+
+ std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
+ */
+
+ if(count == 0)
+ return false;
+ else
+ return true;
+}
+
+} //namespace ns3
diff --git a/model/ccnx-flooding-strategy.h b/model/ccnx-flooding-strategy.h
new file mode 100644
index 0000000..e79a604
--- /dev/null
+++ b/model/ccnx-flooding-strategy.h
@@ -0,0 +1,60 @@
+/* -*- 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+
+#ifndef CCNX_FLOODING_STRATEGY_H
+#define CCNX_FLOODING_STRATEGY_H
+
+#include "ns3/packet.h"
+#include "ns3/callback.h"
+#include "ns3/object.h"
+#include "ns3/log.h"
+
+#include "ccnx-forwarding-strategy.h"
+#include "ccnx.h"
+#include "ccnx-fib.h"
+
+namespace ns3
+{
+
+class CcnxFace;
+class CcnxInterestHeader;
+
+/**
+* \ingroup ccnx
+* \brief Flooding strategy
+*/
+
+class CcnxFloodingStrategy : public CcnxForwardingStrategy
+{
+public:
+ static TypeId GetTypeId (void);
+
+ CcnxFloodingStrategy ();
+
+ bool PropagateInterest (const Ptr<CcnxFace> &incomingFace,
+ Ptr<CcnxInterestHeader> &header,
+ const Ptr<const Packet> &packet,
+ SendCallback ucb);
+};
+
+} //namespace ns3
+
+#endif /* CCNX_FLOODING_STRATEGY_H */
diff --git a/model/ccnx-forwarding-strategy.cc b/model/ccnx-forwarding-strategy.cc
index b2aa342..b296959 100644
--- a/model/ccnx-forwarding-strategy.cc
+++ b/model/ccnx-forwarding-strategy.cc
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2009 University of Washington
+ * 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
@@ -14,6 +14,9 @@
* 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"
@@ -34,10 +37,20 @@
return tid;
}
-CcnxForwardingStrategy::CcnxForwardingStrategy (Ptr<CcnxFib> fib)
+CcnxForwardingStrategy::CcnxForwardingStrategy ()
{
- m_fib = fib;
}
-
+void
+CcnxForwardingStrategy::SetCcnx(Ptr<Ccnx> ccnx)
+{
+ m_ccnx = ccnx;
+}
+
+Ptr<Ccnx>
+CcnxForwardingStrategy::GetCcnx()
+{
+ return m_ccnx;
+}
+
} //namespace ns3
diff --git a/model/ccnx-forwarding-strategy.h b/model/ccnx-forwarding-strategy.h
index 0e6134e..6b4a832 100644
--- a/model/ccnx-forwarding-strategy.h
+++ b/model/ccnx-forwarding-strategy.h
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2009 University of Washington
+ * 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
@@ -15,7 +15,8 @@
* 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>
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Ilya Moiseenko <iliamo@cs.ucla.edu>
*/
#ifndef CCNX_FORWARDING_STRATEGY_H
#define CCNX_FORWARDING_STRATEGY_H
@@ -41,8 +42,10 @@
public:
static TypeId GetTypeId (void);
- CcnxForwardingStrategy (Ptr<CcnxFib> fib);
-
+ CcnxForwardingStrategy ();
+
+ void SetCcnx(Ptr<Ccnx> ccnx);
+
typedef
Callback<void, const Ptr<CcnxFace> &, const Ptr<CcnxInterestHeader> &, const Ptr<Packet> &>
SendCallback;
@@ -51,9 +54,10 @@
Ptr<CcnxInterestHeader> &header,
const Ptr<const Packet> &packet,
SendCallback ucb) = 0;
-
-private:
- Ptr<CcnxFib> m_fib; ///< \brief FIB
+ Ptr<Ccnx> GetCcnx();
+
+private:
+ Ptr<Ccnx> m_ccnx;
};
} //namespace ns3
diff --git a/model/ccnx-net-device-face.cc b/model/ccnx-net-device-face.cc
index 8304711..a903da7 100644
--- a/model/ccnx-net-device-face.cc
+++ b/model/ccnx-net-device-face.cc
@@ -78,6 +78,7 @@
void
CcnxNetDeviceFace::RegisterProtocolHandler (ProtocolHandler handler)
{
+ NS_LOG_FUNCTION(this);
NS_ASSERT_MSG (m_netDevice != 0, "CcnxNetDeviceFace needs to be assigned NetDevice first");
m_protocolHandler = handler;