Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[NS3] unused variable removed
[simgrid.git] / src / surf / ns3 / ns3_simulator.cc
index 4eface7..6c167db 100644 (file)
@@ -19,6 +19,7 @@ NS3Sim SimulatorNS3;
 
 static void receive_callback(Ptr<Socket> localSocket);
 static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace);
+static void datasent_callback(Ptr<Socket> localSocket, uint32_t dataSent);
 static void StartFlow(Ptr<Socket> sock,
     const char *to,
     uint16_t port_number);
@@ -60,7 +61,6 @@ void NS3Sim::create_flow_NS3(
        MySocket *mysocket = new MySocket();
        mysocket->totalBytes = totalBytes;
        mysocket->remaining = totalBytes;
-       mysocket->last_amount_sent = 0;
        mysocket->bufferedBytes = 0;
        mysocket->sentBytes = 0;
        mysocket->finished = 0;
@@ -82,12 +82,8 @@ double NS3Sim::get_remains_from_socket(void *socket){
        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;
+double NS3Sim::get_sent_from_socket(void *socket){
+  return ((MySocket *)socket)->sentBytes;
 }
 
 void NS3Sim::simulator_stop(double min){
@@ -135,7 +131,6 @@ static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
          if(amountSent < 0)
            return;
 
-         (mysocket->last_amount_sent) += amountSent;
          (mysocket->bufferedBytes) += amountSent;
          (mysocket->remaining) -= amountSent;
          //cout << "[" << Simulator::Now ().GetSeconds() << "] " << "Send one packet, remaining "<<  mysocket->remaining << " bytes!" << endl;
@@ -146,6 +141,16 @@ static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
 
 }
 
+static void datasent_callback(Ptr<Socket> localSocket, uint32_t dataSent){
+  Address addr;
+  localSocket->GetSockName (addr);
+  InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
+  MySocket* mysocket = (MySocket*)xbt_dict_get_or_null(dict_socket,(char*)&localSocket);
+  mysocket->sentBytes += dataSent;
+  //cout << "[" << Simulator::Now ().GetSeconds() << "] " << "DATASENT [" << mysocket->totalBytes << "bytes],  from: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort () << " dataSent " << dataSent <<endl;
+}
+
+
 static void StartFlow(Ptr<Socket> sock,
     const char *to,
     uint16_t port_number)
@@ -157,4 +162,5 @@ static void StartFlow(Ptr<Socket> sock,
   sock->Connect(serverAddr);
   sock->SetSendCallback (MakeCallback (&send_callback));
   sock->SetRecvCallback (MakeCallback (&receive_callback));
+  sock->SetDataSentCallback (MakeCallback (&datasent_callback));
 }