History log of /haiku/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h
Revision Date Author Comments
# 745830a0 25-Aug-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: rfc 2018: implemented SACK option

Change-Id: I269ad2682446c4d37bae21dcf9f3036de964ff2c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/53
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 44a4bc5f 22-May-2020 Kyle Ambroff-Kao <kyle@ambroffkao.com>

tcp: Remove sanity checks from BufferQueue in release builds

Each TCPEndpoint has two BufferQueue members, one for the send queue
and one for the receive queue.

If DEBUG_BUFFER_QUEUE is enabled, then most methods of BufferQueue
call BufferQueue::Verify(), sometimes twice. This member function
performs some sanity checking which requires iterating through every
net_buffer in the queue.

Disabling this in a debug build improved throughput by a factor of 5x
over the loopback interface on my laptop. Using iperf the measured
throughput went from 900Mbps to around 4.8Gbps.

This patch turns this sanity checking off for release builds.

* Rename DEBUG_BUFFER_QUEUE to DEBUG_TCP_BUFFER_QUEUE
* Change the default in BufferQueue.h to disabled
* Set DEBUG_TCP_BUFFER_QUEUE to KDEBUG_LEVEL_2 in
kernel_debug_config.h

Change-Id: I262dac5d7e2889d2942bbdcf6b667cc0cbafa4c8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2780
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# d815bbcb 04-Oct-2017 Jérôme Duval <jerome.duval@gmail.com>

Revert "tcp: rfc 2018: implemented SACK option"

This reverts commit 5c31f5a67a0aa37c8f2a1464252b2c5b0a959f33.


# 5c31f5a6 25-Aug-2017 A-star-ayush <myselfthebest@yahoo.com>

tcp: rfc 2018: implemented SACK option

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# 965abdeb 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BufferQueue::Free() no longer will return negative values. As is, the max
bytes restriction is only a soft limit. This fixes stalling TCP connections
because everything received would be out of window once this happened.
* Added a TODO to look into TCP's window management - it doesn't seem to be
right.
* Fixed build with tracing turned on.
* Made the fNumber member of tcp_sequence private.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35468 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c21f81c1 04-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

bonefish + axeld:
* There was one incorrect check in BufferQueue::Get() that happened because
the wrong operator was used due to the uint32 cast operator.
* Consequently, we removed the uint32 cast operator, and changed the code
to deal with this. Fortunately, no other bugs were observed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3cb15e2 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied most parts of Adrian's patch in #2594, applied our coding style.
* Cleaned the net_buffer::sequence handling, and fixed a few more problems of
maintaining it in Add().
* Extended Verify() to check everything that's possible, and call it
conditionally on several places, depending on DEBUG_BUFFER_QUEUE. It's turned
on for now which means that any remaining problems should show up when they
happened.
* Call Dump() from TCPEndpoint::Dump().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc4 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ee08841 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

assorted TCP fixes.

- fixed the locking for spawned connections and accept()s.
- return EMSGSIZE if the user is trying to write more data than the send buffer can hold.
- fixed a crash when receiving a RST while the connection is being closed.
- don't wake up readers when the connection gets established.
- endpoint managers lock must be recursive to properly work with spawn'ed sockets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20727 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7edede4 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed multiple TCP issues.

- Moved FIN handling to after Segment Text handling, it matches the RFC and fixes a possible issue with a user missing some final segment data when receiving a FIN.
- Fixed the FIN handling to better terminate connections (no more senseless chatter in the end with RSTs etc).
- When Bind()ing, set the socket address so a call to getsockname() gets the allocated port correctly.
- After reaching the ESTABLISHED state, try to wake all pending threads (still needs work).
- Corrected the maximum amount of time we wait in SendData() to respect socket->send.timeout.
- Now ReadData() behaves correctly in all possible states.
- There was a missing handling of MSG_DONTWAIT, fixed.
- Better internal handling of PSH.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fcd6d8cd 04-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

keep PUSH'ed pointer in receiver side of TCP so we can wait for more data in recv()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20569 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1166a4f9 26-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Work-in-progress on TCP:
* Changed the implementation to be more BSD like; state variables are now
the same set as usual.
* The BufferQueue didn't use the initial sequence correctly (problems with
SYN sequence).
* It now also removes data out of the current data set (ie. data that was
already read by the application).
* BufferQueue::Get() also didn't work correctly (the version used by sending
data).
* Fixed various issues around the code like incorrect handling of unexpected
data.
* TCP options don't need the end-of-options marker in case they fill up the
data already, also, the end-of-options marker doesn't need to be padded.
* Options are now only processed during SYN - other options may come
later (timestamps are candidate number one).
* Also broke what was working before: connections do no longer work!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19376 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fcf0448 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Added a helper class tcp_sequence which hides the semantics of comparing sequences
(this was completely broken in the code before).
* Wrote a buffer queue class to replace the previous algorithm - instead of merging
all buffers together, they're kept in a list, so that the most work will be done
in the application's thread and only very little when the data is received; maybe
we should add an append_move() function to net_buffer, and use that instead,
though, to keep the number of fragments small.
* The advertised receive window is now bound to 65535, the receive window shift
is correctly computed, but not yet used.
* The new buffer queue is now also responsible for the send buffer.
* TCPConnection::ListenReceive() used the wrong address to retrieve the target route.
* Fixed TCPConnection::ReadData() to also return data when the connection is already
closed, and to wait if the connection is not yet established (in SO_NONBLOCK mode);
it still doesn't wait until data is available, though...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19372 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 965abdebd5f3175836079520f618977d2c889407 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BufferQueue::Free() no longer will return negative values. As is, the max
bytes restriction is only a soft limit. This fixes stalling TCP connections
because everything received would be out of window once this happened.
* Added a TODO to look into TCP's window management - it doesn't seem to be
right.
* Fixed build with tracing turned on.
* Made the fNumber member of tcp_sequence private.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35468 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c21f81c11af8beacf5804d26d62bde44bf2927fe 04-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

