Keep Open TCP Implementation #496

Merged
gaisser merged 23 commits from eive/fsfw:mueller/tcp-keep-open-pr into development 2021-10-18 15:13:09 +02:00
Owner

Fixes #470

This refactoring keeps the TCP connection opened until the client closes
it. It also increased the robustness of the TCP reception.

Because TCP is stream based and usually applied to newline separated
data, a special way to handle binary space packets is required.

The new SpacePacketParser class takes care of this by taking TC packet
IDs as optional start markers to parse for space packets in a given
buffer.

The refactored TCP server uses a ring buffer, a reception buffer and the
new parser to extract space packets from a stream in a safer and more robust way.
If the server is idle, it will use a configurable delay to decrease the CPU load.

A new reception mode state was introduced which could be used in the future to support newline separated data or other packet formats.

The changes were tested on Embedded Linux, Desktop Linux and Desktop Windows.

Unit tests for the new parser will follow in a separate PR

Fixes #470 This refactoring keeps the TCP connection opened until the client closes it. It also increased the robustness of the TCP reception. Because TCP is stream based and usually applied to newline separated data, a special way to handle binary space packets is required. The new SpacePacketParser class takes care of this by taking TC packet IDs as optional start markers to parse for space packets in a given buffer. The refactored TCP server uses a ring buffer, a reception buffer and the new parser to extract space packets from a stream in a safer and more robust way. If the server is idle, it will use a configurable delay to decrease the CPU load. A new reception mode state was introduced which could be used in the future to support newline separated data or other packet formats. The changes were tested on Embedded Linux, Desktop Linux and Desktop Windows. Unit tests for the new parser will follow in a separate PR
muellerr added 15 commits 2021-10-07 10:30:50 +02:00
09299802f0
TCP refactoring
This refactoring keeps the TCP connection opened until the client closes
it. It also increased the robustness of the TCP reception.

Because TCP is stream based and usually applied to newline separated
data, a special way to handle binary space packets is required.

The new SpacePacketParser class takes care of this by taking TC packet
IDs as as optional start markers to parse for space packets in a given
buffer.

The refactored TCP server uses a ring buffer, a reception buffer and the
new parser to extract space packets from a stream in a safer way.
muellerr requested review from gaisser 2021-10-07 10:31:03 +02:00
muellerr added this to the v3.0.0 milestone 2021-10-07 10:31:08 +02:00
muellerr added the
Refactor
label 2021-10-07 10:31:33 +02:00
muellerr added 2 commits 2021-10-09 13:32:04 +02:00
muellerr added 1 commit 2021-10-09 13:32:27 +02:00
Author
Owner

Added some improvements suggested by @Jakob.Meier

Added some improvements suggested by @Jakob.Meier
gaisser reviewed 2021-10-11 14:59:24 +02:00
@ -0,0 +44,4 @@
foundSize = packetSize;
}
*buffer += foundSize;
readLen += idx + foundSize;
Owner

What does readLen mean? If you add += idx you might have more bytes than the buffer size.

What does readLen mean? If you add += idx you might have more bytes than the buffer size.
Author
Owner

Total read length in buffer. If the packet does not start with the start marker, idx will be incremented until a start marker is detected. It then needs to be added on top of the found size

Total read length in buffer. If the packet does not start with the start marker, idx will be incremented until a start marker is detected. It then needs to be added on top of the found size
gaisser marked this conversation as resolved
muellerr added 1 commit 2021-10-11 18:52:59 +02:00
muellerr added 1 commit 2021-10-18 14:44:28 +02:00
muellerr added 1 commit 2021-10-18 14:58:35 +02:00
gaisser was assigned by mohr 2021-10-18 14:58:43 +02:00
muellerr added 2 commits 2021-10-18 15:07:19 +02:00
gaisser approved these changes 2021-10-18 15:12:56 +02:00
gaisser left a comment
Owner

LGTM

LGTM
gaisser merged commit dacec0c1f6 into development 2021-10-18 15:13:09 +02:00
muellerr deleted branch mueller/tcp-keep-open-pr 2021-10-18 15:15:18 +02:00
Sign in to join this conversation.
No description provided.