Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Support for ns3-3.12
authorNavarrop <Pierre.Navarro@imag.fr>
Mon, 5 Sep 2011 13:51:46 +0000 (15:51 +0200)
committerNavarrop <Pierre.Navarro@imag.fr>
Mon, 5 Sep 2011 15:54:00 +0000 (17:54 +0200)
buildtools/Cmake/MakeLib.cmake
buildtools/Cmake/Modules/FindNS3.cmake
src/surf/ns3/ns3_interface.cc
src/surf/ns3/ns3_simulator.h

index 1c41430..c4d1db1 100644 (file)
@@ -118,7 +118,12 @@ if(HAVE_GTNETS)
 endif(HAVE_GTNETS)
 
 if(HAVE_NS3)
 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)
 endif(HAVE_NS3)
 
 if(HAVE_POSIX_GETTIME)
index 1482f39..fea2353 100644 (file)
@@ -13,6 +13,21 @@ find_library(HAVE_NS3_LIB
     ${ns3_path}
 )
 
     ${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
 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)
 
 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}")
        string(REGEX MATCH "${HAVE_NS3_LIB}" operation "$ENV{LD_LIBRARY_PATH}")
-       
        if(NOT operation)
        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)
                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}")
        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)            
        
                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
index 57f118b..e89afd3 100644 (file)
 #include "xbt/log.h"
 #include "xbt/dynar.h"
 
 #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;
 using namespace ns3;
 
 extern xbt_lib_t host_lib;
index f3bbe3e..1335f02 100644 (file)
 #ifdef __cplusplus
 
 #include "ns3/core-module.h"
 #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;
 
 using namespace ns3;
 using namespace std;