From 521c43eb23b20f4dddca5da03b34eb566dafad58 Mon Sep 17 00:00:00 2001 From: Raj Bhattacharjea Date: Mon, 31 Mar 2008 16:18:03 -0400 Subject: [PATCH] Fix the fin retransmission; --- src/internet-node/tcp-socket.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/internet-node/tcp-socket.cc b/src/internet-node/tcp-socket.cc index 02eff8931..d928f9067 100644 --- a/src/internet-node/tcp-socket.cc +++ b/src/internet-node/tcp-socket.cc @@ -733,7 +733,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, { NS_LOG_LOGIC ("TCP " << this << " calling AppCloseRequest"); - NotifyHalfClose (); + NotifyCloseRequested(); m_closeRequestNotified = true; } NS_LOG_LOGIC ("TcpSocket " << this @@ -741,7 +741,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, if (m_state == saveState) { // Need to ack, the application will close later SendEmptyPacket (TcpHeader::ACK); - // Also need to re-tx the ack if we +// // Also need to re-tx the ack if we } if (m_state == LAST_ACK) { @@ -851,10 +851,11 @@ bool TcpSocket::SendPendingData (bool withAck) return -1; } - Time rto = m_rtt->RetransmitTimeout (); + if (m_retxEvent.IsExpired () ) //go ahead and schedule the retransmit { - NS_LOG_LOGIC ("Schedule retransmission timeout at time " << + Time rto = m_rtt->RetransmitTimeout (); + NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " << (Simulator::Now () + rto).GetSeconds () ); m_retxEvent = Simulator::Schedule (rto,&TcpSocket::ReTxTimeout,this); @@ -1042,11 +1043,17 @@ void TcpSocket::CommonNewAck (SequenceNumber ack, bool skipTimer) // and MUST be called by any subclass, from the NewAck function // Always cancel any pending re-tx timer on new acknowledgement NS_LOG_FUNCTION; - NS_LOG_PARAMS (this << ack << skipTimer); + NS_LOG_PARAMS (this << ack << skipTimer); //DEBUG(1,(cout << "TCP " << this << "Cancelling retx timer " << endl)); if (!skipTimer) { - m_retxEvent.Cancel (); + m_retxEvent.Cancel (); + //On recieving a "New" ack we restart retransmission timer .. RFC 2988 + Time rto = m_rtt->RetransmitTimeout (); + NS_LOG_LOGIC ("Schedule retransmission timeout at time " + << Simulator::Now ().GetSeconds () << " to expire at time " + << (Simulator::Now () + rto).GetSeconds ()); + m_retxEvent = Simulator::Schedule (rto, &TcpSocket::ReTxTimeout, this); } NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack << " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed