Bug 2963

Summary: TcpSocketBase::SetAttribute("MaxWindowSize")
Product: ns-3 Reporter: Chih-Yuan Chang <chih-yuan.chang>
Component: tcpAssignee: natale.patriciello
Status: RESOLVED INVALID    
Severity: normal CC: ns-bugs, tomh
Priority: P3    
Version: pre-release   
Hardware: All   
OS: All   

Description Chih-Yuan Chang 2018-07-26 13:42:58 UTC
I would like to set the maximum window size to 4MB.
When I use the call SetAttribute("MaxWindowSize", 4*1024*1024),
I got the following error msg.

msg="Attribute name=MaxWindowSize could not be set for this object: tid=ns3::TcpSocketBase", file=../src/core/model/object-base.cc, line=201
terminate called without an active exception



I also look at WinScale (if I may limit the scale to achieve the same purpose of 4MB max window). But I did not find applicable API.

As long as there is a reasonable way to limit the window size to 4MB, I am fine with the solution.
Comment 1 Tom Henderson 2018-07-26 15:18:53 UTC
Try:

  socket->SetAttribute ("RcvBufSize", UintegerValue (4000000));


The MaxWindowSize is limited to 16 bits (maximum size of 65535) which is why you got that error.

I am not sure whether it is meaningful to set MaxWindowSize when window scale is being used.  I would leave it alone and just manage the RX buffer size.
Comment 2 Chih-Yuan Chang 2018-07-26 15:22:05 UTC
Please confirm: If I set the Tcp RX buffer size to 4MB, I can have the same effect of limiting the max window size to 4MB?
Comment 3 Tom Henderson 2018-07-26 16:37:15 UTC
(In reply to Chih-Yuan Chang from comment #2)
> Please confirm: If I set the Tcp RX buffer size to 4MB, I can have the same
> effect of limiting the max window size to 4MB?

The advertised window is limited by the size of the receive buffer.

The advertised window is set in this method:

http://code.nsnam.org/ns-3-dev/file/f868c87528b1/src/internet/model/tcp-socket-base.cc#l3188

The specific line is:

 w = static_cast<uint32_t> (m_rxBuffer->MaxRxSequence () - m_rxBuffer->NextRxSequence ());

and the difference in sequence number is constrained by the Rx buffer size.

The remainder of the method deals with window scale and limiting the post-scaled version to the MaxWindowSize attribute.

If you want to monitor the window size, you can either enable PCAP tracing or else use the ns-3 trace source AdvWND directly:

http://code.nsnam.org/ns-3-dev/file/f868c87528b1/src/internet/model/tcp-socket-base.cc#l177