A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[NS3] cosmetics, changing the name of the function that creates a NS3 surf network...
[simgrid.git]
/
src
/
surf
/
network_ns3.c
diff --git
a/src/surf/network_ns3.c
b/src/surf/network_ns3.c
index
ea514d3
..
8ebfdf0
100644
(file)
--- a/
src/surf/network_ns3.c
+++ b/
src/surf/network_ns3.c
@@
-17,6
+17,8
@@
extern xbt_lib_t as_router_lib;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_ns3, surf,
"Logging specific to the SURF network NS3 module");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_ns3, surf,
"Logging specific to the SURF network NS3 module");
+#define MAX_LENGHT_IPV4 16 //255.255.255.255\0
+
extern routing_global_t global_routing;
extern xbt_dict_t dict_socket;
extern routing_global_t global_routing;
extern xbt_dict_t dict_socket;
@@
-25,7
+27,7
@@
static double time_to_next_flow_completion = -1;
static double ns3_share_resources(double min);
static void ns3_update_actions_state(double now, double delta);
static void finalize(void);
static double ns3_share_resources(double min);
static void ns3_update_actions_state(double now, double delta);
static void finalize(void);
-static surf_action_t communicate(const char *src_name,
+static surf_action_t
ns3_
communicate(const char *src_name,
const char *dst_name, double size, double rate);
static void action_suspend(surf_action_t action);
static void action_resume(surf_action_t action);
const char *dst_name, double size, double rate);
static void action_suspend(surf_action_t action);
static void action_resume(surf_action_t action);
@@
-54,7
+56,7
@@
static void replace_bdw_ns3(char * bdw)
{
char *temp = xbt_strdup(bdw);
xbt_free(bdw);
{
char *temp = xbt_strdup(bdw);
xbt_free(bdw);
- bdw = bprintf("%f
b
ps",atof(temp));
+ bdw = bprintf("%f
B
ps",atof(temp));
xbt_free(temp);
}
xbt_free(temp);
}
@@
-76,11
+78,18
@@
void parse_ns3_add_host(void)
ns3_add_host(A_surfxml_host_id)
);
}
ns3_add_host(A_surfxml_host_id)
);
}
+
+static void ns3_free_dynar(void * elmts){
+ if(elmts)
+ free(elmts);
+ return;
+}
+
void parse_ns3_add_link(void)
{
XBT_DEBUG("NS3_ADD_LINK '%s'",A_surfxml_link_id);
void parse_ns3_add_link(void)
{
XBT_DEBUG("NS3_ADD_LINK '%s'",A_surfxml_link_id);
- if(!IPV4addr) IPV4addr = xbt_dynar_new(
sizeof(char*),free
);
+ if(!IPV4addr) IPV4addr = xbt_dynar_new(
MAX_LENGHT_IPV4*sizeof(char),ns3_free_dynar
);
tmgr_trace_t bw_trace;
tmgr_trace_t state_trace;
tmgr_trace_t bw_trace;
tmgr_trace_t state_trace;
@@
-188,8
+197,6
@@
void parse_ns3_add_cluster(void)
}
}
}
}
-
-
//Create links
unsigned int cpt;
int elmts;
//Create links
unsigned int cpt;
int elmts;
@@
-258,6
+265,8
@@
void create_ns3_topology()
{
XBT_DEBUG("Starting topology generation");
{
XBT_DEBUG("Starting topology generation");
+ xbt_dynar_shrink(IPV4addr,0);
+
//get the onelinks from the parsed platform
xbt_dynar_t onelink_routes = global_routing->get_onelink_routes();
if (!onelink_routes)
//get the onelinks from the parsed platform
xbt_dynar_t onelink_routes = global_routing->get_onelink_routes();
if (!onelink_routes)
@@
-273,8
+282,10
@@
void create_ns3_topology()
if( strcmp(src,dst) && ((surf_ns3_link_t)link)->created){
XBT_DEBUG("Route from '%s' to '%s' with link '%s'",src,dst,((surf_ns3_link_t)link)->data->id);
if( strcmp(src,dst) && ((surf_ns3_link_t)link)->created){
XBT_DEBUG("Route from '%s' to '%s' with link '%s'",src,dst,((surf_ns3_link_t)link)->data->id);
- char * link_bdw = bprintf("%sBps",((surf_ns3_link_t)link)->data->bdw);
- char * link_lat = bprintf("%ss",(((surf_ns3_link_t)link)->data->lat));
+ char * link_bdw = bprintf("%s",((surf_ns3_link_t)link)->data->bdw);
+ char * link_lat = bprintf("%s",(((surf_ns3_link_t)link)->data->lat));
+ replace_lat_ns3(link_lat);
+ replace_bdw_ns3(link_bdw);
((surf_ns3_link_t)link)->created = 0;
// XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id);
((surf_ns3_link_t)link)->created = 0;
// XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id);
@@
-357,7
+368,7
@@
void surf_network_model_init_NS3(const char *filename)
surf_network_model->resume = action_resume;
surf_network_model->is_suspended = action_is_suspended;
surf_network_model->action_unref = action_unref;
surf_network_model->resume = action_resume;
surf_network_model->is_suspended = action_is_suspended;
surf_network_model->action_unref = action_unref;
- surf_network_model->extension.network.communicate = communicate;
+ surf_network_model->extension.network.communicate =
ns3_
communicate;
/* Added the initialization for NS3 interface */
if (ns3_initialize()) {
/* Added the initialization for NS3 interface */
if (ns3_initialize()) {
@@
-400,6
+411,10
@@
static double ns3_share_resources(double min)
ns3_simulator(min);
time_to_next_flow_completion = ns3_time() - surf_get_clock();
ns3_simulator(min);
time_to_next_flow_completion = ns3_time() - surf_get_clock();
+// XBT_INFO("min : %f",min);
+// XBT_INFO("ns3 time : %f",ns3_time());
+// XBT_INFO("surf time : %f",surf_get_clock());
+
xbt_assert(time_to_next_flow_completion,
"Time to next flow completion not initialized!\n");
xbt_assert(time_to_next_flow_completion,
"Time to next flow completion not initialized!\n");
@@
-422,18
+437,19
@@
static void ns3_update_actions_state(double now, double delta)
return;
xbt_dict_foreach(dict_socket,cursor,key,data){
return;
xbt_dict_foreach(dict_socket,cursor,key,data){
- action = (surf_action_t)ns3_get_socket_action(data);
- action->remains = ns3_get_socket_remains(data);
- if(ns3_get_socket_is_finished(data) == 1){
- action->finish = now;
- surf_action_state_set(action, SURF_ACTION_DONE);
- }
+ action = (surf_action_t)ns3_get_socket_action(data);
+ action->remains = action->cost - ns3_get_socket_sent(data);
+
+ if(ns3_get_socket_is_finished(data) == 1){
+ action->finish = now;
+ surf_action_state_set(action, SURF_ACTION_DONE);
+ }
}
return;
}
/* Max durations are not supported */
}
return;
}
/* Max durations are not supported */
-static surf_action_t communicate(const char *src_name,
+static surf_action_t
ns3_
communicate(const char *src_name,
const char *dst_name, double size, double rate)
{
surf_action_t action = NULL;
const char *dst_name, double size, double rate)
{
surf_action_t action = NULL;