|
|
| 1928 |
m_errno = ERROR_SHUTDOWN; |
1928 |
m_errno = ERROR_SHUTDOWN; |
| 1929 |
return false; |
1929 |
return false; |
| 1930 |
} |
1930 |
} |
| 1931 |
// Stop sending if we need to wait for a larger Tx window (prevent silly window syndrome) |
1931 |
|
| 1932 |
if (w < m_segmentSize && m_txBuffer.SizeFromSequence (m_nextTxSequence) > w) |
1932 |
if (w == 0) break; // window empty |
| 1933 |
{ |
1933 |
|
| 1934 |
break; // No more |
|
|
| 1935 |
} |
| 1936 |
// Nagle's algorithm (RFC896): Hold off sending if there is unacked data |
1934 |
// Nagle's algorithm (RFC896): Hold off sending if there is unacked data |
| 1937 |
// in the buffer and the amount of data to send is less than one segment |
1935 |
// in the buffer and the amount of data to send or the window size is |
| 1938 |
if (!m_noDelay && UnAckDataCount () > 0 |
1936 |
// less than one segment |
| 1939 |
&& m_txBuffer.SizeFromSequence (m_nextTxSequence) < m_segmentSize) |
1937 |
if (m_txBuffer.SizeFromSequence (m_nextTxSequence) < m_segmentSize || w < m_segmentSize ) |
| 1940 |
{ |
1938 |
if (UnAckDataCount () > 0) |
| 1941 |
NS_LOG_LOGIC ("Invoking Nagle's algorithm. Wait to send."); |
1939 |
break; |
| 1942 |
break; |
1940 |
|
| 1943 |
} |
|
|
| 1944 |
uint32_t s = std::min (w, m_segmentSize); // Send no more than window |
1941 |
uint32_t s = std::min (w, m_segmentSize); // Send no more than window |
| 1945 |
uint32_t sz = SendDataPacket (m_nextTxSequence, s, withAck); |
1942 |
uint32_t sz = SendDataPacket (m_nextTxSequence, s, withAck); |
| 1946 |
nPacketsSent++; // Count sent this loop |
1943 |
nPacketsSent++; // Count sent this loop |
|
|
| 1984 |
uint16_t |
1981 |
uint16_t |
| 1985 |
TcpSocketBase::AdvertisedWindowSize () |
1982 |
TcpSocketBase::AdvertisedWindowSize () |
| 1986 |
{ |
1983 |
{ |
| 1987 |
return std::min (m_rxBuffer.MaxBufferSize () - m_rxBuffer.Size (), (uint32_t)m_maxWinSize); |
1984 |
uint16_t w = std::min (m_rxBuffer.MaxBufferSize () - m_rxBuffer.Size (), (uint32_t)m_maxWinSize); |
|
|
1985 |
// Clark's algorithm (RFC813): close window when the buffer space is smaller |
| 1986 |
// than an MSS and smaller than its half capacity |
| 1987 |
return (w < m_segmentSize && w < m_rxBuffer.MaxBufferSize ()/2 ) ? 0 : w; |
| 1988 |
} |
1988 |
} |
| 1989 |
|
1989 |
|
| 1990 |
// Receipt of new packet, put into Rx buffer |
1990 |
// Receipt of new packet, put into Rx buffer |