* 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. */
* 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 "src/surf/network_ns3.hpp"
+#include "src/surf/surf_private.h"
+#include "src/surf/host_interface.hpp"
- XBT_DEBUG("NS3_ADD_AS '%s'",AS->id);
- xbt_lib_set(as_router_lib,
- AS->id,
- NS3_ASR_LEVEL,
- ns3_add_AS(AS->id)
- );
+ const char* as_id = as->p_name;
+ XBT_DEBUG("NS3_ADD_AS '%s'", as_id);
+ xbt_lib_set(as_router_lib, as_id, NS3_ASR_LEVEL, ns3_add_AS(as_id) );
xbt_die("There is no routes!");
XBT_DEBUG("Have get_onelink_routes, found %ld routes",onelink_routes->used);
//save them in trace file
xbt_die("There is no routes!");
XBT_DEBUG("Have get_onelink_routes, found %ld routes",onelink_routes->used);
//save them in trace file
unsigned int iter;
xbt_dynar_foreach(onelink_routes, iter, onelink) {
char *src = onelink->p_src->getName();
char *dst = onelink->p_dst->getName();
unsigned int iter;
xbt_dynar_foreach(onelink_routes, iter, onelink) {
char *src = onelink->p_src->getName();
char *dst = onelink->p_dst->getName();
if (strcmp(src,dst) && link->m_created){
XBT_DEBUG("Route from '%s' to '%s' with link '%s'", src, dst, link->getName());
if (strcmp(src,dst) && link->m_created){
XBT_DEBUG("Route from '%s' to '%s' with link '%s'", src, dst, link->getName());
- sg_platf_host_add_cb (&parse_ns3_add_host);
- sg_platf_router_add_cb (&parse_ns3_add_router);
+ hostCreatedCallbacks.connect(simgrid_ns3_add_host);
+ routingEdgeCreatedCallbacks.connect(simgrid_ns3_add_router);
sg_platf_postparse_add_cb(&create_ns3_topology); //get_one_link_routes
sg_platf_postparse_add_cb(&parse_ns3_end_platform); //InitializeRoutes
}
sg_platf_postparse_add_cb(&create_ns3_topology); //get_one_link_routes
sg_platf_postparse_add_cb(&parse_ns3_end_platform); //InitializeRoutes
}
if (ns3_initialize(xbt_cfg_get_string(_sg_cfg_set, "ns3/TcpModel"))) {
xbt_die("Impossible to initialize NS3 interface");
}
if (ns3_initialize(xbt_cfg_get_string(_sg_cfg_set, "ns3/TcpModel"))) {
xbt_die("Impossible to initialize NS3 interface");
}
XBT_INFO("The NS3 network model doesn't support latency state traces");
if (state_trace)
XBT_INFO("The NS3 network model doesn't support link state traces");
XBT_INFO("The NS3 network model doesn't support latency state traces");
if (state_trace)
XBT_INFO("The NS3 network model doesn't support link state traces");
- return new NetworkNS3Link(this, name, properties, bw_initial, lat_initial);
+ Link* link = new NetworkNS3Link(this, name, properties, bw_initial, lat_initial);
+ surf_callback_emit(networkLinkCreatedCallbacks, link);
+ return link;
{
xbt_dynar_t route = NULL;
routing_get_route_and_latency(src, dst, &route, NULL);
{
xbt_dynar_t route = NULL;
routing_get_route_and_latency(src, dst, &route, NULL);
double size, double rate)
{
XBT_DEBUG("Communicate from %s to %s", src->getName(), dst->getName());
double size, double rate)
{
XBT_DEBUG("Communicate from %s to %s", src->getName(), dst->getName());
ns3_create_flow(src->getName(), dst->getName(), surf_get_clock(), size, action);
ns3_create_flow(src->getName(), dst->getName(), surf_get_clock(), size, action);
xbt_dict_foreach(dict_socket,cursor,key,data){
xbt_dict_foreach(dict_socket,cursor,key,data){
XBT_DEBUG("Processing socket %p (action %p)",data,action);
action->setRemains(action->getCost() - ns3_get_socket_sent(data));
XBT_DEBUG("Processing socket %p (action %p)",data,action);
action->setRemains(action->getCost() - ns3_get_socket_sent(data));
routing_get_route_and_latency (action->p_srcElm, action->p_dstElm, &route, NULL);
unsigned int i;
for (i = 0; i < xbt_dynar_length (route); i++){
routing_get_route_and_latency (action->p_srcElm, action->p_dstElm, &route, NULL);
unsigned int i;
for (i = 0; i < xbt_dynar_length (route); i++){
xbt_dynar_pop(socket_to_destroy,&key);
void *data = xbt_dict_get (dict_socket, key);
xbt_dynar_pop(socket_to_destroy,&key);
void *data = xbt_dict_get (dict_socket, key);
XBT_DEBUG ("Removing socket %p of action %p", key, action);
xbt_dict_remove(dict_socket, key);
}
XBT_DEBUG ("Removing socket %p of action %p", key, action);
xbt_dict_remove(dict_socket, key);
}
-NetworkNS3Link::NetworkNS3Link(NetworkNS3ModelPtr model, const char *name, xbt_dict_t props,
+NetworkNS3Link::NetworkNS3Link(NetworkNS3Model *model, const char *name, xbt_dict_t props,
double bw_initial, double lat_initial)
: Link(model, name, props)
, p_lat(bprintf("%f", lat_initial))
double bw_initial, double lat_initial)
: Link(model, name, props)
, p_lat(bprintf("%f", lat_initial))
p_stateSet->erase(p_stateSet->iterator_to(*this));
XBT_DEBUG ("Removing action %p", this);
delete this;
p_stateSet->erase(p_stateSet->iterator_to(*this));
XBT_DEBUG ("Removing action %p", this);
delete this;