xbt_free(link_lat);
}
}
+
+ ns3::GlobalRouteManager::BuildGlobalRoutingDatabase();
+ ns3::GlobalRouteManager::InitializeRoutes();
}
/*********
simgrid::surf::on_link.connect(netlink_parse_init);
simgrid::surf::on_cluster.connect (&parse_ns3_add_cluster);
simgrid::surf::on_postparse.connect(&create_ns3_topology); //get_one_link_routes
- simgrid::surf::on_postparse.connect(&ns3_end_platform); //InitializeRoutes
NS3_EXTENSION_ID = simgrid::s4u::Host::extension_create(xbt_free_f);
NS3_ASR_LEVEL = xbt_lib_add_level(as_router_lib, xbt_free_f);
Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst, double size, double rate)
{
- XBT_DEBUG("Communicate from %s to %s", src->name(), dst->name());
- NetworkNS3Action *action = new NetworkNS3Action(this, size, 0);
-
- ns3_create_flow(src->name(), dst->name(), surf_get_clock(), size, action);
-
- action->m_lastSent = 0;
- action->p_srcElm = src;
- action->p_dstElm = dst;
- networkCommunicateCallbacks(action, src, dst, size, rate);
-
- return action;
+ return new NetworkNS3Action(this, size, src, dst);
}
double NetworkNS3Model::next_occuring_event(double now)
if (TRACE_is_enabled() &&
action->getState() == Action::State::running){
- double data_delta_sent = sgFlow->sentBytes_ - action->m_lastSent;
+ double data_delta_sent = sgFlow->sentBytes_ - action->lastSent_;
std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency (action->p_srcElm, action->p_dstElm, route, NULL);
+ routing_platf->getRouteAndLatency (action->src_, action->dst_, route, NULL);
for (auto link : *route)
TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta);
delete route;
- action->m_lastSent = sgFlow->sentBytes_;
+ action->lastSent_ = sgFlow->sentBytes_;
}
if(sgFlow->finished_){
THROW_UNIMPLEMENTED;
}
void LinkNS3::setBandwidthTrace(tmgr_trace_t trace) {
- xbt_die("The NS3 network model doesn't support latency state traces");
+ xbt_die("The NS3 network model doesn't support bandwidth traces");
}
void LinkNS3::setLatencyTrace(tmgr_trace_t trace) {
- xbt_die("The NS3 network model doesn't support latency state traces");
+ xbt_die("The NS3 network model doesn't support latency traces");
}
/**********
* Action *
**********/
-NetworkNS3Action::NetworkNS3Action(Model *model, double cost, bool failed)
-: NetworkAction(model, cost, failed)
-{}
-
-void NetworkNS3Action::suspend()
+NetworkNS3Action::NetworkNS3Action(Model *model, double size, NetCard *src, NetCard *dst)
+: NetworkAction(model, size, false)
{
+ XBT_DEBUG("Communicate from %s to %s", src->name(), dst->name());
+
+ src_ = src;
+ dst_ = dst;
+ ns3_create_flow(src->name(), dst->name(), surf_get_clock(), size, this);
+
+ Link::onCommunicate(this, src, dst);
+}
+
+void NetworkNS3Action::suspend() {
THROW_UNIMPLEMENTED;
}
-void NetworkNS3Action::resume()
-{
+void NetworkNS3Action::resume() {
THROW_UNIMPLEMENTED;
}
int NetworkNS3Action::unref()
{
- m_refcount--;
- if (!m_refcount) {
+ refcount_--;
+ if (!refcount_) {
if (action_hook.is_linked())
- p_stateSet->erase(p_stateSet->iterator_to(*this));
+ stateSet_->erase(stateSet_->iterator_to(*this));
XBT_DEBUG ("Removing action %p", this);
delete this;
return 1;
}
-void ns3_simulator(double min){
- if (min > 0.0) // If there is a maximum amount of time to run
- ns3::Simulator::Stop(ns3::Seconds(min));
- XBT_DEBUG("Start simulator for at most %fs",min);
+void ns3_simulator(double maxSeconds){
+ if (maxSeconds > 0.0) // If there is a maximum amount of time to run
+ ns3::Simulator::Stop(ns3::Seconds(maxSeconds));
+ XBT_DEBUG("Start simulator for at most %fs",maxSeconds);
ns3::Simulator::Run ();
}
XBT_DEBUG("\tAdd PTP from %d to %d bw:'%s' lat:'%s'",src,dst,bw,lat);
pointToPoint.SetDeviceAttribute ("DataRate", ns3::StringValue (bw));
pointToPoint.SetChannelAttribute ("Delay", ns3::StringValue (lat));
- //pointToPoint.EnablePcapAll("test_ns3_trace"); //DEBUG
netA.Add(pointToPoint.Install (a, b));
xbt_dynar_set_as(IPV4addr,dst,char*,tmp);
XBT_DEBUG("Have write '%s' for Node '%d'",(char*)xbt_dynar_get_as(IPV4addr,dst,char*),dst);
- if(number_of_links == 255){
- if(number_of_networks == 255)
- xbt_die("Number of links and networks exceed 255*255");
+ if (number_of_links == 255){
+ xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
number_of_links = 1;
number_of_networks++;
- }else{
+ } else {
number_of_links++;
}
}
-
-void ns3_end_platform(void)
-{
- XBT_DEBUG("InitializeRoutes");
- ns3::GlobalRouteManager::BuildGlobalRoutingDatabase();
- ns3::GlobalRouteManager::InitializeRoutes();
-}