Set TCP ACK whenver connection is established (closes bugs 499 and 198)
authorRaj Bhattacharjea <raj.b@gatech.edu>
Thu, 12 Mar 2009 18:25:08 -0400
changeset 4269 78d709bebd55
parent 4268 c5d79ee51ffc
child 4270 5ae6683ea586
Set TCP ACK whenver connection is established (closes bugs 499 and 198)
src/internet-stack/tcp-socket-impl.cc
--- a/src/internet-stack/tcp-socket-impl.cc	Mon Mar 16 18:44:38 2009 -0700
+++ b/src/internet-stack/tcp-socket-impl.cc	Thu Mar 12 18:25:08 2009 -0400
@@ -759,7 +759,7 @@
       break;
     case TX_DATA:
       NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action TX_DATA");
-      SendPendingData ();
+      SendPendingData (m_connected);
       break;
     case PEER_CLOSE:
       NS_ASSERT (false); // This should be processed in ProcessPacketAction
@@ -855,10 +855,21 @@
             NotifySend (GetTxAvailable ());
           }
       }
-      SendPendingData ();
+      SendPendingData (m_connected); //send acks if we are connected
       break;
     case NEW_ACK:
       NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action NEW_ACK_TX");
+      //check to see of the ACK had data with it; if so, pass it along
+      //to NEW_SEQ_RX
+      if(p->GetSize () > 0)
+        {
+          Simulator::ScheduleNow(&TcpSocketImpl::ProcessPacketAction,
+                                 this,
+                                 NEW_SEQ_RX,
+                                 p,
+                                 tcpHeader,
+                                 fromAddress);
+        }
       if (tcpHeader.GetAckNumber () < m_highestRxAck) //old ack, do nothing
       {
         break;
@@ -1001,10 +1012,6 @@
                    << " s " << s 
                    << " datasize " << p->GetSize() );
       uint8_t flags = 0;
-      if (withAck)
-        {
-          flags |= TcpHeader::ACK;
-        }
       uint32_t sz = p->GetSize (); // Size of packet
       uint32_t remainingData = m_pendingData->SizeFromSeq(
           m_firstPendingSequence,
@@ -1014,7 +1021,10 @@
           flags = TcpHeader::FIN;
           m_state = FIN_WAIT_1;
         }
-
+      if (withAck)
+        {
+          flags |= TcpHeader::ACK;
+        }
       TcpHeader header;
       header.SetFlags (flags);
       header.SetSequenceNumber (m_nextTxSequence);
@@ -1386,7 +1396,7 @@
         }
     }
   // Try to send more data
-  SendPendingData();
+  SendPendingData (m_connected);
 }
 
 Ptr<TcpSocketImpl> TcpSocketImpl::Copy ()
@@ -1440,7 +1450,7 @@
     m_cWnd = m_segmentSize; // Collapse cwnd (re-enter slowstart)
     // For Tahoe, we also reset nextTxSeq
     m_nextTxSequence = m_highestRxAck;
-    SendPendingData ();
+    SendPendingData (m_connected);
   }
 }