bonefish + axeld:
* There was one incorrect check in BufferQueue::Get() that happened because
the wrong operator was used due to the uint32 cast operator.
* Consequently, we removed the uint32 cast operator, and changed the code
to deal with this. Fortunately, no other bugs were observed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3cb15e21ee6d6793d23f809db75438fde5d8558 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied most parts of Adrian's patch in #2594, applied our coding style.
* Cleaned the net_buffer::sequence handling, and fixed a few more problems of
maintaining it in Add().
* Extended Verify() to check everything that's possible, and call it
conditionally on several places, depending on DEBUG_BUFFER_QUEUE. It's turned
on for now which means that any remaining problems should show up when they
happened.
* Call Dump() from TCPEndpoint::Dump().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# db4b6bc46caaeb073a5e176a89ea695c0b52b70e 28-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Merged _Receive() and _SegmentReceived().
* Cleanup, shuffled methods around, renamed methods, etc. - no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ee088419f8fdc733b6cb0606e2556b176316788 16-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

assorted TCP fixes.

- fixed the locking for spawned connections and accept()s.
- return EMSGSIZE if the user is trying to write more data than the send buffer can hold.
- fixed a crash when receiving a RST while the connection is being closed.
- don't wake up readers when the connection gets established.
- endpoint managers lock must be recursive to properly work with spawn'ed sockets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20727 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7edede46f377bf9b0f2710079a09f22df2771ca 09-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

fixed multiple TCP issues.

- Moved FIN handling to after Segment Text handling, it matches the RFC and fixes a possible issue with a user missing some final segment data when receiving a FIN.
- Fixed the FIN handling to better terminate connections (no more senseless chatter in the end with RSTs etc).
- When Bind()ing, set the socket address so a call to getsockname() gets the allocated port correctly.
- After reaching the ESTABLISHED state, try to wake all pending threads (still needs work).
- Corrected the maximum amount of time we wait in SendData() to respect socket->send.timeout.
- Now ReadData() behaves correctly in all possible states.
- There was a missing handling of MSG_DONTWAIT, fixed.
- Better internal handling of PSH.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20624 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fcd6d8cd9271e99bd92cf4e0b70efa8c7b984931 04-Apr-2007 Hugo Santos <hugosantos@nowhere.fake>

keep PUSH'ed pointer in receiver side of TCP so we can wait for more data in recv()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20569 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1166a4f9b5ac1afc8c89751b2f5158624173cacf 26-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Work-in-progress on TCP:
* Changed the implementation to be more BSD like; state variables are now
the same set as usual.
* The BufferQueue didn't use the initial sequence correctly (problems with
SYN sequence).
* It now also removes data out of the current data set (ie. data that was
already read by the application).
* BufferQueue::Get() also didn't work correctly (the version used by sending
data).
* Fixed various issues around the code like incorrect handling of unexpected
data.
* TCP options don't need the end-of-options marker in case they fill up the
data already, also, the end-of-options marker doesn't need to be padded.
* Options are now only processed during SYN - other options may come
later (timestamps are candidate number one).
* Also broke what was working before: connections do no longer work!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19376 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fcf044823d5325bd1b6de7c82ef170aaa86439b 25-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

* Added a helper class tcp_sequence which hides the semantics of comparing sequences
(this was completely broken in the code before).
* Wrote a buffer queue class to replace the previous algorithm - instead of merging
all buffers together, they're kept in a list, so that the most work will be done
in the application's thread and only very little when the data is received; maybe
we should add an append_move() function to net_buffer, and use that instead,
though, to keep the number of fragments small.
* The advertised receive window is now bound to 65535, the receive window shift
is correctly computed, but not yet used.
* The new buffer queue is now also responsible for the send buffer.
* TCPConnection::ListenReceive() used the wrong address to retrieve the target route.
* Fixed TCPConnection::ReadData() to also return data when the connection is already
closed, and to wait if the connection is not yet established (in SO_NONBLOCK mode);
it still doesn't wait until data is available, though...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19372 a95241bf-73f2-0310-859d-f6bbb57e9c96