<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.738159103" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option id="gnu.cpp.compiler.option.include.paths.216814103" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/lib/jvm/java-7-openjdk-amd64/include"/>
+ <listOptionValue builtIn="false" value="/usr/include/ns3.22"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1641160853" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1053916774" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
<option id="gnu.c.compiler.option.include.paths.100642505" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/lib/jvm/java-7-openjdk-amd64/include"/>
+ <listOptionValue builtIn="false" value="/usr/include/ns3.22"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.538328935" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1593279917" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
<option id="gnu.both.asm.option.include.paths.2076655261" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/lib/jvm/java-7-openjdk-amd64/include"/>
+ <listOptionValue builtIn="false" value="/usr/include/ns3.22"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2071407067" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
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
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
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()
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)
-# 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}
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")
-### 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")
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}")
\section pls_simgrid_configuration_ns3 Using NS3
-It is possible to use discrete-event network simulator <a href="http://www.nsnam.org/">(ns-3)</a> 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 <a href="http://www.nsnam.org/">NS-3</a> 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
-<ul>
-<li>
-First, whenever possible, we let default ns3 values and we don't changed it ; in case you have doubts on values for those parameters (TCP parameters for example), blame ns-3...
-</li>
-
-<li>
-Second, routing used inside ns-3 is a global and static one, relying on a shortest path algorithm. We did so by using ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables.
-</li>
-
-<li>
-Third, we also choose to restrict the way your platform is built : 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.
-</li>
-
-</ul>
-<i>
-To use ns3 model inside SimGrid you have to install at least the version 3.10 of ns3 simulator.
-</i>
-
-- <b>Download and enter the lateast release (here the 3.12.1)</b>
+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
-- <b>Configure, make and install ns3</b>
+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
-- <b>Enable ns-3 support on SimGrid</b>
-
-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 \<ns3_path\>/lib and \<ns3_path\>/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=<ns3_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
-- <b>Use case</b>
+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
-<simgrid_executable> <platform description file> <deployment file> --cfg=network/model:NS3 --log=surf.threshold:info
-\endverbatim
+<ul>
+ <li>The default values (e.g., TCP parameters) are the ns3
+ values. Don't blame us for them.</li>
+
+ <li>NS3 networks are routed using the shortest path algorithm, using
+ ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables.</li>
+
+ <li>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. </li>
+</ul>
-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 <a href="http://www.nsnam.org/">(Official website)</a>
$ 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
#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;
*/
#include <ns3/abort.h>
-#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/point-to-point-net-device.h"
#include "ns3/point-to-point-channel.h"
#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",
Ptr<PointToPointNetDevice> device = nd->GetObject<PointToPointNetDevice> ();
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;
}
Ptr<PointToPointNetDevice> device = nd->GetObject<PointToPointNetDevice> ();
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;
}
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;
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(){
#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;
*
*/
-#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 <cstdlib>
-NS_LOG_COMPONENT_DEFINE ("red");
-
#define RED_STATS_TABLE_SIZE 256
#define RED_STATS_MASK (RED_STATS_TABLE_SIZE - 1)
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<Queue> ()
RedQueue::~RedQueue ()
{
- NS_LOG_FUNCTION_NOARGS ();
}
void
RedQueue::SetMode (enum Mode mode)
{
- NS_LOG_FUNCTION (mode);
m_mode = mode;
}
uint32_t
RedQueue::evalEwma (uint32_t minTh, uint32_t burst, uint32_t avpkt)
{
- NS_LOG_FUNCTION (this);
uint32_t wlog = 1;
///< 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;
}
{
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;
}
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;
}
///< 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;
}
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;
///> 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;
m_sTable[255] = 31;
- NS_LOG_DEBUG ("\t cLog=" << cLog);
+ //NS_LOG_DEBUG ("\t cLog=" << cLog);
return cLog;
}
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;
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;
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;
uint64_t
RedQueue::AvgFromIdleTime ()
{
- NS_LOG_FUNCTION_NOARGS ();
-
uint64_t idleTime;
int shift;
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];
idleTime = (m_qavg * idleTime) >> m_scellLog;
- NS_LOG_DEBUG ("\t idleus=" << idleTime);
+ // NS_LOG_DEBUG ("\t idleus=" << idleTime);
if (idleTime < (m_qavg / 2))
{
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
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;
}
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)
{
uint32_t
RedQueue::RedRandom ()
{
- NS_LOG_FUNCTION_NOARGS ();
+ //NS_LOG_FUNCTION_NOARGS ();
///> obtain a random u32 number
///> return m_rmask & ran.GetInteger ();
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);
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
{
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;
}
bool
RedQueue::DoEnqueue (Ptr<Packet> 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;
}
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);
// 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 ())
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);
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;
}
Ptr<Packet>
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;
}
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 ())
{
RedQueue::DropPacket (Ptr<Packet> 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<Ptr<Packet> >::iterator iter;
uint32_t packetSize;
Ptr<const Packet>
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<Packet> 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;
}
void
RedQueue::PrintTable ()
{
- NS_LOG_FUNCTION_NOARGS ();
+ //NS_LOG_FUNCTION_NOARGS ();
for (uint32_t i = 0; i < RED_STATS_TABLE_SIZE; i++)
{
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);