History log of /haiku/src/system/boot/loader/net/TCP.cpp
Revision Date Author Comments
# eb5e4560 05-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Various TCP fixes

Don't enqueue a packet whose sequence number matches the first one in queue
or is between the next and the acknowledged on. This would lead to packet
duplication in the queue and leftovers after dequeuing.

Optimize calculation of acknowledgement number for out-of-order reception.
If a single missing packet arrived, this could have resulted in a timeout
depending on the window size.

In case the connection is closed, do dequeue remaining packets. This would
have caused a read error after a unidirectional FIN.

Prepare a dynamic window size calculation.

Do checksum calculation before attempting to trace packet contents. I have
seen a few and couldn't spot an error in the checksum calculation.

More fine-grained control over trace output.
Trace the Maximum Segment Size option if present; break after End of Options.


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


# 040b3398 04-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Prepare socket-specific TCP window size

Pass the desired window size from the socket to the service.


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


# 7d415c01 04-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: TCP and UDP style cleanup

Remove superfluous comments.
Adjust spacing and initializer indentation.
Make NULL pointer checks explicit.
Don't assign in if-clause.


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


# 3bc0fcc6 01-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Fix TCP memory leaks

In some error conditions the packet would have been leaked.


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


# 6c2e0f43 31-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Mute some TCP debug output

Trace packet dequeing only when asked to.


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


# 6dfef7e9 31-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Use real_time_clock_usecs() for TCP

Initialize the PRNG seed for the sequence number with real_time_clock_usecs()
rather than system_time(). The remaining uses of system_time() for timeout
calculation match UDP.


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


# b7e825d6 30-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Add TCP support

Modelled after UDP, add limited TCP support to the boot net stack. The socket
works by queuing received packets as well as sent packets that have not yet
been ACK'ed. Some known issues are documented, especially there's only limited
congestion control. I.e., we send immediately and in unlimited quantity, thus
its use should be restricted to local networks, and due to a fixed window size
there is potential for our socket being overrun with data packets before they
are read. Some corner cases like wrapping sequence numbers may cause a timeout.

The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks",
4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs
and Wikipedia. The pseudo-random number Galois LFSR used for the sequence
number was suggested by Endre Varga.

Since the code is unlikely to get much smaller, better merge it now so that
subsequent changes get easier to review. No platform actively uses TCP sockets
yet, and the receiving code has been reviewed for endianness issues and should
terminate okay after verifying the checksum if no sockets are open.
Based on a version tested with custom code (#5240) as well as with iSCSI.
Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and
haiku_loader with gcc2. Closes ticket #5240.

Changes from #5240 proposed patch:
* Various bug fixes related to queuing, some memory leaks fixed.
* Never bump the sequence number when dequeuing a packet. It's done afterwards.
* Don't bump the sequence number again when resending the queue or ACK'ing.
* Aggressively ACK while waiting for packets.
* Don't queue sent ACK-only packets.
* More trace output, esp. for queue inspection.
* Adapted use of TCP header flags to r38434.


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


# eb5e4560028fef73b6a0a54510e7e2db570fb332 05-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Various TCP fixes

Don't enqueue a packet whose sequence number matches the first one in queue
or is between the next and the acknowledged on. This would lead to packet
duplication in the queue and leftovers after dequeuing.

Optimize calculation of acknowledgement number for out-of-order reception.
If a single missing packet arrived, this could have resulted in a timeout
depending on the window size.

In case the connection is closed, do dequeue remaining packets. This would
have caused a read error after a unidirectional FIN.

Prepare a dynamic window size calculation.

Do checksum calculation before attempting to trace packet contents. I have
seen a few and couldn't spot an error in the checksum calculation.

More fine-grained control over trace output.
Trace the Maximum Segment Size option if present; break after End of Options.


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


# 040b33980cb8a30a3676589984a24302937751ee 04-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Prepare socket-specific TCP window size

Pass the desired window size from the socket to the service.


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


# 7d415c01cc8f77666ba8264c241ee89eb9956050 04-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: TCP and UDP style cleanup

Remove superfluous comments.
Adjust spacing and initializer indentation.
Make NULL pointer checks explicit.
Don't assign in if-clause.


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


# 3bc0fcc66e9c927242db24c2f258c27a97f3025c 01-Sep-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Fix TCP memory leaks

In some error conditions the packet would have been leaked.


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


# 6c2e0f43774ec80017065ef4476955a7ac1261a1 31-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Mute some TCP debug output

Trace packet dequeing only when asked to.


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


# 6dfef7e9b2f4bc8ab8415007726b27d484bc741e 31-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Use real_time_clock_usecs() for TCP

Initialize the PRNG seed for the sequence number with real_time_clock_usecs()
rather than system_time(). The remaining uses of system_time() for timeout
calculation match UDP.


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


# b7e825d6e742817cd52eca03f6f1897452fa68e7 30-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_net: Add TCP support

Modelled after UDP, add limited TCP support to the boot net stack. The socket
works by queuing received packets as well as sent packets that have not yet
been ACK'ed. Some known issues are documented, especially there's only limited
congestion control. I.e., we send immediately and in unlimited quantity, thus
its use should be restricted to local networks, and due to a fixed window size
there is potential for our socket being overrun with data packets before they
are read. Some corner cases like wrapping sequence numbers may cause a timeout.

The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks",
4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs
and Wikipedia. The pseudo-random number Galois LFSR used for the sequence
number was suggested by Endre Varga.

Since the code is unlikely to get much smaller, better merge it now so that
subsequent changes get easier to review. No platform actively uses TCP sockets
yet, and the receiving code has been reviewed for endianness issues and should
terminate okay after verifying the checksum if no sockets are open.
Based on a version tested with custom code (#5240) as well as with iSCSI.
Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and
haiku_loader with gcc2. Closes ticket #5240.

Changes from #5240 proposed patch:
* Various bug fixes related to queuing, some memory leaks fixed.
* Never bump the sequence number when dequeuing a packet. It's done afterwards.
* Don't bump the sequence number again when resending the queue or ACK'ing.
* Aggressively ACK while waiting for packets.
* Don't queue sent ACK-only packets.
* More trace output, esp. for queue inspection.
* Adapted use of TCP header flags to r38434.


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