--- /dev/null
+/* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SIMGRID_PLUGINS_LOAD_H_
+#define SIMGRID_PLUGINS_LOAD_H_
+
+#include <ns3/node.h>
+#include <ns3/ptr.h>
+#include <simgrid/config.h>
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+
+namespace simgrid {
+/** Returns the ns3 node from a simgrid host */
+XBT_PUBLIC ns3::Ptr<ns3::Node> get_ns3node_from_sghost(simgrid::s4u::Host* host);
+}; // namespace simgrid
+
+#endif
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "simgrid/plugins/ns3.hpp"
+
#include <string>
#include <unordered_set>
static uint16_t port_number = 1;
- ns3::Ptr<ns3::Node> src_node = src->get_netpoint()->extension<NetPointNs3>()->ns3_node_;
- ns3::Ptr<ns3::Node> dst_node = dst->get_netpoint()->extension<NetPointNs3>()->ns3_node_;
+ ns3::Ptr<ns3::Node> src_node = get_ns3node_from_sghost(src);
+ ns3::Ptr<ns3::Node> dst_node = get_ns3node_from_sghost(dst);
std::string& addr = dst->get_netpoint()->extension<NetPointNs3>()->ipv4_address_;
xbt_assert(not addr.empty(), "Element %s is unknown to ns-3. Is it connected to any one-hop link?",
} // namespace resource
} // namespace kernel
+
+ns3::Ptr<ns3::Node> get_ns3node_from_sghost(simgrid::s4u::Host* host)
+{
+ xbt_assert(host->get_netpoint()->extension<NetPointNs3>() != nullptr, "Please only use this function on ns-3 nodes");
+ return host->get_netpoint()->extension<NetPointNs3>()->ns3_node_;
+}
} // namespace simgrid
void ns3_simulator(double maxSeconds)
endif()
if(SIMGRID_HAVE_NS3)
+ set(headers_to_install ${headers_to_install} include/simgrid/plugins/ns3.hpp)
+
set(simgrid_sources ${simgrid_sources} ${NS3_SRC})
+else()
+ set(EXTRA_DIST ${EXTRA_DIST} include/simgrid/plugins/ns3.hpp)
endif()
if(SIMGRID_HAVE_LUA)