static void clusterCreation_cb(ClusterCreationArgs* cluster)
{
- for (int i : *cluster->radicals) {
+ for (int const& i : *cluster->radicals) {
// Routers don't create a router on the other end of the private link by themselves.
// We just need this router to be given an ID so we create a temporary NetPointNS3 so that it gets one
NetPointNs3* host_dst = new NetPointNs3();
// Create private link
- char* host_id = bprintf("%s%d%s", cluster->prefix, i, cluster->suffix);
- NetPointNs3* host_src = sg_host_by_name(host_id)->pimpl_netpoint->extension<NetPointNs3>();
- xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id);
+ std::string host_id = cluster->prefix + std::to_string(i) + cluster->suffix;
+ NetPointNs3* host_src = sg_host_by_name(host_id.c_str())->pimpl_netpoint->extension<NetPointNs3>();
+ xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id.c_str());
// Any NS3 route is symmetrical
ns3_add_link(host_src, host_dst, cluster->bw, cluster->lat);
delete host_dst;
- free(host_id);
}
//Create link backbone
- ns3_add_cluster(cluster->id, cluster->bb_bw, cluster->bb_lat);
+ ns3_add_cluster(cluster->id.c_str(), cluster->bb_bw, cluster->bb_lat);
}
static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoint* src,
NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create<NetPointNs3>();
+ flowFromSock = xbt_dict_new_homogeneous([](void* p) { delete (SgFlow*)p; });
ns3_initialize(ns3_tcp_model.get().c_str());
simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
}
NetworkNS3Model::~NetworkNS3Model() {
- for (auto addr : IPV4addr)
+ for (auto const& addr : IPV4addr)
free(addr);
IPV4addr.clear();
xbt_dict_free(&flowFromSock);
std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
action->src_->routeTo(action->dst_, &route, nullptr);
- for (auto link : route)
+ for (auto const& link : route)
TRACE_surf_link_set_utilization(link->cname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
delta);