From fb58ceee59de7a8bbcbdc38aede8fbf678f7fcc1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 18 Jul 2015 23:35:18 +0200 Subject: [PATCH] Overhaul of NS3 support in SimGrid - NS3 is now found if installed from the default package (eg, Debian) - If enable_ns3 and not found, cmake will fail - 3 log channels were a bit too much - Don't use NS3 log channels as it fails when running in Java somehow - Drop support for ancient version of NS3 (3.10) - Documentation refresh/rewrite - Revalidate the tesh files (rounding errors on timings) --- .cproject | 3 + .gitignore | 1 + buildtools/Cmake/CompleteInFiles.cmake | 7 +- buildtools/Cmake/MakeLib.cmake | 8 +- buildtools/Cmake/Modules/FindNS3.cmake | 34 ++--- buildtools/Cmake/Option.cmake | 2 +- buildtools/Cmake/PrintArgs.cmake | 15 +- doc/doxygen/pls.doc | 171 +++++++---------------- examples/msg/ns3/ns3.tesh | 20 +-- src/surf/network_ns3.cpp | 3 +- src/surf/ns3/my-point-to-point-helper.cc | 10 +- src/surf/ns3/ns3_interface.cc | 2 +- src/surf/ns3/ns3_simulator.cc | 3 +- src/surf/ns3/ns3_simulator.h | 29 ++-- src/surf/ns3/red-queue.cc | 143 ++++++++----------- src/xbt/log.c | 4 +- 16 files changed, 171 insertions(+), 284 deletions(-) diff --git a/.cproject b/.cproject index ceb09eb724..6739911b35 100644 --- a/.cproject +++ b/.cproject @@ -23,12 +23,14 @@ @@ -42,6 +44,7 @@ diff --git a/.gitignore b/.gitignore index 367a41b3dc..91a4a13cad 100644 --- a/.gitignore +++ b/.gitignore @@ -180,6 +180,7 @@ examples/msg/icomms/toto.txt examples/msg/masterslave/masterslave_console examples/msg/irc_isend/peer examples/msg/irc_isend/toto.txt +examples/msg/ns3/ns3 examples/simdag/sd_avail examples/simdag/ex_sd_seq_access examples/simdag/sd_seq_access diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index df8b11bfd7..3ff5472c41 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -102,6 +102,9 @@ endif() set(HAVE_NS3 0) if(enable_ns3) include(FindNS3) + if (NOT HAVE_NS3) + message(FATAL_ERROR "Cannot find NS3. Please install it (apt-get install ns3 libns3-dev) or disable that cmake option") + endif() endif() # algorithm 1.50.0 @@ -114,9 +117,9 @@ if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) else() if(APPLE) #MAC - message(FATAL_ERROR, "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')") + message(FATAL_ERROR "Failed to find Boost libraries (Try to install them with 'sudo fink install boost1.53.nopython')") else() - message(FATAL_ERROR, "Failed to find Boost libraries") + message(FATAL_ERROR "Failed to find Boost libraries") endif() endif() diff --git a/buildtools/Cmake/MakeLib.cmake b/buildtools/Cmake/MakeLib.cmake index f8d2a4f095..e9777ee78f 100644 --- a/buildtools/Cmake/MakeLib.cmake +++ b/buildtools/Cmake/MakeLib.cmake @@ -129,13 +129,7 @@ if(MMALLOC_WANT_OVERRIDE_LEGACY AND HAVE_GNU_LD) endif() if(HAVE_NS3) - if(${NS3_VERSION_MINOR} EQUAL 10) - SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_NS3_3_10") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_NS3_3_10") - else() - SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3.${NS3_VERSION_MINOR}-core -lns3.${NS3_VERSION_MINOR}-csma -lns3.${NS3_VERSION_MINOR}-point-to-point -lns3.${NS3_VERSION_MINOR}-internet -lns3.${NS3_VERSION_MINOR}-applications") - endif() + SET(SIMGRID_DEP "${SIMGRID_DEP} -lns3.${NS3_VERSION_MINOR}-core -lns3.${NS3_VERSION_MINOR}-csma -lns3.${NS3_VERSION_MINOR}-point-to-point -lns3.${NS3_VERSION_MINOR}-internet -lns3.${NS3_VERSION_MINOR}-applications") endif() if(HAVE_POSIX_GETTIME) diff --git a/buildtools/Cmake/Modules/FindNS3.cmake b/buildtools/Cmake/Modules/FindNS3.cmake index eb64091aa0..7e8d7eae86 100644 --- a/buildtools/Cmake/Modules/FindNS3.cmake +++ b/buildtools/Cmake/Modules/FindNS3.cmake @@ -1,19 +1,10 @@ -# If you use NS-3 version 3.14 (prefer used at most 3.13) be sure having do -# ln -sf libns3.14.1-applications-debug.so libns3-applications.so -# ln -sf libns3.14.1-internet-debug.so libns3-internet.so -# ln -sf libns3.14.1-point-to-point-debug.so libns3-point-to-point.so -# ln -sf libns3.14.1-csma-debug.so libns3-csma.so -# ln -sf libns3.14.1-core-debug.so libns3-core.so -find_library(HAVE_NS3_LIB - NAME ns3 - PATH_SUFFIXES lib64 lib ns3/lib - PATHS - ${ns3_path} - ) +## ADDING A NS3 VERSION. +# - Add ns3.${version}-core to the NAME line of the find_library below +# - Add include/ns3{version} to the PATH_SUFFIXES line of the find_path below find_library(HAVE_NS3_CORE_LIB - NAME ns3-core ns3.14-core ns3.17-core + NAME ns3-core ns3.14-core ns3.15-core ns3.16-core ns3.17-core ns3.18-core ns3.19-core ns3.20-core ns3.21-core ns3.22-core PATH_SUFFIXES lib64 lib ns3/lib PATHS ${ns3_path} @@ -21,27 +12,20 @@ find_library(HAVE_NS3_CORE_LIB find_path(HAVE_CORE_MODULE_H NAME ns3/core-module.h - PATH_SUFFIXES include ns3/include include/ns3.14.1 include/ns3.17 + PATH_SUFFIXES include ns3/include include/ns3.14 include/ns3.15 include/ns3.16 include/ns3.17 include/ns3.18 include/ns3.19 include/ns3.20 include/ns3.21 include/ns3.22 PATHS ${ns3_path} ) -message(STATUS "Looking for core-module.h") + + if(HAVE_CORE_MODULE_H) - message(STATUS "Looking for core-module.h - found") + message(STATUS "Looking for ns3/core-module.h - found") else() - message(STATUS "Looking for core-module.h - not found") + message(STATUS "Looking for ns3/core-module.h - not found") endif() mark_as_advanced(HAVE_CORE_MODULE_H) -message(STATUS "Looking for lib ns3") -if(HAVE_NS3_LIB) - message(STATUS "Looking for lib ns3 - found") -else() - message(STATUS "Looking for lib ns3 - not found") -endif() -mark_as_advanced(HAVE_NS3_LIB) - message(STATUS "Looking for lib ns3-core") if(HAVE_NS3_CORE_LIB) message(STATUS "Looking for lib ns3-core - found") diff --git a/buildtools/Cmake/Option.cmake b/buildtools/Cmake/Option.cmake index 9c01b51395..89e69696ad 100644 --- a/buildtools/Cmake/Option.cmake +++ b/buildtools/Cmake/Option.cmake @@ -1,4 +1,4 @@ -### ARGs use -D[var]=[ON/OFF] or [1/0] or [true/false](see after) +### ARGs use -D[var]=[ON/OFF] or [1/0] or [true/false](see below) ### ex: cmake -Denable_java=ON -Denable_gtnets=ON ./ set(BIBTEX2HTML ${BIBTEX2HTML} CACHE PATH "Path to bibtex2html") diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index 928da8fa14..84485c985e 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -102,11 +102,16 @@ message(" CFlags ......................: ${CMAKE_C_FLAGS}") message(" CXXFlags ....................: ${CMAKE_CXX_FLAGS}") message(" LDFlags .....................: ${CMAKE_C_LINK_FLAGS}") message("") -if(NOT APPLE AND NOT WIN32) - message(" Compile Gtnets ..............: ${HAVE_GTNETS}") - message(" Compile NS-3 ................: ${HAVE_NS3}") - message(" Gtnets path .................: ${gtnets_path}") - message(" NS-3 path ...................: ${ns3_path}") + +if (HAVE_GTNETS) + message(" Compile Gtnets ..............: yes (path: ${gtnets_path})") +else() + message(" Compile Gtnets ..............: NO (path: ${gtnets_path})") +endif() +if (HAVE_NS3) + message(" Compile NS-3 ................: yes (path: ${ns3_path})") +else() + message(" Compile NS-3 ................: NO (path: ${ns3_path})") endif() message(" Compile Java ................: ${HAVE_Java}") diff --git a/doc/doxygen/pls.doc b/doc/doxygen/pls.doc index e236b5ff57..5dd9f0aef1 100644 --- a/doc/doxygen/pls.doc +++ b/doc/doxygen/pls.doc @@ -116,157 +116,94 @@ gtnets/gtnets gtnets/onelink-p.xml gtnets/onelink-d.xml --cfg=network_model:GTNe \section pls_simgrid_configuration_ns3 Using NS3 -It is possible to use discrete-event network simulator (ns-3) for Internet systems -instead of the default one. +You may want to replace the SimGrid network models by the ones of the +well known packet-level network simulator NS-3 instead. +This section explains how to do so. -A ns-3 platform is created according to the platform file you provide in SimGrid format. However from this configuration, we had to set up some extra parameters : +\subsection pls_simgrid_configuration_ns3_install Installing NS3 - - -To use ns3 model inside SimGrid you have to install at least the version 3.10 of ns3 simulator. - - -- Download and enter the lateast release (here the 3.12.1) +The easiest is to install it with the package manager. Under +Debian/Ubuntu, simply type as root: \verbatim -http://www.nsnam.org/release/ns-allinone-3.12.1.tar.bz2 -tar -xf ns-allinone-3.12.1.tar.bz2 -cd ns-allinone-3.12.1/ns-3.12.1/ +apt-get install libns3-dev ns3 \endverbatim -- Configure, make and install ns3 +You can also install it from scratch with the following commands: \verbatim +# Download the source +wget http://www.nsnam.org/release/ns-allinone-3.22.tar.bz2 +tar -xf ns-allinone-3.22.tar.bz2 +cd ns-allinone-3.22/ns-3.22/ +# Configure, build and install ./waf configure --prefix="ns-3_install_directory" ./waf ./waf install \endverbatim -After install ns-3 you should have directories into your "ns-3_install_directory": - \li include/ns3/ - \li lib/ - \li bin/ (with 3.12) +For more information, please refer to the NS-3 documentation. -In some cases, include/ns3 does not exist, but there is an /include/ns3.XX . Then, a simple symbolic link is enough. From the /path/to/ns3/installation/include directory, run: -\verbatim -ln -s -T ns3.XX/ns3 ns3 -\endverbatim - -Make sure to replace 3.XX with your version of NS3, e.g., 3.17, or 3.18. -Check the correct presence of the symbolic link using -\verbatim -ls -al -\endverbatim - -and you should see an ns3 link pointing to ns3.XX. E.g., ns3 -> ns3.17/ns3 -You also need to add to the LD_LIBRARY_PATH : "ns-3_install_directory/lib". +\subsection pls_simgrid_configuration_ns3_config Enabling SimGrid's support for NS3 -- Enable ns-3 support on SimGrid - -Enabling ns-3 integration with Simgrid requires several intermediate steps. --# Modify "simgrid_path/buildtools/CMake/MakeLib.cmake".\n -The "-lns3.${NS3_VERSION_MINOR}-[module]" should match the library names in your "ns-3_install_directory/lib". The "module" can be one of the following: core, csma, point-to-oint, internet, applications, bridge, mpi, config-store, stats, network. For this, in the "MakeLib.cmake" file find the "else" branch of "if(HAVE_NS3)" statement. Replace the se of "-lns3.${NS3_VERSION_MINOR}-[module]" with "-lns3[version]-[module]-debug" in "SET(SIMGRID_DEP)". On the same branch, add "-I/path/to/ns-3_install_directory/include" to MAKE_C_FLAGS and "CMAKE_CXX_FLAGS". --# There might be a need for creating symbolic links of each ns3 library from "ns-3_install_directory/lib" to "/usr/lib". --# In order to enable ns-3 with simgrid you have to give where is ns-3 to the simgrid configuration command. (path to \/lib and \/include) +Normally, you just have to enable NS3 in ccmake or cmake as follows. +If you installed NS3 in a regular path, just drop the ns3_path +configuration item. \verbatim cmake . -Denable_ns3=ON -Dns3_path= \endverbatim -With the output of the configuration you can see if ns-3 is detected (see CFlags: ; CPPFlags: ; Compile NS-3: , NS-3 path:). +By the end of the configuration, cmake reports whether NS-3 was found. +You can also double-check by executing the tests after the compilation. \verbatim -Configuration of package `simgrid' on arch (=4): - BUILDNAME : UNIX - SITE : Linux_2.6.38-11-generic_x86_64 - Release : simgrid-3.6.1 - - Compiler: c++ : /usr/bin/c++ - version: 4.6.1 - Compiler: c : /usr/bin/gcc - version: 4.6.1 - - CFlags : -O3 -finline-functions -funroll-loops -fno-strict-aliasing -L/usr/lib/x86_64-linux-gnu -I/usr/include - -L/home/navarrop/Install/ns3-3.10/lib -I/home/navarrop/Install/ns3-3.10/include -g3 -D_NS3_3_10 - CPPFlags: -I/home/navarrop/Install/ns3-3.10/include -L/home/navarrop/Install/ns3-3.10/lib - - Compile Gtnets : 0 - Compile NS-3 : 1 ---------------------> Be sure this option is "1" otherwise ns-3 is not activated - Gtnets path : - NS-3 path : /home/navarrop/Install/ns3-3.10 - Compile Lua : - Compile Smpi : OFF - Compile Static : OFF - - Maintainer mode: OFF - Supernovae mode: OFF - Model checking : OFF - Tracing mode : OFF - Jedule mode : OFF - Latency bound : OFF - Graphviz mode : - - Simgrid dependencies: -lm -lpthread -lns3 -lrt - Smpi dependencies : - - INSTALL_PREFIX: /usr/local --- Configuring done --- Generating done --- Build files have been written to: /home/navarrop/workspace/simgrid/build +$ ctest -R ns3 +(several tests should be run) \endverbatim -Now you can compile SimGrid -\verbatim -make -\endverbatim +If you have a NS3 version that is not known (yet) to SimGrid, the +detection may fail. In that case, edit the file +buildtools/Cmake/Modules/FindNS3.cmake in your SimGrid tree. The +required changes are very easy, and documented at the beginning of +this file. -Then you can see if ns-3 is well activated by testing -\verbatim -ctest -R ns3 -\endverbatim +If the compilation fails when linking the library because of some .a +file that cannot be used dynamically, that's probably because you only +installed the libns3-dev library on your Debian, where you also need +libns3-3. That's probably a bug of the libns3-dev package that should +depend on the dynamic libraries corresponding to its .so files. -You should see -\verbatim - Start 182: msg-ns3-thread -1/3 Test #182: msg-ns3-thread ................... Passed 0.35 sec - Start 183: msg-ns3-ucontext -2/3 Test #183: msg-ns3-ucontext ................. Passed 0.22 sec - Start 184: msg-ns3-raw -3/3 Test #184: msg-ns3-raw ...................... Passed 0.23 sec -\endverbatim +\subsection pls_simgrid_configuration_ns3_use Using NS3 from SimGrid -- Use case +A working example of NS3/SimGrid interactions can be found in +examples/msg/ns3. Basically, you just have to run your SimGrid +simulation with the configuration option "network/model" set to the +value "NS3". The rest remains unchanged. -An example of using Simgrid with NS3 can be found in: +The following should work from the examples/msg/ns3 folder (ns3 here +is the name of our example binary). \verbatim -path/to/simgrid/examples/src/surf/ns3/ +./ns3 ./3hosts_2links_p.xml 3hosts_2links_d.xml --cfg=network/model:NS3 --log=root.threshold:info \endverbatim -From the example folder above, the command line sintax is +A ns-3 platform is automatically created from the SimGrid platform +file that you will provide. There is some caveats to know: -\verbatim - --cfg=network/model:NS3 --log=surf.threshold:info -\endverbatim +
    +
  • The default values (e.g., TCP parameters) are the ns3 + values. Don't blame us for them.
  • + +
  • NS3 networks are routed using the shortest path algorithm, using + ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables.
  • + +
  • End hosts cannot have more than one interface card (so, only one + <link> in your SimGrid platform should link an end host to + the platform ; if not, your end host will be considered as a + router.
  • +
-This example should work: -\verbatim -./ns3 ./3hosts_2links_p.xml 3hosts_2links_d.xml --cfg=network/model:NS3 --log=root.threshold:info -\endverbatim More about ns-3 simulator (Official website) diff --git a/examples/msg/ns3/ns3.tesh b/examples/msg/ns3/ns3.tesh index 5eab1f4bad..96a8de196c 100644 --- a/examples/msg/ns3/ns3.tesh +++ b/examples/msg/ns3/ns3.tesh @@ -4,31 +4,31 @@ p 3hosts 2links $ ns3/ns3 ${srcdir:=.}/examples/platforms/small_platform_one_link_routes.xml ${srcdir:=.}/examples/msg/ns3/3hosts_2links_d.xml --cfg=network/model:NS3 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' -> [Jupiter:slave:(2) 0.000249] [msg_test/INFO] FLOW[1] : Receive 100 bytes from Tremblay to Jupiter +> [Jupiter:slave:(2) 0.000250] [msg_test/INFO] FLOW[1] : Receive 100 bytes from Tremblay to Jupiter p 6hosts 3links $ ns3/ns3 ${srcdir:=.}/examples/platforms/small_platform_one_link_routes.xml ${srcdir:=.}/examples/msg/ns3/3links-d.xml --cfg=network/model:NS3 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' -> [Jupiter:slave:(2) 0.003027] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from Tremblay to Jupiter -> [Ginette:slave:(4) 0.161074] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from Fafard to Ginette -> [Lovelace:slave:(6) 1.256527] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from Bourassa to Lovelace +> [Jupiter:slave:(2) 0.003057] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from Tremblay to Jupiter +> [Ginette:slave:(4) 0.162674] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from Fafard to Ginette +> [Lovelace:slave:(6) 1.269505] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from Bourassa to Lovelace $ ns3/ns3 ${srcdir:=.}/examples/platforms/small_platform_one_link_routes.xml ${srcdir:=.}/examples/msg/ns3/3links-d-timer.xml --cfg=network/model:NS3 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' -> [Jupiter:slave:(2) 0.003027] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from Tremblay to Jupiter -> [Ginette:slave:(4) 0.161074] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from Fafard to Ginette -> [Lovelace:slave:(6) 1.256527] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from Bourassa to Lovelace -> [Lovelace:slave:(7) 3.256527] [msg_test/INFO] FLOW[4] : Receive 2000000 bytes from Bourassa to Lovelace +> [Jupiter:slave:(2) 0.003057] [msg_test/INFO] FLOW[1] : Receive 100000 bytes from Tremblay to Jupiter +> [Ginette:slave:(4) 0.162674] [msg_test/INFO] FLOW[2] : Receive 1000000 bytes from Fafard to Ginette +> [Lovelace:slave:(6) 1.269505] [msg_test/INFO] FLOW[3] : Receive 2000000 bytes from Bourassa to Lovelace +> [Lovelace:slave:(7) 3.269505] [msg_test/INFO] FLOW[4] : Receive 2000000 bytes from Bourassa to Lovelace p One cluster $ ns3/ns3 ${srcdir:=.}/examples/platforms/cluster.xml ${srcdir:=.}/examples/msg/ns3/One_cluster-d.xml --cfg=network/model:NS3 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' -> [node-6.acme.org:slave:(2) 0.006755] [msg_test/INFO] FLOW[1] : Receive 100 bytes from node-2.acme.org to node-6.acme.org +> [node-6.acme.org:slave:(2) 0.007311] [msg_test/INFO] FLOW[1] : Receive 100 bytes from node-2.acme.org to node-6.acme.org p Two clusters $ ns3/ns3 ${srcdir:=.}/examples/platforms/clusters_routing_full.xml ${srcdir:=.}/examples/msg/ns3/Two_clusters-d.xml --cfg=network/model:NS3 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' -> [c-16.me:slave:(2) 0.012729] [msg_test/INFO] FLOW[1] : Receive 100 bytes from c-3.me to c-16.me +> [c-16.me:slave:(2) 0.026463] [msg_test/INFO] FLOW[1] : Receive 100 bytes from c-3.me to c-16.me diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 0c5969f599..7a82d42ad3 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -8,8 +8,7 @@ #include "surf_private.h" #include "simgrid/sg_config.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_ns3, surf, - "Logging specific to the SURF network NS3 module"); +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); extern xbt_lib_t host_lib; extern xbt_lib_t link_lib; diff --git a/src/surf/ns3/my-point-to-point-helper.cc b/src/surf/ns3/my-point-to-point-helper.cc index b5a80b8929..7ac53db2b9 100644 --- a/src/surf/ns3/my-point-to-point-helper.cc +++ b/src/surf/ns3/my-point-to-point-helper.cc @@ -24,7 +24,6 @@ */ #include -#include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/point-to-point-net-device.h" #include "ns3/point-to-point-channel.h" @@ -40,7 +39,9 @@ #include "ns3/trace-helper.h" #include "my-point-to-point-helper.h" -NS_LOG_COMPONENT_DEFINE ("MyPointToPointHelper"); +#include "xbt/log.h" + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); ///> RED Parameters see src/node/red-queue.* for details //.AddAttribute ("Mode", @@ -163,7 +164,7 @@ MyPointToPointHelper::EnablePcapInternal (std::string prefix, Ptr nd, Ptr device = nd->GetObject (); if (device == 0) { - NS_LOG_INFO ("MyPointToPointHelper::EnablePcapInternal(): Device " << device << " not of type ns3::PointToPointNetDevice"); + XBT_INFO ("MyPointToPointHelper::EnablePcapInternal(): Device not of type ns3::PointToPointNetDevice"); return; } @@ -199,8 +200,7 @@ MyPointToPointHelper::EnableAsciiInternal ( Ptr device = nd->GetObject (); if (device == 0) { - NS_LOG_INFO ("MyPointToPointHelper::EnableAsciiInternal(): Device " << device << - " not of type ns3::PointToPointNetDevice"); + XBT_INFO ("MyPointToPointHelper::EnableAsciiInternal(): Device not of type ns3::PointToPointNetDevice"); return; } diff --git a/src/surf/ns3/ns3_interface.cc b/src/surf/ns3/ns3_interface.cc index 900f77b6d7..0b9b1a3d10 100644 --- a/src/surf/ns3/ns3_interface.cc +++ b/src/surf/ns3/ns3_interface.cc @@ -17,7 +17,7 @@ extern xbt_lib_t host_lib; extern int NS3_HOST_LEVEL; //host node for ns3 extern xbt_dynar_t IPV4addr; -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(interface_ns3, surf, +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ns3, surf, "Logging specific to the SURF network NS3 module"); InternetStackHelper stack; diff --git a/src/surf/ns3/ns3_simulator.cc b/src/surf/ns3/ns3_simulator.cc index 4ad133eed5..7898de3996 100644 --- a/src/surf/ns3/ns3_simulator.cc +++ b/src/surf/ns3/ns3_simulator.cc @@ -24,8 +24,7 @@ static void StartFlow(Ptr sock, const char *to, uint16_t port_number); -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simulator_ns3, surf, - "Logging specific to the SURF network NS3 module"); +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); // Constructor. NS3Sim::NS3Sim(){ diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index 116c74b83d..a0fa181112 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -12,26 +12,15 @@ #include "ns3/core-module.h" #include "my-point-to-point-helper.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" - #include "ns3/tcp-socket-factory.h" -#endif +#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" +#include "ns3/tcp-socket-factory.h" using namespace ns3; using namespace std; diff --git a/src/surf/ns3/red-queue.cc b/src/surf/ns3/red-queue.cc index 3be1e16d5b..fa38df2864 100644 --- a/src/surf/ns3/red-queue.cc +++ b/src/surf/ns3/red-queue.cc @@ -24,19 +24,15 @@ * */ -#include "ns3/log.h" #include "ns3/enum.h" #include "ns3/uinteger.h" #include "ns3/double.h" #include "red-queue.h" #include "ns3/simulator.h" #include "ns3/nstime.h" -#include "ns3/random-variable.h" #include -NS_LOG_COMPONENT_DEFINE ("red"); - #define RED_STATS_TABLE_SIZE 256 #define RED_STATS_MASK (RED_STATS_TABLE_SIZE - 1) @@ -46,7 +42,7 @@ NS_OBJECT_ENSURE_REGISTERED (RedQueue); TypeId RedQueue::GetTypeId (void) { - ///< Note: these paramemters must be worked out beforehand for RED to work correctly + ///< Note: these parameters must be worked out beforehand for RED to work correctly ///< How these parameters are set up can affect RED performance greatly static TypeId tid = TypeId ("ns3::RedQueue") .SetParent () @@ -123,13 +119,11 @@ RedQueue::RedQueue () RedQueue::~RedQueue () { - NS_LOG_FUNCTION_NOARGS (); } void RedQueue::SetMode (enum Mode mode) { - NS_LOG_FUNCTION (mode); m_mode = mode; } @@ -162,7 +156,6 @@ RedQueue::GetAverageQueueSize (void) uint32_t RedQueue::evalEwma (uint32_t minTh, uint32_t burst, uint32_t avpkt) { - NS_LOG_FUNCTION (this); uint32_t wlog = 1; @@ -174,11 +167,9 @@ RedQueue::evalEwma (uint32_t minTh, uint32_t burst, uint32_t avpkt) ///< Note: bursts must be larger than minTh/avpkt for it to work temp = (double)burst + 1 - (double)minTh / avpkt; - NS_LOG_DEBUG ( "\t temp =" << temp); if (temp < 1.0) { - NS_LOG_DEBUG ("\tFailed to calculate EWMA constant"); return -1; } @@ -198,12 +189,10 @@ RedQueue::evalEwma (uint32_t minTh, uint32_t burst, uint32_t avpkt) { if (temp <= (1 - pow (1 - W, burst)) / W ) { - NS_LOG_DEBUG ("\t wlog=" << wlog); return wlog; } } - NS_LOG_DEBUG ("\tFailed to calculate EWMA constant"); return -1; } @@ -222,13 +211,11 @@ RedQueue::evalEwma (uint32_t minTh, uint32_t burst, uint32_t avpkt) uint32_t RedQueue::evalP (uint32_t minTh, uint32_t maxTh, double prob) { - NS_LOG_FUNCTION (this); uint32_t i = maxTh - minTh ; if (i <= 0) { - NS_LOG_DEBUG ("maxTh - minTh = 0"); return -1; } @@ -247,11 +234,11 @@ RedQueue::evalP (uint32_t minTh, uint32_t maxTh, double prob) ///< Error checking if (i >= 32 ) { - NS_LOG_DEBUG ("i >= 32, this shouldn't happen"); + //NS_LOG_DEBUG ("i >= 32, this shouldn't happen"); return -1; } - NS_LOG_DEBUG ("\t i(makes C1 power of two)=" << i); + //NS_LOG_DEBUG ("\t i(makes C1 power of two)=" << i); return i; } @@ -269,7 +256,6 @@ RedQueue::evalP (uint32_t minTh, uint32_t maxTh, double prob) uint32_t RedQueue::evalIdleDamping (uint32_t wLog, uint32_t avpkt, uint32_t bps) { - NS_LOG_FUNCTION (this); ///> in microsecond ticks: 1 sec = 1000000 microsecond ticks double xmitTime = ((double) avpkt / bps) * 1000000; @@ -282,8 +268,8 @@ RedQueue::evalIdleDamping (uint32_t wLog, uint32_t avpkt, uint32_t bps) ///> the maximum allow idle time double maxTime = 31 / wLogTemp; - NS_LOG_DEBUG ("\t xmitTime=" << xmitTime << " wLogTemp=" << wLogTemp - << " maxTime=" << maxTime); + //NS_LOG_DEBUG ("\t xmitTime=" << xmitTime << " wLogTemp=" << wLogTemp + // << " maxTime=" << maxTime); uint32_t cLog, i; @@ -320,7 +306,7 @@ RedQueue::evalIdleDamping (uint32_t wLog, uint32_t avpkt, uint32_t bps) m_sTable[255] = 31; - NS_LOG_DEBUG ("\t cLog=" << cLog); + //NS_LOG_DEBUG ("\t cLog=" << cLog); return cLog; } @@ -340,7 +326,6 @@ void RedQueue::SetParams (uint32_t minTh, uint32_t maxTh, uint32_t wLog, uint32_t pLog, uint64_t scellLog) { - NS_LOG_FUNCTION (this); m_qavg = 0; m_count = -1; @@ -352,20 +337,18 @@ RedQueue::SetParams (uint32_t minTh, uint32_t maxTh, m_scellLog = scellLog; m_scellMax = (255 << m_scellLog); - NS_LOG_DEBUG ("\t m_wLog" << m_wLog << " m_pLog" << m_pLog << " m_scellLog" << m_scellLog - << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh - << " rmask=" << m_rmask << " m_scellMax=" << m_scellMax); + //NS_LOG_DEBUG ("\t m_wLog" << m_wLog << " m_pLog" << m_pLog << " m_scellLog" << m_scellLog + // << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh + // << " rmask=" << m_rmask << " m_scellMax=" << m_scellMax); } int RedQueue::IsIdling () { - NS_LOG_FUNCTION_NOARGS (); - //use IsZero instead if ( m_idleStart.GetNanoSeconds () != 0) { - NS_LOG_DEBUG ("\t IsIdling"); + //NS_LOG_DEBUG ("\t IsIdling"); } return m_idleStart.GetNanoSeconds () != 0; @@ -373,23 +356,17 @@ RedQueue::IsIdling () void RedQueue::StartIdlePeriod () { - NS_LOG_FUNCTION_NOARGS (); - m_idleStart = Simulator::Now (); } void RedQueue::EndIdlePeriod () { - NS_LOG_FUNCTION_NOARGS (); - m_idleStart = NanoSeconds (0); } void RedQueue::Restart () { - NS_LOG_FUNCTION_NOARGS (); - EndIdlePeriod (); m_qavg = 0; m_count = -1; @@ -413,8 +390,6 @@ RedQueue::Restart () uint64_t RedQueue::AvgFromIdleTime () { - NS_LOG_FUNCTION_NOARGS (); - uint64_t idleTime; int shift; @@ -426,7 +401,7 @@ RedQueue::AvgFromIdleTime () idleTime = m_scellMax; } - NS_LOG_DEBUG ("\t idleTime=" << idleTime); + //NS_LOG_DEBUG ("\t idleTime=" << idleTime); //PrintTable (); shift = m_sTable [(idleTime >> m_scellLog) & RED_STATS_MASK]; @@ -441,7 +416,7 @@ RedQueue::AvgFromIdleTime () idleTime = (m_qavg * idleTime) >> m_scellLog; - NS_LOG_DEBUG ("\t idleus=" << idleTime); + // NS_LOG_DEBUG ("\t idleus=" << idleTime); if (idleTime < (m_qavg / 2)) { @@ -459,10 +434,10 @@ RedQueue::AvgFromIdleTime () uint64_t RedQueue::AvgFromNonIdleTime (uint32_t backlog) { - NS_LOG_FUNCTION (this << backlog); + //NS_LOG_FUNCTION (this << backlog); - NS_LOG_DEBUG ("qavg " << m_qavg); - NS_LOG_DEBUG ("backlog" << backlog); + //NS_LOG_DEBUG ("qavg " << m_qavg); + //NS_LOG_DEBUG ("backlog" << backlog); /** * This is basically EWMA @@ -476,21 +451,21 @@ RedQueue::AvgFromNonIdleTime (uint32_t backlog) uint64_t RedQueue::AvgCalc (uint32_t backlog) { - NS_LOG_FUNCTION (this << backlog); + //NS_LOG_FUNCTION (this << backlog); uint64_t qtemp; if ( !IsIdling ()) { qtemp = AvgFromNonIdleTime (backlog); - NS_LOG_DEBUG ("NonIdle Avg " << qtemp); + //NS_LOG_DEBUG ("NonIdle Avg " << qtemp); //std::cout <<"n "<< qtemp << std::endl; return qtemp; } else { qtemp = AvgFromIdleTime (); - NS_LOG_DEBUG ("Idle Avg" << qtemp); + //NS_LOG_DEBUG ("Idle Avg" << qtemp); //std::cout <<"i "<< qtemp << std::endl; return qtemp; } @@ -500,8 +475,8 @@ int RedQueue::CheckThresh (uint64_t avg) { - NS_LOG_FUNCTION (this << avg); - NS_LOG_DEBUG ("\t check threshold: min " << m_minTh << " max" << m_maxTh); + //NS_LOG_FUNCTION (this << avg); + //NS_LOG_DEBUG ("\t check threshold: min " << m_minTh << " max" << m_maxTh); if (avg < m_minTh) { @@ -519,7 +494,7 @@ RedQueue::CheckThresh (uint64_t avg) uint32_t RedQueue::RedRandom () { - NS_LOG_FUNCTION_NOARGS (); + //NS_LOG_FUNCTION_NOARGS (); ///> obtain a random u32 number ///> return m_rmask & ran.GetInteger (); @@ -529,10 +504,10 @@ RedQueue::RedRandom () int RedQueue::MarkProbability (uint64_t avg) { - NS_LOG_FUNCTION (this << avg); - NS_LOG_DEBUG ("\t m_randNum " << m_randNum); - NS_LOG_DEBUG ("\t right\t" << m_randNum); - NS_LOG_DEBUG ("\t left\t" << ((avg - m_minTh)*m_count)); + //NS_LOG_FUNCTION (this << avg); + //NS_LOG_DEBUG ("\t m_randNum " << m_randNum); + //NS_LOG_DEBUG ("\t right\t" << m_randNum); + //NS_LOG_DEBUG ("\t left\t" << ((avg - m_minTh)*m_count)); ///> max_P* (qavg - qth_min)/(qth_max-qth_min) < rnd/qcount //return !((avg - m_minTh ) * m_count < m_randNum); @@ -544,32 +519,32 @@ int RedQueue::Processing (uint64_t qavg) { - NS_LOG_FUNCTION (this << "qavg" << qavg << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh); + //NS_LOG_FUNCTION (this << "qavg" << qavg << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh); switch (CheckThresh (qavg)) { case BELOW_MIN_THRESH: - NS_LOG_DEBUG ("\t below threshold "); + //NS_LOG_DEBUG ("\t below threshold "); m_count = -1; return DONT_MARK; case BETWEEN_THRESH: - NS_LOG_DEBUG ("\t between threshold "); + //NS_LOG_DEBUG ("\t between threshold "); if (++m_count) { - NS_LOG_DEBUG ("\t check Mark Prob"); + //NS_LOG_DEBUG ("\t check Mark Prob"); if (MarkProbability (qavg)) { m_count = 0; m_randNum = RedRandom (); - NS_LOG_DEBUG ("\t Marked Will Drop " << m_qavg); + //NS_LOG_DEBUG ("\t Marked Will Drop " << m_qavg); return PROB_MARK; } - NS_LOG_DEBUG ("\t Marked Will Save " << m_qavg); + //NS_LOG_DEBUG ("\t Marked Will Save " << m_qavg); } else { @@ -579,13 +554,13 @@ RedQueue::Processing (uint64_t qavg) case ABOVE_MAX_THRESH: - NS_LOG_DEBUG ("\t above threshold "); + //NS_LOG_DEBUG ("\t above threshold "); m_count = -1; return HARD_MARK; } - NS_LOG_DEBUG ("BUG HERE\n"); + //NS_LOG_DEBUG ("BUG HERE\n"); return DONT_MARK; } @@ -593,18 +568,18 @@ RedQueue::Processing (uint64_t qavg) bool RedQueue::DoEnqueue (Ptr p) { - NS_LOG_FUNCTION (this << p); + //NS_LOG_FUNCTION (this << p); if (m_mode == PACKETS && (m_packets.size () >= m_maxPackets)) { - NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt"); + //NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt"); Drop (p); return false; } if (m_mode == BYTES && (m_bytesInQueue + p->GetSize () >= m_maxBytes)) { - NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt"); + //NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt"); Drop (p); return false; } @@ -612,11 +587,11 @@ RedQueue::DoEnqueue (Ptr p) if (!m_initialized) { // making sure all the variables are initialized ok - NS_LOG_DEBUG ("\t m_maxPackets" << m_maxPackets - << " m_maxBytes" << m_maxBytes - << " m_burst" << m_burst << " m_avPkt" << m_avPkt - << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh - << " m_rate" << m_rate << " m_prob" << m_prob); + //NS_LOG_DEBUG ("\t m_maxPackets" << m_maxPackets + // << " m_maxBytes" << m_maxBytes + // << " m_burst" << m_burst << " m_avPkt" << m_avPkt + // << " m_minTh" << m_minTh << " m_maxTh" << m_maxTh + // << " m_rate" << m_rate << " m_prob" << m_prob); m_wLog = evalEwma (m_minTh, m_burst, m_avPkt); m_pLog = evalP (m_minTh, m_maxTh, m_prob); @@ -640,8 +615,8 @@ RedQueue::DoEnqueue (Ptr p) // m_qavg = AvgCalc (m_packets.size ()); } - NS_LOG_DEBUG ("\t bytesInQueue " << m_bytesInQueue << "\tQavg " << m_qavg); - NS_LOG_DEBUG ("\t packetsInQueue " << m_packets.size () << "\tQavg " << m_qavg); + //NS_LOG_DEBUG ("\t bytesInQueue " << m_bytesInQueue << "\tQavg " << m_qavg); + //NS_LOG_DEBUG ("\t packetsInQueue " << m_packets.size () << "\tQavg " << m_qavg); if (IsIdling ()) @@ -655,14 +630,14 @@ RedQueue::DoEnqueue (Ptr p) break; case PROB_MARK: - NS_LOG_DEBUG ("\t Dropping due to Prob Mark " << m_qavg); + //NS_LOG_DEBUG ("\t Dropping due to Prob Mark " << m_qavg); m_stats.probDrop++; m_stats.probMark++; Drop (p); return false; case HARD_MARK: - NS_LOG_DEBUG ("\t Dropping due to Hard Mark " << m_qavg); + //NS_LOG_DEBUG ("\t Dropping due to Hard Mark " << m_qavg); m_stats.forcedMark++; m_stats.probDrop++; Drop (p); @@ -673,8 +648,8 @@ RedQueue::DoEnqueue (Ptr p) m_bytesInQueue += p->GetSize (); m_packets.push_back (p); - NS_LOG_LOGIC ("Number packets " << m_packets.size ()); - NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); + //NS_LOG_LOGIC ("Number packets " << m_packets.size ()); + //NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); return true; } @@ -682,11 +657,11 @@ RedQueue::DoEnqueue (Ptr p) Ptr RedQueue::DoDequeue (void) { - NS_LOG_FUNCTION (this); + //NS_LOG_FUNCTION (this); if (m_packets.empty ()) { - NS_LOG_LOGIC ("Queue empty"); + //NS_LOG_LOGIC ("Queue empty"); return 0; } @@ -694,10 +669,10 @@ RedQueue::DoDequeue (void) m_packets.pop_front (); m_bytesInQueue -= p->GetSize (); - NS_LOG_LOGIC ("Popped " << p); + //NS_LOG_LOGIC ("Popped " << p); - NS_LOG_LOGIC ("Number packets " << m_packets.size ()); - NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); + //NS_LOG_LOGIC ("Number packets " << m_packets.size ()); + //NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); if (m_bytesInQueue <= 0 && !IsIdling ()) { @@ -713,9 +688,9 @@ int RedQueue::DropPacket (Ptr p) { - NS_LOG_FUNCTION (this << p); + //NS_LOG_FUNCTION (this << p); - NS_LOG_DEBUG ("\t Dropping Packet p"); + //NS_LOG_DEBUG ("\t Dropping Packet p"); std::list >::iterator iter; uint32_t packetSize; @@ -742,18 +717,18 @@ RedQueue::DropPacket (Ptr p) Ptr RedQueue::DoPeek (void) const { - NS_LOG_FUNCTION (this); + //NS_LOG_FUNCTION (this); if (m_packets.empty ()) { - NS_LOG_LOGIC ("Queue empty"); + //NS_LOG_LOGIC ("Queue empty"); return NULL; } Ptr p = m_packets.front (); - NS_LOG_LOGIC ("Number packets " << m_packets.size ()); - NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); + //NS_LOG_LOGIC ("Number packets " << m_packets.size ()); + //NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); return p; } @@ -761,7 +736,7 @@ RedQueue::DoPeek (void) const void RedQueue::PrintTable () { - NS_LOG_FUNCTION_NOARGS (); + //NS_LOG_FUNCTION_NOARGS (); for (uint32_t i = 0; i < RED_STATS_TABLE_SIZE; i++) { diff --git a/src/xbt/log.c b/src/xbt/log.c index 7547f323c9..c690e8ba2a 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -721,9 +721,7 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(surf_network_gtnets_topology); #endif #ifdef HAVE_NS3 - XBT_LOG_CONNECT(surf_network_ns3); - XBT_LOG_CONNECT(interface_ns3); - XBT_LOG_CONNECT(simulator_ns3); + XBT_LOG_CONNECT(ns3); #endif XBT_LOG_CONNECT(surf_parse); XBT_LOG_CONNECT(surf_route); -- 2.20.1