Bug 2392 - Scaling window even in SYN packets
Scaling window even in SYN packets
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: tcp
pre-release
PC Linux
: P5 major
Assigned To: natale.patriciello
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-04-27 09:09 UTC by natale.patriciello
Modified: 2016-05-07 09:33 UTC (History)
2 users (show)

See Also:


Attachments
Fix the retr SYN problem (2.31 KB, patch)
2016-05-04 10:51 UTC, natale.patriciello
Details | Diff
patch to fix (2.35 KB, patch)
2016-05-05 13:26 UTC, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description natale.patriciello 2016-04-27 09:09:05 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);
Comment 1 natale.patriciello 2016-04-27 09:32:26 UTC
Fixed in 12096
Comment 2 natale.patriciello 2016-05-04 10:50:55 UTC
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?
Comment 3 natale.patriciello 2016-05-04 10:51:21 UTC
Created attachment 2410 [details]
Fix the retr SYN problem
Comment 4 Tom Henderson 2016-05-05 13:26:28 UTC
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.
Comment 5 Tom Henderson 2016-05-07 09:33:58 UTC
(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