Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[NS3] adding bufferedBytes variable to MySocket structure (replaces old sentBytes)
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Fri, 2 Sep 2011 15:00:52 +0000 (17:00 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Mon, 5 Sep 2011 09:08:12 +0000 (11:08 +0200)
- also fix on header indentation (removing tabs and replace by two spaces)

src/surf/ns3/ns3_simulator.cc
src/surf/ns3/ns3_simulator.h

index 258c43d..c3911fa 100644 (file)
@@ -61,6 +61,7 @@ void NS3Sim::create_flow_NS3(
        mysocket->TotalBytes = TotalBytes;
        mysocket->remaining = TotalBytes;
        mysocket->last_amount_sent = 0;
        mysocket->TotalBytes = TotalBytes;
        mysocket->remaining = TotalBytes;
        mysocket->last_amount_sent = 0;
+       mysocket->bufferedBytes = 0;
        mysocket->sentBytes = 0;
        mysocket->finished = 0;
        mysocket->action = action;
        mysocket->sentBytes = 0;
        mysocket->finished = 0;
        mysocket->action = action;
@@ -126,7 +127,7 @@ static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
        InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
        MySocket* mysocket = (MySocket*)xbt_dict_get_or_null(dict_socket,(char*)&localSocket);
        uint32_t totalBytes = mysocket->TotalBytes;
        InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
        MySocket* mysocket = (MySocket*)xbt_dict_get_or_null(dict_socket,(char*)&localSocket);
        uint32_t totalBytes = mysocket->TotalBytes;
-       while ((mysocket->sentBytes) < totalBytes && localSocket->GetTxAvailable () > 0){
+       while ((mysocket->bufferedBytes) < totalBytes && localSocket->GetTxAvailable () > 0){
          uint32_t toWrite = min ((mysocket->remaining), writeSize);
          toWrite = min (toWrite, localSocket->GetTxAvailable ());
          int amountSent = localSocket->Send (&data[0], toWrite, 0);
          uint32_t toWrite = min ((mysocket->remaining), writeSize);
          toWrite = min (toWrite, localSocket->GetTxAvailable ());
          int amountSent = localSocket->Send (&data[0], toWrite, 0);
@@ -135,11 +136,11 @@ static void send_callback(Ptr<Socket> localSocket, uint32_t txSpace){
            return;
 
          (mysocket->last_amount_sent) += amountSent;
            return;
 
          (mysocket->last_amount_sent) += amountSent;
-         (mysocket->sentBytes) += amountSent;
+         (mysocket->bufferedBytes) += amountSent;
          (mysocket->remaining) -= amountSent;
          //cout << "[" << Simulator::Now ().GetSeconds() << "] " << "Send one packet, remaining "<<  mysocket->remaining << " bytes!" << endl;
        }
          (mysocket->remaining) -= amountSent;
          //cout << "[" << Simulator::Now ().GetSeconds() << "] " << "Send one packet, remaining "<<  mysocket->remaining << " bytes!" << endl;
        }
-       if ((mysocket->sentBytes) >= totalBytes){
+       if ((mysocket->bufferedBytes) >= TotalBytes){
                localSocket->Close();
        }
 
                localSocket->Close();
        }
 
index bd08513..484a49f 100644 (file)
@@ -21,12 +21,13 @@ using namespace ns3;
 using namespace std;
 
 struct MySocket{
 using namespace std;
 
 struct MySocket{
-       uint32_t sentBytes;
-       uint32_t remaining;
-       uint32_t TotalBytes;
-       uint32_t last_amount_sent;
-       char finished;
-       void* action;
+  uint32_t bufferedBytes;
+  uint32_t sentBytes;
+  uint32_t remaining;
+  uint32_t TotalBytes;
+  uint32_t last_amount_sent;
+  char finished;
+  void* action;
 };
 
 //Simulator s;
 };
 
 //Simulator s;