Flooding forwarding strategy added
diff --git a/helper/ccnx-consumer-helper.cc b/helper/ccnx-consumer-helper.cc
index 765f6b6..adb3c6e 100644
--- a/helper/ccnx-consumer-helper.cc
+++ b/helper/ccnx-consumer-helper.cc
@@ -19,10 +19,8 @@
*/
#include "ccnx-consumer-helper.h"
-#include "ns3/inet-socket-address.h"
-#include "ns3/packet-socket-address.h"
-#include "ns3/string.h"
-#include "ns3/names.h"
+
+NS_LOG_COMPONENT_DEFINE ("CcnxConsumerHelper");
namespace ns3
{
diff --git a/helper/ccnx-consumer-helper.h b/helper/ccnx-consumer-helper.h
index d885e2e..7d0011f 100644
--- a/helper/ccnx-consumer-helper.h
+++ b/helper/ccnx-consumer-helper.h
@@ -34,6 +34,9 @@
#include "ns3/ccnx-local-face.h"
#include "ns3/callback.h"
#include "ns3/ccnx-consumer.h"
+#include "ns3/log.h"
+#include "ns3/string.h"
+#include "ns3/names.h"
namespace ns3
{
diff --git a/helper/ccnx-forwarding-helper.cc b/helper/ccnx-forwarding-helper.cc
index 8f01194..c840d7a 100644
--- a/helper/ccnx-forwarding-helper.cc
+++ b/helper/ccnx-forwarding-helper.cc
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2008 INRIA
+ * 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,8 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
*/
+
#include "ns3/node.h"
#include "ns3/node-list.h"
#include "ns3/simulator.h"
@@ -25,10 +26,36 @@
namespace ns3 {
-CcnxForwardingHelper::~CcnxForwardingHelper ()
+CcnxForwardingHelper::CcnxForwardingHelper()
{
+ m_strategy = Ccnx::NDN_FLOODING;
+}
+
+CcnxForwardingHelper::CcnxForwardingHelper(Ccnx::ForwardingStrategy strategy)
+{
+ m_strategy = strategy;
}
+CcnxForwardingHelper::~CcnxForwardingHelper ()
+{
+
+}
+
+void
+CcnxForwardingHelper::SetForwarding(Ptr<Ccnx> ccnx) const
+{
+ if(m_strategy == Ccnx::NDN_FLOODING)
+ {
+ Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> ();
+ ccnxForwarding->SetCcnx(ccnx);
+ ccnx->SetForwardingStrategy (ccnxForwarding);
+ }
+ else if(m_strategy == Ccnx::NDN_BESTROUTE)
+ {}
+ else if (m_strategy == Ccnx::NDN_RANKING)
+ {}
+}
+
// void
// CcnxForwardingHelper::PrintForwardingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
// {
diff --git a/helper/ccnx-forwarding-helper.h b/helper/ccnx-forwarding-helper.h
index 8ac041e..c40bc12 100644
--- a/helper/ccnx-forwarding-helper.h
+++ b/helper/ccnx-forwarding-helper.h
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2008 INRIA
+ * 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,18 +15,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
*/
+
#ifndef CCNX_FORWARDING_HELPER_H
#define CCNX_FORWARDING_HELPER_H
#include "ns3/ptr.h"
#include "ns3/nstime.h"
#include "ns3/output-stream-wrapper.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-flooding-strategy.h"
namespace ns3 {
-class CcnxForwardingStrategy;
class Node;
/**
@@ -39,26 +41,27 @@
class CcnxForwardingHelper
{
public:
+
+ /*
+ * \brief Default constructor, which sets NDN_FLOODING forwarding strategy
+ */
+ CcnxForwardingHelper();
+
+ /*
+ * \brief This constructor sets a specified forwarding strategy
+ */
+ CcnxForwardingHelper(Ccnx::ForwardingStrategy strategy);
+
/*
* Destroy an instance of an CcnxForwardingHelper
*/
- virtual ~CcnxForwardingHelper ();
+ ~CcnxForwardingHelper ();
- /**
- * \brief virtual constructor
- * \returns pointer to clone of this CcnxForwardingHelper
- *
- * This method is mainly for internal use by the other helpers;
- * clients are expected to free the dynamic memory allocated by this method
+ /*
+ * \brief creates a specified ForwardingStrategy object and binds it to Ccnx
*/
- virtual CcnxForwardingHelper* Copy () const = 0;
-
- /**
- * \param node the node within which the new forwarding protocol will run
- * \returns a newly-created forwarding protocol
- */
- virtual Ptr<CcnxForwardingStrategy> Create (Ptr<Node> node) const = 0;
-
+ void SetForwarding(Ptr<Ccnx> ccnx) const;
+
/**
* \brief prints the forwarding tables of all nodes at a particular time.
* \param printTime the time at which the forwarding table is supposed to be printed.
@@ -106,6 +109,7 @@
void PrintForwardingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
private:
+ Ccnx::ForwardingStrategy m_strategy;
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
diff --git a/helper/ccnx-producer-helper.cc b/helper/ccnx-producer-helper.cc
index 433a15a..c3ec37e 100644
--- a/helper/ccnx-producer-helper.cc
+++ b/helper/ccnx-producer-helper.cc
@@ -19,8 +19,8 @@
*/
#include "ccnx-producer-helper.h"
-#include "ns3/string.h"
-#include "ns3/names.h"
+
+NS_LOG_COMPONENT_DEFINE ("CcnxProducerHelper");
namespace ns3
{
@@ -40,6 +40,7 @@
ApplicationContainer
CcnxProducerHelper::Install (Ptr<Node> node)
{
+ NS_LOG_FUNCTION(this);
return ApplicationContainer (InstallPriv (node));
}
@@ -72,6 +73,7 @@
Ptr<Application>
CcnxProducerHelper::InstallPriv (Ptr<Node> node)
{
+ NS_LOG_INFO ("InstallPriv started");
Ptr<CcnxLocalFace> localFace = Create<CcnxLocalFace> ();
localFace->SetNode(node);
diff --git a/helper/ccnx-producer-helper.h b/helper/ccnx-producer-helper.h
index eda0d04..ca2dd7a 100644
--- a/helper/ccnx-producer-helper.h
+++ b/helper/ccnx-producer-helper.h
@@ -36,6 +36,9 @@
#include "ns3/ccnx-producer.h"
#include "ns3/uinteger.h"
#include "ns3/ccnx-stack-helper.h"
+#include "ns3/log.h"
+#include "ns3/string.h"
+#include "ns3/names.h"
namespace ns3
{
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index 428ddef..e1a554a 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -15,7 +15,7 @@
* 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>
*/
/**
@@ -57,7 +57,6 @@
#include "ns3/log.h"
#include "ns3/object.h"
#include "ns3/names.h"
-#include "ns3/ccnx.h"
#include "ns3/packet-socket-factory.h"
#include "ns3/config.h"
#include "ns3/simulator.h"
@@ -112,10 +111,17 @@
static FaceFileMapCcnx g_faceFileMapCcnx; /**< A mapping of Ccnx/face pairs to pcap files */
static FaceStreamMapCcnx g_faceStreamMapCcnx; /**< A mapping of Ccnx/face pairs to ascii streams */
+
CcnxStackHelper::CcnxStackHelper ()
+ : m_forwardingHelper (Ccnx::NDN_FLOODING)
{
}
-
+
+CcnxStackHelper::CcnxStackHelper (Ccnx::ForwardingStrategy strategy)
+ : m_forwardingHelper (strategy)
+{
+}
+
CcnxStackHelper::~CcnxStackHelper ()
{
}
@@ -135,10 +141,10 @@
}
void
-CcnxStackHelper::SetForwardingHelper (const CcnxForwardingHelper &forwarding)
+CcnxStackHelper::SetForwardingStrategy (Ccnx::ForwardingStrategy strategy)
{
- // delete m_forwarding;
- // m_forwarding = forwarding.Copy ();
+ CcnxForwardingHelper newForwardingHelper (strategy);
+ m_forwardingHelper = newForwardingHelper;
}
Ptr<CcnxFaceContainer>
@@ -191,11 +197,15 @@
Ptr<CcnxNetDeviceFace> face = Create<CcnxNetDeviceFace> (node->GetDevice (index));
face->SetNode (node);
uint32_t __attribute__ ((unused)) face_id = ccnx->AddFace (face);
- NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcxnNetDeviceFace as face #" << face_id);
+ NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcnxNetDeviceFace as face #" << face_id);
+ face->SetUp ();
faces->Add (face);
}
- // Ptr<CcnxForwardingStrategy> ccnxForwarding = m_forwarding->Create (node);
+
+ m_forwardingHelper.SetForwarding(ccnx);
+
+ // Ptr<CcnxForwardingStrategy> ccnxForwarding = m_forwarding->Create (node);
// ccnx->SetForwardingStrategy (ccnxForwarding);
return faces;
diff --git a/helper/ccnx-stack-helper.h b/helper/ccnx-stack-helper.h
index 1e587e3..78cc121 100644
--- a/helper/ccnx-stack-helper.h
+++ b/helper/ccnx-stack-helper.h
@@ -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:
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Ilya Moiseenko <iliamo@cs.ucla.edu>
*/
#ifndef CCNX_STACK_HELPER_H
@@ -26,11 +27,12 @@
#include "ns3/object-factory.h"
#include "ccnx-trace-helper.h"
+#include "ns3/ccnx-forwarding-helper.h"
+#include "ns3/ccnx.h"
namespace ns3 {
class Node;
-class CcnxForwardingHelper;
class CcnxFaceContainer;
/**
@@ -58,11 +60,14 @@
{
public:
/**
- * \brief Create a new CcnxStackHelper with empty forwarding by default.
- *
- * \todo set non-empty default forwarding
+ * \brief Create a new CcnxStackHelper with a default NDN_FLOODING forwarding stategy
*/
- CcnxStackHelper ();
+ CcnxStackHelper();
+
+ /**
+ * \brief Create a new CcnxStackHelper with a specified forwarding strategy
+ */
+ CcnxStackHelper (Ccnx::ForwardingStrategy);
/**
* \brief Destroy the CcnxStackHelper
@@ -82,7 +87,7 @@
* a single ns3::Ccnx object through its ns3::Ccnx::SetforwardingProtocol.
*/
void
- SetForwardingHelper (const CcnxForwardingHelper &forwarding);
+ SetForwardingStrategy (Ccnx::ForwardingStrategy strategy);
/**
* \brief Install CCNx stack on the node
@@ -148,6 +153,8 @@
AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric);
private:
+ CcnxForwardingHelper m_forwardingHelper;
+
/**
* @brief Enable pcap output the indicated Ccnx and interface pair.
* @internal