void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Initialize */ inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while (1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name, net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); debug_done(); /* Finish program */ mhandle_done(); exit(0); }
void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Network Trace = Stand Alone */ if (net_tracing()) { /* Initialization of Trace */ net_trace_header("net.init version=\"%d.%d\"\n", NET_SYSTEM_TRACE_VERSION_MAJOR, NET_SYSTEM_TRACE_VERSION_MINOR); /* Network Trace Header */ net_config_trace(net); } inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while(1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name ,net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); trace_done(); debug_done(); }