|
600 |
NS_LOG_LOGIC ("txBufSize=" << m_txBuffer->Size () << " state " << TcpStateName[m_state]); |
600 |
NS_LOG_LOGIC ("txBufSize=" << m_txBuffer->Size () << " state " << TcpStateName[m_state]); |
601 |
if (m_state == ESTABLISHED || m_state == CLOSE_WAIT) |
601 |
if (m_state == ESTABLISHED || m_state == CLOSE_WAIT) |
602 |
{ // Try to send the data out |
602 |
{ // Try to send the data out |
603 |
SendPendingData (m_connected); |
603 |
if (!m_sendPendingDataEvent.IsRunning ()) |
|
|
604 |
{ |
605 |
m_sendPendingDataEvent = Simulator::Schedule ( TimeStep (1), &TcpSocketBase::SendPendingData, this, m_connected); |
606 |
} |
604 |
} |
607 |
} |
605 |
return p->GetSize (); |
608 |
return p->GetSize (); |
606 |
} |
609 |
} |
|
947 |
NS_LOG_LOGIC (this << " Leaving zerowindow persist state"); |
950 |
NS_LOG_LOGIC (this << " Leaving zerowindow persist state"); |
948 |
m_persistEvent.Cancel (); |
951 |
m_persistEvent.Cancel (); |
949 |
} |
952 |
} |
950 |
m_rWnd = tcpHeader.GetWindowSize (); |
953 |
m_rWnd = (uint32_t(tcpHeader.GetWindowSize ()) << m_rcvScaleFactor); |
951 |
m_rWnd <<= m_rcvScaleFactor; |
|
|
952 |
|
954 |
|
953 |
// Discard fully out of range data packets |
955 |
// Discard fully out of range data packets |
954 |
if (packet->GetSize () |
956 |
if (packet->GetSize () |
|
1051 |
NS_LOG_LOGIC (this << " Leaving zerowindow persist state"); |
1053 |
NS_LOG_LOGIC (this << " Leaving zerowindow persist state"); |
1052 |
m_persistEvent.Cancel (); |
1054 |
m_persistEvent.Cancel (); |
1053 |
} |
1055 |
} |
1054 |
m_rWnd = tcpHeader.GetWindowSize (); |
1056 |
m_rWnd = (uint32_t(tcpHeader.GetWindowSize ()) << m_rcvScaleFactor); |
1055 |
m_rWnd <<= m_rcvScaleFactor; |
|
|
1056 |
|
1057 |
|
1057 |
// Discard fully out of range packets |
1058 |
// Discard fully out of range packets |
1058 |
if (packet->GetSize () |
1059 |
if (packet->GetSize () |
|
2063 |
if (m_txBuffer->Size () == 0) |
2064 |
if (m_txBuffer->Size () == 0) |
2064 |
{ |
2065 |
{ |
2065 |
return false; // Nothing to send |
2066 |
return false; // Nothing to send |
2066 |
|
|
|
2067 |
} |
2067 |
} |
2068 |
if (m_endPoint == 0 && m_endPoint6 == 0) |
2068 |
if (m_endPoint == 0 && m_endPoint6 == 0) |
2069 |
{ |
2069 |
{ |
|
2074 |
while (m_txBuffer->SizeFromSequence (m_nextTxSequence)) |
2074 |
while (m_txBuffer->SizeFromSequence (m_nextTxSequence)) |
2075 |
{ |
2075 |
{ |
2076 |
uint32_t w = AvailableWindow (); // Get available window size |
2076 |
uint32_t w = AvailableWindow (); // Get available window size |
2077 |
NS_LOG_LOGIC ("TcpSocketBase " << this << " SendPendingData" << |
|
|
2078 |
" w " << w << |
2079 |
" rxwin " << m_rWnd << |
2080 |
" segsize " << m_segmentSize << |
2081 |
" nextTxSeq " << m_nextTxSequence << |
2082 |
" highestRxAck " << m_txBuffer->HeadSequence () << |
2083 |
" pd->Size " << m_txBuffer->Size () << |
2084 |
" pd->SFS " << m_txBuffer->SizeFromSequence (m_nextTxSequence)); |
2085 |
// Stop sending if we need to wait for a larger Tx window (prevent silly window syndrome) |
2077 |
// Stop sending if we need to wait for a larger Tx window (prevent silly window syndrome) |
2086 |
if (w < m_segmentSize && m_txBuffer->SizeFromSequence (m_nextTxSequence) > w) |
2078 |
if (w < m_segmentSize && m_txBuffer->SizeFromSequence (m_nextTxSequence) > w) |
2087 |
{ |
2079 |
{ |
|
|
2080 |
NS_LOG_LOGIC ("Preventing Silly Window Syndrome. Wait to send."); |
2088 |
break; // No more |
2081 |
break; // No more |
2089 |
} |
2082 |
} |
2090 |
// Nagle's algorithm (RFC896): Hold off sending if there is unacked data |
2083 |
// Nagle's algorithm (RFC896): Hold off sending if there is unacked data |
|
2095 |
NS_LOG_LOGIC ("Invoking Nagle's algorithm. Wait to send."); |
2088 |
NS_LOG_LOGIC ("Invoking Nagle's algorithm. Wait to send."); |
2096 |
break; |
2089 |
break; |
2097 |
} |
2090 |
} |
|
|
2091 |
NS_LOG_LOGIC ("TcpSocketBase " << this << " SendPendingData" << |
2092 |
" w " << w << |
2093 |
" rxwin " << m_rWnd << |
2094 |
" segsize " << m_segmentSize << |
2095 |
" nextTxSeq " << m_nextTxSequence << |
2096 |
" highestRxAck " << m_txBuffer->HeadSequence () << |
2097 |
" pd->Size " << m_txBuffer->Size () << |
2098 |
" pd->SFS " << m_txBuffer->SizeFromSequence (m_nextTxSequence)); |
2098 |
uint32_t s = std::min (w, m_segmentSize); // Send no more than window |
2099 |
uint32_t s = std::min (w, m_segmentSize); // Send no more than window |
2099 |
uint32_t sz = SendDataPacket (m_nextTxSequence, s, withAck); |
2100 |
uint32_t sz = SendDataPacket (m_nextTxSequence, s, withAck); |
2100 |
nPacketsSent++; // Count sent this loop |
2101 |
nPacketsSent++; // Count sent this loop |
|
2119 |
} |
2120 |
} |
2120 |
|
2121 |
|
2121 |
uint32_t |
2122 |
uint32_t |
2122 |
TcpSocketBase::Window () |
|
|
2123 |
{ |
2124 |
NS_LOG_FUNCTION (this); |
2125 |
return m_rWnd; |
2126 |
} |
2127 |
|
2128 |
uint32_t |
2129 |
TcpSocketBase::AvailableWindow () |
2123 |
TcpSocketBase::AvailableWindow () |
2130 |
{ |
2124 |
{ |
2131 |
NS_LOG_FUNCTION_NOARGS (); |
2125 |
NS_LOG_FUNCTION_NOARGS (); |
|
2313 |
m_retxEvent.Cancel (); |
2307 |
m_retxEvent.Cancel (); |
2314 |
} |
2308 |
} |
2315 |
// Try to send more data |
2309 |
// Try to send more data |
2316 |
SendPendingData (m_connected); |
2310 |
if (!m_sendPendingDataEvent.IsRunning ()) |
|
|
2311 |
{ |
2312 |
m_sendPendingDataEvent = Simulator::Schedule ( TimeStep (1), &TcpSocketBase::SendPendingData, this, m_connected); |
2313 |
} |
2317 |
} |
2314 |
} |
2318 |
|
2315 |
|
2319 |
// Retransmit timeout |
2316 |
// Retransmit timeout |
|
2450 |
m_delAckEvent.Cancel (); |
2447 |
m_delAckEvent.Cancel (); |
2451 |
m_lastAckEvent.Cancel (); |
2448 |
m_lastAckEvent.Cancel (); |
2452 |
m_timewaitEvent.Cancel (); |
2449 |
m_timewaitEvent.Cancel (); |
|
|
2450 |
m_sendPendingDataEvent.Cancel (); |
2453 |
} |
2451 |
} |
2454 |
|
2452 |
|
2455 |
/* Move TCP to Time_Wait state and schedule a transition to Closed state */ |
2453 |
/* Move TCP to Time_Wait state and schedule a transition to Closed state */ |
|
2604 |
{ |
2602 |
{ |
2605 |
m_winScalingEnabled = true; |
2603 |
m_winScalingEnabled = true; |
2606 |
ProcessOptionWScale (header.GetOption (TcpOption::WINSCALE)); |
2604 |
ProcessOptionWScale (header.GetOption (TcpOption::WINSCALE)); |
|
|
2605 |
ScaleSsThresh (m_sndScaleFactor); |
2607 |
} |
2606 |
} |
2608 |
} |
2607 |
} |
2609 |
} |
2608 |
} |