Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[ns3, trace] tracing needs the sentBytes variable being updated by the datasent callback
[simgrid.git] / src / surf / ns3 / ns3_simulator.cc
index c705984..8b8a00c 100644 (file)
@@ -131,13 +131,16 @@ static void receive_callback(Ptr<Socket> localSocket){
 }
 
 static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
-       uint8_t *data = (uint8_t*)malloc(sizeof(uint8_t)*txSpace);
        MySocket* mysocket = get_my_socket(localSocket);
+
        if (mysocket->remaining == 0){
                  //all data was already buffered (and socket was already closed), just return
                  return;
        }
-       while (mysocket->sentBytes < mysocket->totalBytes
+
+       uint8_t *data = (uint8_t*)malloc(sizeof(uint8_t)*txSpace);
+
+       while (mysocket->bufferedBytes < mysocket->totalBytes
                        && localSocket->GetTxAvailable () > 0)
        {
       uint32_t toWrite = min ((mysocket->remaining), txSpace);
@@ -146,15 +149,15 @@ static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
 
       if(amountSent < 0)
          return;
-         (mysocket->sentBytes) += amountSent;
-         (mysocket->remaining) -= amountSent;
+      (mysocket->bufferedBytes) += amountSent;
+      (mysocket->remaining) -= amountSent;
       XBT_DEBUG("send_cb of F[%p, %p, %d] (%d/%d) %d buffered", mysocket, mysocket->action, mysocket->totalBytes, mysocket->remaining, mysocket->totalBytes, amountSent);
 
     }
 
        free(data);
 
-       if ((mysocket->sentBytes) >= mysocket->totalBytes){
+       if ((mysocket->bufferedBytes) >= mysocket->totalBytes){
                localSocket->Close();
        }
 }