Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[NS3] fixing the remains value when updating actions state
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Fri, 2 Sep 2011 15:36:17 +0000 (17:36 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 5 Sep 2011 09:08:12 +0000 (11:08 +0200)
details:
- new method to get the sent bytes of a socket from the NS3 simulator
- before, the remains was always 0 because the send callback buffers all data

src/surf/network_ns3.c
src/surf/ns3/ns3_interface.cc
src/surf/ns3/ns3_interface.h
src/surf/ns3/ns3_simulator.cc
src/surf/ns3/ns3_simulator.h

index db84ca0..e838247 100644 (file)
@@ -438,7 +438,7 @@ static void ns3_update_actions_state(double now, double delta)
 
          xbt_dict_foreach(dict_socket,cursor,key,data){
            action = (surf_action_t)ns3_get_socket_action(data);
-           action->remains = ns3_get_socket_remains(data);
+           action->remains = action->cost - ns3_get_socket_sent(data);
 
            if(ns3_get_socket_is_finished(data) == 1){
              action->finish = now;
index 7607bdc..b0f57d2 100644 (file)
@@ -55,6 +55,10 @@ double ns3_get_socket_remains(void *socket){
                return ns3_sim->get_remains_from_socket(socket);
 }
 
+double ns3_get_socket_sent(void *socket){
+  return ns3_sim->get_sent_from_socket(socket);
+}
+
 double ns3_get_socket_last_amount_sent(void *socket){
        return ns3_sim->get_last_amount_sent_from_socket(socket);
 }
index 7b9022d..95426c6 100644 (file)
@@ -36,6 +36,7 @@ XBT_PUBLIC(void)   ns3_simulator(double min);
 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_sent(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);
index d731aa8..bd52efc 100644 (file)
@@ -83,6 +83,10 @@ double NS3Sim::get_remains_from_socket(void *socket){
        return ((MySocket *)socket)->remaining;
 }
 
+double NS3Sim::get_sent_from_socket(void *socket){
+  return ((MySocket *)socket)->sentBytes;
+}
+
 double NS3Sim::get_last_amount_sent_from_socket(void *socket){
        return ((MySocket *)socket)->last_amount_sent;
 }
index 88dda1d..5e6792a 100644 (file)
@@ -49,6 +49,7 @@ public:
        void simulator_start(void);
        void* get_action_from_socket(void *socket);
        double get_remains_from_socket(void *socket);
+       double get_sent_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);