NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create<NetPointNs3>();
NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create<NetPointNs3>();
ns3_initialize(ns3_tcp_model.get().c_str());
simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
ns3_initialize(ns3_tcp_model.get().c_str());
simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
}
LinkImpl* NetworkNS3Model::createLink(const std::string& name, double bandwidth, double latency,
}
LinkImpl* NetworkNS3Model::createLink(const std::string& name, double bandwidth, double latency,
/* If there are no running flows, advance the NS3 simulator and return */
if (getRunningActionSet()->empty()) {
/* If there are no running flows, advance the NS3 simulator and return */
if (getRunningActionSet()->empty()) {
- xbt_dict_cursor_t cursor = nullptr;
- char *ns3Socket;
- SgFlow *sgFlow;
- xbt_dict_foreach(flowFromSock,cursor,ns3Socket,sgFlow){
+ std::string ns3Socket;
+ for (auto elm : flowFromSock) {
+ ns3Socket = elm.first;
+ SgFlow* sgFlow = elm.second;
NetworkNS3Action * action = sgFlow->action_;
XBT_DEBUG("Processing socket %p (action %p)",sgFlow,action);
action->setRemains(action->getCost() - sgFlow->sentBytes_);
NetworkNS3Action * action = sgFlow->action_;
XBT_DEBUG("Processing socket %p (action %p)",sgFlow,action);
action->setRemains(action->getCost() - sgFlow->sentBytes_);
XBT_DEBUG("Destroy socket %p of action %p", ns3Socket, action);
action->finish(Action::State::done);
}
}
XBT_DEBUG("Destroy socket %p of action %p", ns3Socket, action);
action->finish(Action::State::done);
}
}
- while (not xbt_dynar_is_empty(socket_to_destroy)) {
- xbt_dynar_pop(socket_to_destroy,&ns3Socket);
-
+ while (not socket_to_destroy.empty()) {
+ ns3Socket = socket_to_destroy.back();
+ socket_to_destroy.pop_back();
+ SgFlow* flow = flowFromSock.at(ns3Socket);
- xbt_dict_set(flowFromSock, transformSocketPtr(sock), new SgFlow(TotalBytes, action), nullptr);
+ flowFromSock.insert({transformSocketPtr(sock), new SgFlow(TotalBytes, action)});