Solving compilation problems, adding more comments. Modified ccnx-test example
diff --git a/helper/ccnx-face-container.cc b/helper/ccnx-face-container.cc
index 956614d..ce595bb 100644
--- a/helper/ccnx-face-container.cc
+++ b/helper/ccnx-face-container.cc
@@ -19,8 +19,7 @@
*/
#include "ccnx-face-container.h"
-// #include "ns3/node-list.h"
-// #include "ns3/names.h"
+
#include <algorithm>
#include "ns3/ccnx-face.h"
@@ -47,6 +46,12 @@
void
+CcnxFaceContainer::AddAll (Ptr<CcnxFaceContainer> other)
+{
+ AddAll (*other);
+}
+
+void
CcnxFaceContainer::AddAll (const CcnxFaceContainer &other)
{
m_faces.insert (m_faces.end (),
diff --git a/helper/ccnx-face-container.h b/helper/ccnx-face-container.h
index 4426449..ecb29d9 100644
--- a/helper/ccnx-face-container.h
+++ b/helper/ccnx-face-container.h
@@ -23,20 +23,24 @@
#include <stdint.h>
#include <vector>
-#include "ns3/ccnx.h"
+
+#include "ns3/ptr.h"
+#include "ns3/simple-ref-count.h"
namespace ns3 {
+class CcnxFace;
+
/**
- * \ingroup ccnx
+ * \ingroup ccnx-helpers
* \brief A pool for CCNx faces
*
* Provides tools to perform basic manipulation on faces, such as
* setting metrics and states on faces
*
- * \see Ccnx
+ * \see CcnxStackHelper
*/
-class CcnxFaceContainer
+class CcnxFaceContainer : public SimpleRefCount<CcnxFaceContainer>
{
private:
typedef std::vector<Ptr<CcnxFace> > FaceContainer;
@@ -67,6 +71,13 @@
/**
* \brief Add all entries from other container
*
+ * \param other smart pointer to a container
+ */
+ void AddAll (Ptr<CcnxFaceContainer> other);
+
+ /**
+ * \brief Add all entries from other container
+ *
* \param other container
*/
void AddAll (const CcnxFaceContainer &other);
diff --git a/helper/ccnx-forwarding-helper.h b/helper/ccnx-forwarding-helper.h
index a7d0bf8..8ac041e 100644
--- a/helper/ccnx-forwarding-helper.h
+++ b/helper/ccnx-forwarding-helper.h
@@ -30,13 +30,11 @@
class Node;
/**
+ * \ingroup ccnx-helpers
+ *
* \brief a factory to create ns3::CcnxForwardingStrategy objects
*
- * For each new forwarding protocol created as a subclass of
- * ns3::CcnxForwardingStrategy, you need to create a subclass of
- * ns3::CcnxForwardingHelper which can be used by
- * ns3::InternetStackHelper::SetForwardingHelper and
- * ns3::InternetStackHelper::Install.
+ * \todo Document this class
*/
class CcnxForwardingHelper
{
@@ -53,7 +51,7 @@
* This method is mainly for internal use by the other helpers;
* clients are expected to free the dynamic memory allocated by this method
*/
- virtual CcnxForwardingHelper* Copy (void) const = 0;
+ virtual CcnxForwardingHelper* Copy () const = 0;
/**
* \param node the node within which the new forwarding protocol will run
diff --git a/helper/ccnx-header-helper.h b/helper/ccnx-header-helper.h
index 35aeab8..72d030c 100644
--- a/helper/ccnx-header-helper.h
+++ b/helper/ccnx-header-helper.h
@@ -30,7 +30,9 @@
class Packet;
/**
- * Class implementing functionality to detect CCNx packet type and
+ * \ingroup ccnx-helpers
+ *
+ * \brief Class implementing functionality to detect CCNx packet type and
* create the corresponding object
*
* CCNx doesn't really have a header, so we need this class to
@@ -68,6 +70,15 @@
CreateCorrectCcnxHeader (Ptr<const Packet> packet);
};
+ /**
+ * \ingroup ccnx
+ * \defgroup ccnx-exceptions Exceptions
+ */
+ /**
+ * \ingroup ccnx-exceptions
+ * \brief Exception thrown if CCNx stack receives unrecognized
+ * message type
+ */
class CcnxUnknownHeaderException {};
} // namespace ns3
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index 50839a3..d59827e 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011 UCLA
*
@@ -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:
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
/**
@@ -67,7 +67,10 @@
#include "ns3/node.h"
#include "ns3/core-config.h"
#include "ns3/ccnx-forwarding-strategy.h"
+#include "ns3/ccnx-net-device-face.h"
+#include "ns3/ccnx-l3-protocol.h"
+#include "ccnx-face-container.h"
#include "ccnx-stack-helper.h"
#include "ccnx-forwarding-helper.h"
@@ -175,19 +178,21 @@
m_ccnxEnabled = enable;
}
-void
+Ptr<CcnxFaceContainer>
CcnxStackHelper::Install (NodeContainer c) const
{
+ Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> ();
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
- Install (*i);
+ faces->AddAll (Install (*i));
}
+ return faces;
}
-void
+Ptr<CcnxFaceContainer>
CcnxStackHelper::InstallAll (void) const
{
- Install (NodeContainer::GetGlobal ());
+ return Install (NodeContainer::GetGlobal ());
}
void
@@ -199,10 +204,11 @@
node->AggregateObject (protocol);
}
-void
+Ptr<CcnxFaceContainer>
CcnxStackHelper::Install (Ptr<Node> node) const
{
- NS_ASSERT_MSG (m_forwarding, "CcnxForwarding should be set prior calling Install() method");
+ // NS_ASSERT_MSG (m_forwarding, "SetForwardingHelper() should be set prior calling Install() method");
+ Ptr<CcnxFaceContainer> faces = Create<CcnxFaceContainer> ();
if (m_ccnxEnabled)
{
@@ -210,22 +216,32 @@
{
NS_FATAL_ERROR ("CcnxStackHelper::Install (): Installing "
"a CcnxStack to a node with an existing Ccnx object");
- return;
+ return 0;
}
CreateAndAggregateObjectFromTypeId (node, "ns3::CcnxL3Protocol");
// Set forwarding
Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
- Ptr<CcnxForwardingStrategy> ccnxForwarding = m_forwarding->Create (node);
- ccnx->SetForwardingStrategy (ccnxForwarding);
+ for (uint32_t index=0; index < node->GetNDevices (); index++)
+ {
+ Ptr<CcnxNetDeviceFace> face = Create<CcnxNetDeviceFace> (node->GetDevice (index));
+ uint32_t __attribute__ ((unused)) face_id = ccnx->AddFace (face);
+ NS_LOG_LOGIC ("Node " << node->GetId () << ": added CcxnNetDeviceFace as face #" << face_id);
+
+ faces->Add (face);
+ }
+ // Ptr<CcnxForwardingStrategy> ccnxForwarding = m_forwarding->Create (node);
+ // ccnx->SetForwardingStrategy (ccnxForwarding);
}
+
+ return faces;
}
-void
+Ptr<CcnxFaceContainer>
CcnxStackHelper::Install (std::string nodeName) const
{
Ptr<Node> node = Names::Find<Node> (nodeName);
- Install (node);
+ return Install (node);
}
static void
diff --git a/helper/ccnx-stack-helper.h b/helper/ccnx-stack-helper.h
index 3d0b3a4..7308241 100644
--- a/helper/ccnx-stack-helper.h
+++ b/helper/ccnx-stack-helper.h
@@ -21,12 +21,9 @@
#ifndef CCNX_STACK_HELPER_H
#define CCNX_STACK_HELPER_H
-#include "ns3/node-container.h"
-#include "ns3/net-device-container.h"
#include "ns3/packet.h"
#include "ns3/ptr.h"
#include "ns3/object-factory.h"
-#include "ns3/ccnx-l3-protocol.h"
#include "ccnx-trace-helper.h"
@@ -34,8 +31,14 @@
class Node;
class CcnxForwardingHelper;
+class CcnxFaceContainer;
/**
+ * \ingroup ccnx
+ * \defgroup ccnx-helpers Helpers
+ */
+/**
+ * \ingroup ccnx-helpers
* \brief Adding CCNx functionality to existing Nodes.
*
* This helper enables pcap and ascii tracing of events in the ccnx stack
@@ -55,25 +58,27 @@
{
public:
/**
- * Create a new CcnxStackHelper which <empty> forwarding by default.
+ * \brief Create a new CcnxStackHelper which <empty> forwarding by default.
*
* \todo set non-empty default forwarding
*/
CcnxStackHelper ();
/**
- * Destroy the CcnxStackHelper
+ * \brief Destroy the CcnxStackHelper
*/
virtual ~CcnxStackHelper ();
CcnxStackHelper (const CcnxStackHelper &);
CcnxStackHelper &operator = (const CcnxStackHelper &o);
/**
- * Return helper internal state to that of a newly constructed one
+ * \brief Return helper internal state to that of a newly constructed one
*/
void Reset ();
/**
+ * Set forwarding strategy helper
+ *
* \param forwarding a new forwarding helper
*
* Set the forwarding helper to use during Install. The forwarding helper is
@@ -81,50 +86,68 @@
* ns3::CcnxFrProtocol per node. This forwarding object is then associated to
* a single ns3::Ccnx object through its ns3::Ccnx::SetforwardingProtocol.
*/
- void SetForwardingHelper (const CcnxForwardingHelper &forwarding);
+ void
+ SetForwardingHelper (const CcnxForwardingHelper &forwarding);
/**
- * Install CCNx stack on the node
+ * \brief Install CCNx stack on the node
*
* This method will assert if called on a node that already has Ccnx object
* installed on it
*
* \param nodeName The name of the node on which to install the stack.
+ *
+ * \returns list of installed faces in the form of a smart pointer
+ * to CcnxFaceContainer object
*/
- void Install (std::string nodeName) const;
+ Ptr<CcnxFaceContainer>
+ Install (std::string nodeName) const;
/**
- * Install CCNx stack on the node
+ * \brief Install CCNx stack on the node
*
* This method will assert if called on a node that already has Ccnx object
* installed on it
*
* \param node The node on which to install the stack.
+ *
+ * \returns list of installed faces in the form of a smart pointer
+ * to CcnxFaceContainer object
*/
- void Install (Ptr<Node> node) const;
+ Ptr<CcnxFaceContainer>
+ Install (Ptr<Node> node) const;
/**
- * Install CCNx stack on each node in the input container
+ * \brief Install CCNx stack on each node in the input container
*
* The program will assert if this method is called on a container with a node
* that already has an ccnx object aggregated to it.
*
* \param c NodeContainer that holds the set of nodes on which to install the
* new stacks.
+ *
+ * \returns list of installed faces in the form of a smart pointer
+ * to CcnxFaceContainer object
*/
- void Install (NodeContainer c) const;
+ Ptr<CcnxFaceContainer>
+ Install (NodeContainer c) const;
/**
- * Install CCNx stack on all nodes in the simulation
+ * \brief Install CCNx stack on all nodes in the simulation
+ *
+ * \returns list of installed faces in the form of a smart pointer
+ * to CcnxFaceContainer object
*/
- void
+ Ptr<CcnxFaceContainer>
InstallAll () const;
/**
* \brief Enable/disable ccnx stack install.
+ *
* \param enable enable state
*/
- void SetCcnxStackInstall (bool enable);
+ void
+ SetCcnxStackInstall (bool enable);
private:
/**
diff --git a/helper/ccnx-trace-helper.h b/helper/ccnx-trace-helper.h
index a0390e7..49ad8e0 100644
--- a/helper/ccnx-trace-helper.h
+++ b/helper/ccnx-trace-helper.h
@@ -14,6 +14,8 @@
* 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
+ *
+ * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef CCNX_TRACE_HELPER_H
@@ -27,6 +29,8 @@
namespace ns3 {
/**
+ * \ingroup ccnx-helpers
+ *
* @brief Base class providing common user-level pcap operations for helpers
* representing Ccnx protocols .
*/
@@ -119,6 +123,8 @@
};
/**
+ * \ingroup ccnx-helpers
+ *
* @brief Base class providing common user-level ascii trace operations for
* helpers representing Ccnx protocols .
*/