X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/49e85177c669d793e84242983a1b1f430e47184e..7cad4f0d54aafeabb7ee95007fc370514c4923a9:/src/surf/network_ns3.cpp diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 4fecb0f530..789dc98e83 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -1,7 +1,9 @@ -/* Copyright (c) 2007-2013. The SimGrid Team. - * - * This program is free software; you can redistribute it and/or modify it +/* Copyright (c) 2007-2014. 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 "network_ns3.hpp" #include "surf_private.h" #include "simgrid/sg_config.h" @@ -55,7 +57,7 @@ static void parse_ns3_add_link(sg_platf_link_cbarg_t link) if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free); - NetworkLinkPtr net_link = surf_network_model->createResource(link->id, + NetworkLinkPtr net_link = surf_network_model->createNetworkLink(link->id, link->bandwidth, link->bandwidth_trace, link->latency, @@ -64,6 +66,7 @@ static void parse_ns3_add_link(sg_platf_link_cbarg_t link) link->state_trace, link->policy, link->properties); + xbt_lib_set(link_lib, link->id, SURF_LINK_LEVEL, net_link); } @@ -283,7 +286,6 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel("network NS3") { NS3_HOST_LEVEL = xbt_lib_add_level(host_lib,(void_f_pvoid_t)free_ns3_host); NS3_ASR_LEVEL = xbt_lib_add_level(as_router_lib,(void_f_pvoid_t)free_ns3_host); - NS3_LINK_LEVEL = xbt_lib_add_level(link_lib,(void_f_pvoid_t)free_ns3_link); } NetworkNS3Model::~NetworkNS3Model() { @@ -292,7 +294,7 @@ NetworkNS3Model::~NetworkNS3Model() { xbt_dict_free(&dict_socket); } -NetworkLinkPtr NetworkNS3Model::createResource(const char *name, +NetworkLinkPtr NetworkNS3Model::createNetworkLink(const char *name, double bw_initial, tmgr_trace_t bw_trace, double lat_initial, @@ -331,6 +333,7 @@ ActionPtr NetworkNS3Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, action->p_srcElm = src; action->p_dstElm = dst; #endif + surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); return (surf_action_t) action; } @@ -346,7 +349,7 @@ double NetworkNS3Model::shareResources(double now) do { ns3_simulator(now); time_to_next_flow_completion = ns3_time() - surf_get_clock();//FIXME: use now instead ? - } while(double_equals(time_to_next_flow_completion, 0)); + } while(double_equals(time_to_next_flow_completion, 0, sg_surf_precision)); XBT_DEBUG("min : %f", now); XBT_DEBUG("ns3 time : %f", ns3_time()); @@ -367,7 +370,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) /* If there are no running flows, just return */ if (!getRunningActionSet()->size()) { - while(double_positive(now-ns3_time())) { + while(double_positive(now-ns3_time(), sg_surf_precision)) { ns3_simulator(now-ns3_time()); } return; @@ -427,8 +430,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta) NetworkNS3Link::NetworkNS3Link(NetworkNS3ModelPtr model, const char *name, xbt_dict_t props, double bw_initial, double lat_initial) : NetworkLink(model, name, props) - , p_bdw(bprintf("%f", bw_initial)) , p_lat(bprintf("%f", lat_initial)) + , p_bdw(bprintf("%f", bw_initial)) , m_created(1) { } @@ -440,14 +443,6 @@ NetworkNS3Link::~NetworkNS3Link() void NetworkNS3Link::updateState(tmgr_trace_event_t event_type, double value, double date) { -} -double NetworkNS3Link::getLatency() -{ - -} -double NetworkNS3Link::getBandwidth() -{ - } /**********