I've written a net device module for my research and I'm trying to run tcp simulations on it (module has been tested in a lot of scenarios to make sure there are no bugs in my module). I'm running the following simulation: I have one Access point and one station. The bulk send application is installed on the AP and is sending packets over a tcp socket. Segment size has been set to 1024 bytes for tcp socket. However, instead of receiving segments of size 1024 bytes, the station most of the times receives segments of size 512 bytes and sometimes 1024 bytes. So essentially a single 1024 byte segment is split into two segments of 512 bytes. And this does not happen all the time. Now in my simulation, there is no channel error, no packet loss, and so basically tcp's window size never falls (I've verified this). So is this normal tcp behaviour? Also, the packets enqueued at the Access point are also 512 bytes (plus header), so my module is not breaking the segments.
I tried to look into where the error might be coming from. I checked two different versions of ns 3: ns 3.20 and 3.21. Interestingly, 3.20 does not have this problem however 3.21 does. Now the one thing that changed between the two versions is the window scaling feature of tcp (found this from the release notes). I tried to look further and found the following: in tcp-socket-base.cc there is a line where the available window 'w' is being calculated. Following this, there is an if condition:
if (w < m_segmentSize && m_txBuffer.SizeFromSequence (m_nextTxSequence) > w)
{
break; // No more
}
Now in 3.21 w's value increases from 0 to 1, 10, 19 etc where as in ns 3.20 it only seems to increase in multiples of segment size i.e. 1024. When a segment of size 512 is generated, m_txBuffer.SizeFromSequence (m_nextTxSequence) 's value is 512 and w's value is also 512 so it makes sense why tcp never enters the if loop and sends a packet of size 512. Even if the segment size is set to 1500, it divides segments into 512 bytes. w is calcualted by a call to AvailableWindow() which calls Window() which returns m_rWnd. Now in DoForwardUp(), m_rWnd is changed by the following operation:
m_rWnd <<= m_rcvScaleFactor;
Now between ns 3.20 and 3.21 there is no change made to bulk send application, so this is coming from tcp-socket-base itself. Also, the above change to m_rWnd is not made in ns 3.20
Also, from the release notes it does not seem that this problem was faced/fixed in any of the following versions.
I'm having some difficulties in using my module with ns 3.24 because some of the syntax that I'm using is giving errors in ns 3.24. I'm working on it but if you could provide me with some insights on what's going or how I can fix this (if it is a bug) on that would be great and would save me lots of time on changing the syntax! Many thanks!