From d4572bb4bef9682c2a981e6015566791eec8eea7 Mon Sep 17 00:00:00 2001 From: Navarrop Date: Mon, 5 Sep 2011 15:51:46 +0200 Subject: [PATCH] Support for ns3-3.12 --- buildtools/Cmake/MakeLib.cmake | 7 +++- buildtools/Cmake/Modules/FindNS3.cmake | 50 +++++++++++++++++++++----- src/surf/ns3/ns3_interface.cc | 8 ----- src/surf/ns3/ns3_simulator.h | 26 ++++++++++---- 4 files changed, 68 insertions(+), 23 deletions(-) diff --git a/buildtools/Cmake/MakeLib.cmake b/buildtools/Cmake/MakeLib.cmake index 1c41430e8b..c4d1db1549 100644 --- a/buildtools/Cmake/MakeLib.cmake +++ b/buildtools/Cmake/MakeLib.cmake @@ -118,7 +118,12 @@ if(HAVE_GTNETS) endif(HAVE_GTNETS) if(HAVE_NS3) - SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3") + if(${NS3_VERSION} EQUAL 310) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10") + else(${NS3_VERSION} EQUAL 310) + SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3-core -lns3-csma -lns3-point-to-point") + endif(${NS3_VERSION} EQUAL 310) endif(HAVE_NS3) if(HAVE_POSIX_GETTIME) diff --git a/buildtools/Cmake/Modules/FindNS3.cmake b/buildtools/Cmake/Modules/FindNS3.cmake index 1482f3900b..fea2353a22 100644 --- a/buildtools/Cmake/Modules/FindNS3.cmake +++ b/buildtools/Cmake/Modules/FindNS3.cmake @@ -13,6 +13,21 @@ find_library(HAVE_NS3_LIB ${ns3_path} ) +find_library(HAVE_NS3_CORE_LIB + NAME ns3-core + HINTS + $ENV{LD_LIBRARY_PATH} + $ENV{HOME} + PATH_SUFFIXES lib64 lib ns3/lib + PATHS + /opt + /opt/local + /opt/csw + /sw + /usr + ${ns3_path} +) + find_path(HAVE_CORE_MODULE_H NAME ns3/core-module.h HINTS @@ -43,16 +58,34 @@ message(STATUS "Looking for lib ns3 - not found") endif(HAVE_NS3_LIB) mark_as_advanced(HAVE_NS3_LIB) -if(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H) - set(HAVE_NS3 1) - string(REPLACE "/libns3.${LIB_EXE}" "" HAVE_NS3_LIB "${HAVE_NS3_LIB}") +message(STATUS "Looking for lib ns3-core") +if(HAVE_NS3_CORE_LIB) +message(STATUS "Looking for lib ns3-core - found") +else(HAVE_NS3_CORE_LIB) +message(STATUS "Looking for lib ns3-core - not found") +endif(HAVE_NS3_CORE_LIB) +mark_as_advanced(HAVE_NS3_LIB) + +if(HAVE_CORE_MODULE_H) + if(HAVE_NS3_LIB) + message(STATUS "Warning: NS-3 version <= 3.10") + set(HAVE_NS3 1) + set(NS3_VERSION 310) + string(REPLACE "/libns3.${LIB_EXE}" "" HAVE_NS3_LIB "${HAVE_NS3_LIB}") + endif(HAVE_NS3_LIB) + if(HAVE_NS3_CORE_LIB) + message(STATUS "Warning: NS-3 version > 3.10") + set(HAVE_NS3 1) + set(NS3_VERSION 312) + string(REPLACE "/libns3-core.${LIB_EXE}" "" HAVE_NS3_LIB "${HAVE_NS3_CORE_LIB}") + endif(HAVE_NS3_CORE_LIB) +endif(HAVE_CORE_MODULE_H) + +if(HAVE_NS3) string(REGEX MATCH "${HAVE_NS3_LIB}" operation "$ENV{LD_LIBRARY_PATH}") - if(NOT operation) - message(STATUS "Warning: To use NS-3 don't forget to set LD_LIBRARY_PATH with: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HAVE_NS3_LIB}") set(HAVE_NS3 0) - else(NOT operation) string(REGEX MATCH "-L${HAVE_NS3_LIB} " operation1 "${CMAKE_C_FLAGS}") @@ -67,5 +100,6 @@ if(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-I${HAVE_CORE_MODULE_H} -L${HAVE_NS3_LIB} ") endif(NOT operation) - -endif(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H) \ No newline at end of file +else(HAVE_NS3) + message(STATUS "Warning: To use NS-3 Please install ns3 at least version 3.10 (http://www.nsnam.org/releases/)") +endif(HAVE_NS3) \ No newline at end of file diff --git a/src/surf/ns3/ns3_interface.cc b/src/surf/ns3/ns3_interface.cc index 57f118bc3c..e89afd37fe 100644 --- a/src/surf/ns3/ns3_interface.cc +++ b/src/surf/ns3/ns3_interface.cc @@ -10,14 +10,6 @@ #include "xbt/log.h" #include "xbt/dynar.h" -#include "ns3/core-module.h" -#include "ns3/simulator-module.h" -#include "ns3/node-module.h" -#include "ns3/helper-module.h" -#include "ns3/global-route-manager.h" -#include "ns3/global-route-manager.h" -#include "ns3/ipv4-global-routing-helper.h" - using namespace ns3; extern xbt_lib_t host_lib; diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index f3bbe3eab6..1335f0261b 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -10,12 +10,26 @@ #ifdef __cplusplus #include "ns3/core-module.h" -#include "ns3/helper-module.h" -#include "ns3/simulator-module.h" -#include "ns3/node-module.h" -#include "ns3/helper-module.h" -#include "ns3/global-routing-module.h" -#include "ns3/tcp-socket-factory.h" + +#ifdef _NS3_3_10 + /*NS3 3.10*/ + #include "ns3/helper-module.h" + #include "ns3/simulator-module.h" + #include "ns3/node-module.h" + #include "ns3/helper-module.h" + #include "ns3/global-routing-module.h" + #include "ns3/tcp-socket-factory.h" +#else + /*NS3 3.12*/ + #include "ns3/node.h" + #include "ns3/global-route-manager.h" + #include "ns3/csma-helper.h" + #include "ns3/internet-stack-helper.h" + #include "ns3/ipv4-address-helper.h" + #include "ns3/point-to-point-helper.h" + #include "ns3/packet-sink-helper.h" + #include "ns3/inet-socket-address.h" +#endif using namespace ns3; using namespace std; -- 2.20.1