Closed fanpei91 closed 6 years ago
Hmm, looks wrong to me. @hbhasker, thoughts?
For reference, this was added in https://github.com/google/netstack/commit/9527cbdc82c1bc0a7c3d64eb69df039119394185#diff-04661a3cf15a0f0b7871767d7208e024R273
This is correct. What this is doing is scaling the window if window scaling was enabled. This basically stores the send window based on the advertised window in the last ack of the TCP handshake.
See from rfc 1323.
The window field (SEG.WND) in the header of every incoming segment, with the exception of SYN segments, is left-shifted by Snd.Wind.Scale bits before updating SND.WND:
SND.WND = SEG.WND << Snd.Wind.Scale
(assuming the other conditions of RFC793 are met, and using
the "C" notation "<<" for left-shift).
Oh yes, you are right!
https://github.com/google/netstack/blob/26bc1beb19b61a85b86be893b58e91b96e5a029d/tcpip/transport/tcp/connect.go#L310
Is it should be written as the following?