Enable basic support for MPI in CcnxAppHelper
If MPI is enabled, an App will be installed only on the node with the
same SystemId
diff --git a/helper/ccnx-app-helper.cc b/helper/ccnx-app-helper.cc
index d52a005..0e77075 100644
--- a/helper/ccnx-app-helper.cc
+++ b/helper/ccnx-app-helper.cc
@@ -24,6 +24,10 @@
#include "ns3/names.h"
#include "ns3/ccnx-app.h"
+#ifdef NS3_MPI
+#include "ns3/mpi-interface.h"
+#endif
+
NS_LOG_COMPONENT_DEFINE ("CcnxAppHelper");
namespace ns3
@@ -49,14 +53,19 @@
ApplicationContainer
CcnxAppHelper::Install (Ptr<Node> node)
{
- return ApplicationContainer (InstallPriv (node));
+ ApplicationContainer apps;
+ Ptr<Application> app = InstallPriv (node);
+ if (app != 0)
+ apps.Add (app);
+
+ return apps;
}
ApplicationContainer
CcnxAppHelper::Install (std::string nodeName)
{
Ptr<Node> node = Names::Find<Node> (nodeName);
- return ApplicationContainer (InstallPriv (node));
+ return Install (node);
}
ApplicationContainer
@@ -65,7 +74,9 @@
ApplicationContainer apps;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
- apps.Add (InstallPriv (*i));
+ Ptr<Application> app = InstallPriv (*i);
+ if (app != 0)
+ apps.Add (app);
}
return apps;
@@ -74,6 +85,15 @@
Ptr<Application>
CcnxAppHelper::InstallPriv (Ptr<Node> node)
{
+#ifdef NS3_MPI
+ if (MpiInterface::IsEnabled () &&
+ node->GetSystemId () != MpiInterface::GetSystemId ())
+ {
+ // don't create an app if MPI is enabled and node is not in the correct partition
+ return 0;
+ }
+#endif
+
Ptr<CcnxApp> app = m_factory.Create<CcnxApp> ();
node->AddApplication (app);