*** tcp-socket-impl.cc.orig Fri Apr 30 10:36:46 2010 --- tcp-socket-impl.cc Mon May 3 16:25:27 2010 *************** *** 91,96 **** --- 91,97 ---- m_highestRxAck (0), m_lastRxAck (0), m_nextRxSequence (0), + m_finSequence (0), m_rxAvailable (0), m_rxBufSize (0), m_pendingData (0), *************** *** 131,136 **** --- 132,138 ---- m_highestRxAck (sock.m_highestRxAck), m_lastRxAck (sock.m_lastRxAck), m_nextRxSequence (sock.m_nextRxSequence), + m_finSequence (0), m_rxAvailable (0), m_rxBufSize (0), m_pendingData (0), *************** *** 360,365 **** --- 362,368 ---- " deferring close, state " << m_state); return 0; } + m_finSequence = m_nextTxSequence + SequenceNumber(1); Actions_t action = ProcessEvent (APP_CLOSE); ProcessAction (action); return 0; *************** *** 958,963 **** --- 961,967 ---- if(tcpHeader.GetFlags() & TcpHeader::FIN) { ++m_nextRxSequence; //bump this to account for the FIN + m_nextTxSequence=m_finSequence; } SendEmptyPacket (TcpHeader::ACK); break; *************** *** 1054,1060 **** --- 1058,1067 ---- // out of sequence. If so, note pending close and process // new sequence rx if (tcpHeader.GetSequenceNumber () != m_nextRxSequence) + { + if(m_finSequence != m_nextRxSequence) { // process close later + m_finSequence = tcpHeader.GetSequenceNumber()+SequenceNumber(p->GetSize()); m_pendingClose = true; NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" << " rxseq " << tcpHeader.GetSequenceNumber () *************** *** 1062,1067 **** --- 1069,1075 ---- NewRx (p, tcpHeader, fromAddress, toAddress); return true; } + } // Now we need to see if any data came with the FIN // if so, call NewRx if (p->GetSize () != 0) *************** *** 1176,1181 **** --- 1184,1190 ---- m_nextTxSequence + SequenceNumber (sz)); if (m_closeOnEmpty && (remainingData == 0)) { + m_finSequence=m_nextTxSequence + SequenceNumber(1 + sz); flags = TcpHeader::FIN; m_state = FIN_WAIT_1; } *** tcp-socket-impl.h.orig Fri Apr 30 10:56:13 2010 --- tcp-socket-impl.h Fri Apr 30 11:04:23 2010 *************** *** 202,207 **** --- 202,208 ---- //sequence info, receiver side SequenceNumber m_nextRxSequence; //next expected sequence + SequenceNumber m_finSequence; // Sequence number where fin was received //Rx buffer UnAckData_t m_bufferedData; //buffer which sorts out of sequence data //Rx buffer state