Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Put ns3 sources in place.
authorNavarrop <Pierre.Navarro@imag.fr>
Thu, 21 Apr 2011 12:31:40 +0000 (14:31 +0200)
committerNavarrop <Pierre.Navarro@imag.fr>
Thu, 21 Apr 2011 12:31:40 +0000 (14:31 +0200)
buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/Modules/FindNS3.cmake
buildtools/Cmake/gras_config.h.in
src/include/surf/surf.h
src/surf/network_ns3.c [new file with mode: 0644]
src/surf/ns3/ns3_interface.cc [new file with mode: 0644]
src/surf/ns3/ns3_interface.h [new file with mode: 0644]
src/surf/surf.c
src/surf/surf_private.h
src/surf/surf_routing.c

index 3371adb..db5d97f 100644 (file)
@@ -184,6 +184,11 @@ set(GTNETS_SRC
        src/surf/network_gtnets.c
 )
 
        src/surf/network_gtnets.c
 )
 
+set(NS3_SRC
+       src/surf/network_ns3.c
+       src/surf/ns3/ns3_interface.cc
+       )
+
 set(SURF_SRC 
        src/surf/surf_model.c
        src/surf/surf_action.c
 set(SURF_SRC 
        src/surf/surf_model.c
        src/surf/surf_action.c
@@ -478,6 +483,13 @@ if(HAVE_MC)
                )
 endif(HAVE_MC)
 
                )
 endif(HAVE_MC)
 
+if(HAVE_NS3)
+       set(simgrid_sources
+               ${simgrid_sources}
+               ${NS3_SRC}
+       )
+endif(HAVE_NS3)
+
 # WINDOWS
 if(WIN32)
        set(simgrid_sources
 # WINDOWS
 if(WIN32)
        set(simgrid_sources
index 8906d1f..aca50fd 100644 (file)
@@ -59,6 +59,11 @@ if(HAVE_NS3_LIB AND HAVE_CORE_MODULE_H)
                if(NOT operation1)
                        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${HAVE_NS3_LIB} ")
                endif(NOT operation1)
                if(NOT operation1)
                        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${HAVE_NS3_LIB} ")
                endif(NOT operation1)
+               
+               string(REGEX MATCH "-I${HAVE_CORE_MODULE_H} " operation1 "${CMAKE_C_FLAGS}")
+               if(NOT operation1)
+                       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${HAVE_CORE_MODULE_H} ")
+               endif(NOT operation1)
        
                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)            
index a39a90f..4777ae1 100644 (file)
 /* Indicates that we have GTNETS support */
 #cmakedefine HAVE_GTNETS @HAVE_GTNETS@
 
 /* Indicates that we have GTNETS support */
 #cmakedefine HAVE_GTNETS @HAVE_GTNETS@
 
+/* Indicates that we have NS3 support */
+#cmakedefine HAVE_NS3 @HAVE_NS3@
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@
 
index 5672742..6aecbc5 100644 (file)
@@ -497,6 +497,28 @@ XBT_PUBLIC(void) surf_network_model_init_bypass(const char *id,
 XBT_PUBLIC(void) surf_network_model_init_GTNETS(const char *filename);
 #endif
 
 XBT_PUBLIC(void) surf_network_model_init_GTNETS(const char *filename);
 #endif
 
+#ifdef HAVE_NS3
+/** \brief Initializes the platform with the network model NS3
+ *  \ingroup SURF_models
+ *  \param filename XML platform file name
+ *
+ *  This function is called by surf_workstation_model_init_NS3
+ *  or by yourself only if you plan using surf_workstation_model_init_compound
+ *
+ *  \see surf_workstation_model_init_NS3()
+ */
+XBT_PUBLIC(void) surf_network_model_init_NS3(const char *filename);
+
+XBT_PUBLIC(void) parse_ns3_add_host(void);
+XBT_PUBLIC(void) parse_ns3_add_router(void);
+XBT_PUBLIC(void) parse_ns3_add_link(void);
+XBT_PUBLIC(void) parse_ns3_add_AS(void);
+XBT_PUBLIC(void) parse_ns3_add_route(void);
+XBT_PUBLIC(void) parse_ns3_add_ASroute(void);
+XBT_PUBLIC(void) parse_ns3_add_cluster(void);
+
+#endif
+
 /** \brief Initializes the platform with the network model Reno
  *  \ingroup SURF_models
  *  \param filename XML platform file name
 /** \brief Initializes the platform with the network model Reno
  *  \ingroup SURF_models
  *  \param filename XML platform file name
diff --git a/src/surf/network_ns3.c b/src/surf/network_ns3.c
new file mode 100644 (file)
index 0000000..b2e7470
--- /dev/null
@@ -0,0 +1,65 @@
+/* Copyright (c) 2007, 2008, 2009, 2010, 2011. 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. */
+
+#include "surf_private.h"
+#include "surf/ns3/ns3_interface.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_ns3, surf,
+                                "Logging specific to the SURF network NS3 module");
+
+extern routing_global_t global_routing;
+
+void parse_ns3_add_host(void)
+{
+       XBT_INFO("NS3_ADD_HOST '%s'",A_surfxml_host_id);
+       //ns3_add_host(A_surfxml_host_id);
+}
+void parse_ns3_add_router(void)
+{
+       XBT_INFO("NS3_ADD_ROUTER '%s'",A_surfxml_router_id);
+}
+void parse_ns3_add_link(void)
+{
+       XBT_INFO("NS3_ADD_LINK '%s'",A_surfxml_link_id);
+}
+void parse_ns3_add_AS(void)
+{
+       XBT_INFO("NS3_ADD_AS '%s'",A_surfxml_AS_id);
+}
+void parse_ns3_add_route(void)
+{
+       XBT_INFO("NS3_ADD_ROUTE from '%s' to '%s'",A_surfxml_route_src,A_surfxml_route_dst);
+}
+void parse_ns3_add_ASroute(void)
+{
+       XBT_INFO("NS3_ADD_ASROUTE from '%s' to '%s'",A_surfxml_ASroute_src,A_surfxml_ASroute_dst);
+}
+void parse_ns3_add_cluster(void)
+{
+       XBT_INFO("NS3_ADD_CLUSTER '%s'",A_surfxml_cluster_id);
+       routing_parse_Scluster();
+}
+
+static void define_callbacks_ns3(const char *filename)
+{
+  surfxml_add_callback(STag_surfxml_host_cb_list, &parse_ns3_add_host);        //HOST
+  surfxml_add_callback(STag_surfxml_router_cb_list, &parse_ns3_add_router);    //ROUTER
+  surfxml_add_callback(STag_surfxml_link_cb_list, &parse_ns3_add_link);        //LINK
+  surfxml_add_callback(STag_surfxml_AS_cb_list, &parse_ns3_add_AS);            //AS
+  surfxml_add_callback(STag_surfxml_route_cb_list, &parse_ns3_add_route);      //ROUTE
+  surfxml_add_callback(STag_surfxml_ASroute_cb_list, &parse_ns3_add_ASroute);  //ASROUTE
+  surfxml_add_callback(STag_surfxml_cluster_cb_list, &parse_ns3_add_cluster); //CLUSTER
+}
+
+void surf_network_model_init_NS3(const char *filename)
+{
+       define_callbacks_ns3(filename);
+       surf_network_model = surf_model_init();
+       surf_network_model->name = "network NS3";
+
+       update_model_description(surf_network_model_description,
+                   "NS3", surf_network_model);
+}
diff --git a/src/surf/ns3/ns3_interface.cc b/src/surf/ns3/ns3_interface.cc
new file mode 100644 (file)
index 0000000..2688f63
--- /dev/null
@@ -0,0 +1,22 @@
+
+#include "surf/ns3/ns3_interface.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 "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(interface_ns3, surf,
+                                "Logging specific to the SURF network NS3 module");
+
+//NodeContainer nodes;
+
+void ns3_add_host(char * id)
+{
+       XBT_INFO("Interface ns3 add host");
+//     Ptr<Node> a =  CreateObject<Node> (0);
+//     nodes.Add(a);
+}
diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h
new file mode 100644 (file)
index 0000000..76c43d5
--- /dev/null
@@ -0,0 +1,9 @@
+/* Copyright (c) 2007, 2008, 2009, 2010. 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. */
+
+#include "xbt/misc.h"
+
+XBT_PUBLIC(void) ns3_add_host(char * id);
index 74f7519..bd46602 100644 (file)
@@ -131,6 +131,11 @@ s_surf_model_description_t surf_network_model_description[] = {
   {"GTNets",
    "Network Pseudo-model using the GTNets simulator instead of an analytic model",
    NULL, surf_network_model_init_GTNETS},
   {"GTNets",
    "Network Pseudo-model using the GTNets simulator instead of an analytic model",
    NULL, surf_network_model_init_GTNETS},
+#endif
+#ifdef HAVE_NS3
+  {"NS3",
+   "TODO",
+   NULL, surf_network_model_init_NS3},
 #endif
   {"Reno",
    "Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
 #endif
   {"Reno",
    "Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
index ac3fae8..42ec82a 100644 (file)
@@ -194,6 +194,8 @@ struct s_routing_global {
 
 XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback, double_f_cpvoid_t get_link_latency_fun);
 
 
 XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback, double_f_cpvoid_t get_link_latency_fun);
 
+XBT_PUBLIC(void) routing_parse_Scluster(void);       /* cluster bypass */
+
 /**
  * Resource protected methods
  */
 /**
  * Resource protected methods
  */
index 3d1fd6a..5d1e078 100644 (file)
@@ -27,7 +27,6 @@ static double_f_cpvoid_t get_link_latency = NULL;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
-static void routing_parse_Scluster(void);       /* cluster bypass */
 static void routing_parse_Speer(void);          /* peer bypass */
 static void routing_parse_Srandom(void);        /* random bypass */
 static void routing_parse_Erandom(void);        /* random bypass */
 static void routing_parse_Speer(void);          /* peer bypass */
 static void routing_parse_Srandom(void);        /* random bypass */
 static void routing_parse_Erandom(void);        /* random bypass */
@@ -1529,7 +1528,7 @@ static void routing_parse_Econfig(void)
   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
 }
 
   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
 }
 
-static void routing_parse_Scluster(void)
+void routing_parse_Scluster(void)
 {
   static int AX_ptr = 0;
 
 {
   static int AX_ptr = 0;