Bugzilla – Bug 2392
Scaling window even in SYN packets
Last modified: 2016-05-07 09:33:58 UTC
RFC says that SYN packets advertised window should not be scaled. In the rush for ns-3.25 we didn't follow this rule. To check, the patch to the test is the following: diff --git i/src/internet/test/tcp-wscaling-test.cc w/src/internet/test/tcp-wscaling-test.cc index 3ed70d2..8f5af35 100644 --- i/src/internet/test/tcp-wscaling-test.cc +++ w/src/internet/test/tcp-wscaling-test.cc @@ -138,6 +138,15 @@ WScalingTestCase::Tx (const Ptr<const Packet> p, const TcpHeader &h, SocketWho w { NS_TEST_ASSERT_MSG_EQ (h.HasOption (TcpOption::WINSCALE), true, "wscale enabled but option disabled"); + + uint16_t advWin = h.GetWindowSize (); + uint32_t maxSize = GetRxBuffer (SENDER)->MaxBufferSize (); + + if (maxSize > 65535) + { + NS_TEST_ASSERT_MSG_EQ (advWin, 65535, + "Not advertising all window, or scaling in SYN present"); + } } if (who == SENDER) Fortunately, the fix is easy: diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index f851363..20ff233 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -2214,6 +2214,11 @@ TcpSocketBase::SendEmptyPacket (uint8_t flags) bool isAck = flags == TcpHeader::ACK; if (hasSyn) { + if (m_winScalingEnabled) + { // The window scaling option is set only on SYN packets + AddOptionWScale (header); + } + if (m_synCount == 0) { // No more connection retries, give up NS_LOG_LOGIC ("Connection failed."); @@ -3253,12 +3258,6 @@ TcpSocketBase::AddOptions (TcpHeader& header) { NS_LOG_FUNCTION (this << header); - // The window scaling option is set only on SYN packets - if (m_winScalingEnabled && (header.GetFlags () & TcpHeader::SYN)) - { - AddOptionWScale (header); - } - if (m_timestampEnabled) { AddOptionTimestamp (header);
Fixed in 12096
Tom has found that in the retransmitted SYN we send the scaled value. Here's the patch (with a little API change) that fixes it. Comments?
Created attachment 2410 [details] Fix the retr SYN problem
Created attachment 2411 [details] patch to fix The previous patch has a problem that the window may overflow when scaling argument is false. I believe that the revised patch fixes this and can be committed now.
(In reply to Tom Henderson from comment #4) > Created attachment 2411 [details] > patch to fix > > The previous patch has a problem that the window may overflow when scaling > argument is false. I believe that the revised patch fixes this and can be > committed now. updated patch committed in changeset 12103:12595e63bcbf