xbt_dict_foreach(dict_socket,cursor,key,data){
action = (surf_action_t)ns3_get_socket_action(data);
action->remains = ns3_get_socket_remains(data);
+
+//#ifdef HAVE_TRACING
+// if (TRACE_is_enabled()) {
+// double amount_sent = (action->generic_action.cost - action->generic_action.remains);
+//
+// // tracing resource utilization
+// xbt_dynar_t route = global_routing->get_route(action->src_name,
+// action->dst_name);
+// network_link_GTNETS_t link;
+// unsigned int i;
+// xbt_dynar_foreach(route, i, link) {
+// TRACE_surf_link_set_utilization (link->generic_resource.name,
+// action->generic_action.data,
+// (surf_action_t) action,
+// (amount_sent - last_amount_sent)/(delta),
+// now-delta,
+// delta);
+// }
+// }
+//#endif
+
if(ns3_get_socket_is_finished(data) == 1){
action->finish = now;
surf_action_state_set(action, SURF_ACTION_DONE);
return ns3_sim->get_remains_from_socket(socket);
}
+double ns3_get_socket_last_amount_sent(void *socket){
+ return ns3_sim->get_last_amount_sent_from_socket(socket);
+}
+
+void ns3_reset_socket_last_amount_sent(void *socket){
+ ns3_sim->reset_last_amount_sent_from_socket(socket);
+}
+
char ns3_get_socket_is_finished(void *socket){
return ns3_sim->get_finished(socket);
}
-
double ns3_time(){
return Simulator::Now().GetSeconds();
}
XBT_PUBLIC(double) ns3_time(void);
XBT_PUBLIC(void*) ns3_get_socket_action(void *socket);
XBT_PUBLIC(double) ns3_get_socket_remains(void *socket);
+XBT_PUBLIC(double) ns3_get_socket_last_amount_sent(void *socket);
+XBT_PUBLIC(void) ns3_reset_socket_last_amount_sent(void *socket);
XBT_PUBLIC(char) ns3_get_socket_is_finished(void *socket);
XBT_PUBLIC(void *) ns3_add_host(char * id);
XBT_PUBLIC(void *) ns3_add_host_cluster(char * id);
MySocket *mysocket = new MySocket();
mysocket->TotalBytes = TotalBytes;
mysocket->remaining = TotalBytes;
+ mysocket->last_amount_sent = 0;
mysocket->sentBytes = 0;
mysocket->finished = 0;
mysocket->action = action;
return ((MySocket *)socket)->remaining;
}
+double NS3Sim::get_last_amount_sent_from_socket(void *socket){
+ return ((MySocket *)socket)->last_amount_sent;
+}
+
+void NS3Sim::reset_last_amount_sent_from_socket(void *socket){
+ ((MySocket *)socket)->last_amount_sent = 0;
+}
+
void NS3Sim::simulator_stop(double min){
if(min > 0.0)
Simulator::Stop(Seconds(min));
if(amountSent < 0)
return;
- (mysocket->sentBytes) += amountSent;
+
+ (mysocket->last_amount_sent) += amountSent;
+ (mysocket->sentBytes) += amountSent;
(mysocket->remaining) -= amountSent;
//cout << "[" << Simulator::Now ().GetSeconds() << "] " << "Send one packet, remaining "<< mysocket->remaining << " bytes!" << endl;
}
uint32_t sentBytes;
uint32_t remaining;
uint32_t TotalBytes;
+ uint32_t last_amount_sent;
char finished;
void* action;
};
void simulator_start(void);
void* get_action_from_socket(void *socket);
double get_remains_from_socket(void *socket);
+ double get_last_amount_sent_from_socket(void *socket);
+ void reset_last_amount_sent_from_socket(void *socket);
char get_finished(void *socket);
};