diff --git a/examples/tcp-large-transfer.cc b/examples/tcp-large-transfer.cc index 33665b848..7d0b9cd74 100644 --- a/examples/tcp-large-transfer.cc +++ b/examples/tcp-large-transfer.cc @@ -139,7 +139,7 @@ int main (int argc, char *argv[]) // /////////////////////////////////////////////////////////////////////////// - int nBytes = 2000000; + int nBytes = 200000; uint16_t servPort = 50000; // Create a packet sink to receive these packets @@ -165,7 +165,7 @@ int main (int argc, char *argv[]) PointToPointHelper::EnablePcapAll ("tcp-large-transfer"); - Simulator::StopAt (Seconds(10)); + Simulator::StopAt (Seconds(100)); Simulator::Run (); Simulator::Destroy (); } diff --git a/src/internet-node/tcp-socket-impl.cc b/src/internet-node/tcp-socket-impl.cc index 86a24dbd3..71f771472 100644 --- a/src/internet-node/tcp-socket-impl.cc +++ b/src/internet-node/tcp-socket-impl.cc @@ -461,6 +461,10 @@ Ptr TcpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { NS_LOG_FUNCTION_NOARGS (); + if(m_bufferedData.empty()) + { + return 0; + } UnAckData_t out; //serves as buffer to return up to the user UnAckData_t::iterator i; while (!m_bufferedData.empty ()) @@ -474,7 +478,7 @@ TcpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { break; // we're done, no more in-sequence data exits } - if (i->first < m_nextRxSequence) + else // (i->first <= m_nextRxSequence) { // Two cases here. // 1) seq + length > nextRxSeq, can deliver partial // 2) seq + length <= nextRxSeq, deliver whole @@ -488,23 +492,22 @@ TcpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) // so don't do anything else and output it out[i->first] = i->second; } - else - { // At this point i->first must equal nextRxSeq - if (i->first != m_nextRxSequence) - { - NS_FATAL_ERROR ("HuH? NexRx failure, first " - << i->first << " nextRxSeq " << m_nextRxSequence); - } - } m_rxAvailable -= i->second->GetSize (); m_bufferedData.erase (i); // Remove from list } + if (out.size() == 0) + { + return 0; + } Ptr outPacket = Create(); + SocketRxAddressTag tag; //Packet AddAt* APIs don't preserve tags + out.begin()->second->PeekTag (tag); //XXX so manually copy the address tag + outPacket->AddTag (tag); for(i = out.begin(); i!=out.end(); ++i) { if (outPacket->GetSize() + i->second->GetSize() <= maxSize ) { - outPacket->AddAtEnd(i->second); + outPacket->AddAtEnd(i->second); //XXX this doesn't copy the tags } else {