diff -r 8523b98f949c examples/tcp-large-transfer.cc --- a/examples/tcp-large-transfer.cc Wed Jul 23 16:09:17 2008 -0400 +++ b/examples/tcp-large-transfer.cc Thu Jul 24 14:41:00 2008 -0400 @@ -132,6 +132,7 @@ int main (int argc, char *argv[]) ApplicationContainer apps = sink.Install (n1n2.Get (1)); apps.Start (Seconds (0.0)); + apps.Stop (Seconds (3.0)); // Create a source to send packets from n0. Instead of a full Application // and the helper APIs you might see in other example files, this example diff -r 8523b98f949c src/internet-stack/tcp-socket-impl.cc --- a/src/internet-stack/tcp-socket-impl.cc Wed Jul 23 16:09:17 2008 -0400 +++ b/src/internet-stack/tcp-socket-impl.cc Thu Jul 24 14:41:00 2008 -0400 @@ -646,13 +646,15 @@ void TcpSocketImpl::SendEmptyPacket (uin m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), m_remoteAddress); Time rto = m_rtt->RetransmitTimeout (); - if (flags & TcpHeader::SYN) + bool hasSyn = flags & TcpHeader::SYN; + bool hasFin = flags & TcpHeader::FIN; + if (hasSyn) { rto = m_cnTimeout; m_cnTimeout = m_cnTimeout + m_cnTimeout; m_cnCount--; } - if (m_retxEvent.IsExpired () ) //no outstanding timer + if (m_retxEvent.IsExpired () && (hasSyn || hasFin) ) //no outstanding timer { NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " @@ -746,6 +748,13 @@ bool TcpSocketImpl::ProcessPacketAction Ptr ipv4 = m_node->GetObject (); switch (a) { + case ACK_TX: + if(tcpHeader.GetFlags() & TcpHeader::FIN) + { + ++m_nextRxSequence; //bump this to account for the FIN + } + SendEmptyPacket (TcpHeader::ACK); + break; case SYN_ACK_TX: NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); // m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); @@ -768,19 +777,20 @@ bool TcpSocketImpl::ProcessPacketAction p, tcpHeader,fromAddress); return true; } - // This is the cloned endpoint - m_endPoint->SetPeer (m_remoteAddress, m_remotePort); - if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) - { - m_localAddress = ipv4->GetAddress (localIfIndex); - m_endPoint->SetLocalAddress (m_localAddress); - // Leave local addr in the portmap to any, as the path from - // remote can change and packets can arrive on different interfaces - //m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); - } - // TCP SYN consumes one byte - m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); - SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); + // This is the cloned endpoint + NS_ASSERT (m_state == SYN_RCVD); + m_endPoint->SetPeer (m_remoteAddress, m_remotePort); + if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) + { + m_localAddress = ipv4->GetAddress (localIfIndex); + m_endPoint->SetLocalAddress (m_localAddress); + // Leave local addr in the portmap to any, as the path from + // remote can change and packets can arrive on different interfaces + //m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); + } + // TCP SYN consumes one byte + m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); + SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); break; case ACK_TX_1: NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); @@ -845,6 +855,7 @@ bool TcpSocketImpl::ProcessPacketAction { NewRx (p, tcpHeader, fromAddress); } + ++m_nextRxSequence; //bump this to account for the FIN States_t saveState = m_state; // Used to see if app responds NS_LOG_LOGIC ("TcpSocketImpl " << this << " peer close, state " << m_state); @@ -879,7 +890,7 @@ bool TcpSocketImpl::ProcessPacketAction CommonNewAck (tcpHeader.GetAckNumber (), true); break; default: - break; + return ProcessAction (a); } return true; } diff -r 8523b98f949c src/internet-stack/tcp-typedefs.h --- a/src/internet-stack/tcp-typedefs.h Wed Jul 23 16:09:17 2008 -0400 +++ b/src/internet-stack/tcp-typedefs.h Thu Jul 24 14:41:00 2008 -0400 @@ -63,21 +63,21 @@ typedef enum { typedef enum { NO_ACT, // 0 ACK_TX, // 1 - ACK_TX_1, // ACK response to syn - RST_TX, // 2 - SYN_TX, // 3 - SYN_ACK_TX, // 4 - FIN_TX, // 5 - FIN_ACK_TX, // 6 - NEW_ACK, // 7 - NEW_SEQ_RX, // 8 - RETX, // 9 - TX_DATA, // 10 - PEER_CLOSE, // 11 - APP_CLOSED, // 12 - CANCEL_TM, // 13 - APP_NOTIFY, // 14 - Notify app that connection failed - SERV_NOTIFY, // 15 - Notify server tcp that connection completed + ACK_TX_1, // 2 - ACK response to syn + RST_TX, // 3 + SYN_TX, // 4 + SYN_ACK_TX, // 5 + FIN_TX, // 6 + FIN_ACK_TX, // 7 + NEW_ACK, // 8 + NEW_SEQ_RX, // 9 + RETX, // 10 + TX_DATA, // 11 + PEER_CLOSE, // 12 + APP_CLOSED, // 13 + CANCEL_TM, // 14 + APP_NOTIFY, // 15 - Notify app that connection failed + SERV_NOTIFY, // 16 - Notify server tcp that connection completed LAST_ACTION } Actions_t; class SA // State/Action pair