Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an application (hub_test) for testing the throughput of a hub or a CAN-bus #762

Merged
merged 47 commits into from
Feb 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c8b7fde
Adds the skeleton of a hub test application which will verify the per…
balazsracz Dec 23, 2023
8cbfb2a
Adds an accessor to the last expiry time of a timer.
balazsracz Dec 23, 2023
822bad7
Starts adding the send flow.
balazsracz Dec 23, 2023
0b088d2
Adds code for filling in the output frames.
balazsracz Dec 25, 2023
e0ef336
Releases packets as the receive notifications are coming in.
balazsracz Dec 25, 2023
b05236b
Adds receiver class to hub_test.
balazsracz Dec 27, 2023
9130af0
Adds constants for TCP socket options fo SO_SNDBUF and SO_RCVBUF
balazsracz Dec 29, 2023
6498441
Optimizes the memory and buffer use of the hub application.
balazsracz Dec 29, 2023
84b4808
Ensures that an executor thread can not be created twice.
balazsracz Dec 29, 2023
df96714
hub-test: Implements links and prints statistics about sent data.
balazsracz Dec 29, 2023
954956d
gc-tcp-hub: applies SO_SNDBUF and SO_RCVBUF options to sockets.
balazsracz Dec 29, 2023
a85ca9f
client connection util: exposes the file descriptor when available.
balazsracz Dec 29, 2023
8ee55a0
Limits end to end buffering in gridconnect bridge.
balazsracz Dec 29, 2023
0d0cefa
Adds a utility class for computing simple statistics.
balazsracz Dec 29, 2023
9755279
Ensures that the ClientCOnnection.cxx is built and linked.
balazsracz Dec 29, 2023
e2b9769
Sorts lines in sources.
balazsracz Dec 29, 2023
47cb981
Ensures that an executor thread can not be created twice.
balazsracz Dec 29, 2023
4bd04c6
Limits end to end buffering in gridconnect bridge.
balazsracz Dec 29, 2023
46cfb1c
fix whitespace
balazsracz Dec 29, 2023
1347885
Merge commit '4bd04c6c81b987a82f5f399bd104fb0eeb9b2f7b' into bracz-hu…
balazsracz Dec 29, 2023
304883b
Merge branch 'bracz-hub-bridge-limit-pool' into bracz-hub-test-app
balazsracz Dec 29, 2023
cad3b2e
Merge branch 'bracz-exec-multi-thread-assert' into bracz-hub-test-app
balazsracz Dec 29, 2023
567021a
Refactors the fd optimization code to FdUtils class.
balazsracz Dec 29, 2023
52bd450
Adds constants for TCP socket options fo SO_SNDBUF and SO_RCVBUF
balazsracz Dec 29, 2023
cf52f64
Optimizes the memory and buffer use of the hub application.
balazsracz Dec 29, 2023
c664b91
gc-tcp-hub: applies SO_SNDBUF and SO_RCVBUF options to sockets.
balazsracz Dec 29, 2023
06c6bb4
client connection util: exposes the file descriptor when available.
balazsracz Dec 29, 2023
f8db2a0
Ensures that the ClientCOnnection.cxx is built and linked.
balazsracz Dec 29, 2023
c573f41
Sorts lines in sources.
balazsracz Dec 29, 2023
ea41047
Refactors the fd optimization code to FdUtils class.
balazsracz Dec 29, 2023
976af9e
Makes tcp_lowat also configurable.
balazsracz Dec 29, 2023
f384215
Fix compile error.
balazsracz Dec 29, 2023
7bbc545
Adds comment.
balazsracz Dec 29, 2023
19a39e3
Merge commit 'ea41047b1bc27c2cc29e4b5ba303b9bb10096009' into bracz-hu…
balazsracz Dec 29, 2023
d3e957f
Merge branch 'bracz-optimize-tcp-socket' into bracz-hub-test-app
balazsracz Dec 29, 2023
6ffb38e
Switch gridconnect hub to LimitedPool instead of FixedPool.
balazsracz Dec 29, 2023
b2eb101
Tune TCP options.
balazsracz Dec 29, 2023
993c2b0
hubtest: tune TCP options.
balazsracz Dec 29, 2023
f52ca25
Switch gridconnect hub to LimitedPool instead of FixedPool.
balazsracz Dec 29, 2023
3e6e3ac
Tune TCP options.
balazsracz Dec 29, 2023
c6bb145
Merge branch 'bracz-optimize-tcp-socket' into bracz-hub-test-app
balazsracz Dec 29, 2023
6e31c7e
Changes TCP tuning params: no snd/recv buf limitation, but notsent_lo…
balazsracz Jan 1, 2024
781184c
Merge branch 'master' into bracz-optimize-tcp-socket
balazsracz Jan 2, 2024
e6b99c6
Merge branch 'bracz-optimize-tcp-socket' into bracz-hub-test-app
balazsracz Jan 2, 2024
a10430c
Adds new features to the hub_test:
balazsracz Jan 26, 2024
5786c59
Removes output buffer delay.
balazsracz Jan 26, 2024
91b9680
Merge branch 'master' into bracz-hub-test-app
balazsracz Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
client connection util: exposes the file descriptor when available.
Applies the gridconnect use select link option.
Applies the SO_SNDBUF/RCVBUF link option.
balazsracz committed Dec 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a85ca9f384273470a89f67e979e1eaa79955e442
77 changes: 77 additions & 0 deletions src/utils/ClientConnection.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/** \copyright
* Copyright (c) 2023, Balazs Racz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \file ClientConnection.cxx
*
* Utilities for managing can-hub connections as a client application.
*
* @author Balazs Racz
* @date 27 Dec 2023
*/

#include "utils/ClientConnection.hxx"

#include "netinet/in.h"
#include "netinet/tcp.h"
#include "nmranet_config.h"

/** Callback from try_connect to donate the file descriptor. @param fd is
* the file destriptor of the connection freshly opened. */
void GCFdConnectionClient::connection_complete(int fd)
{
struct stat statbuf;
fstat(fd, &statbuf);

const bool use_select =
(config_gridconnect_tcp_use_select() == CONSTANT_TRUE);
fd_ = fd;
const int rcvbuf = config_gridconnect_tcp_rcv_buffer_size();
if (rcvbuf > 1)
{
::setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
}
const int sndbuf = config_gridconnect_tcp_snd_buffer_size();
if (sndbuf > 1)
{
::setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf));
int ret = 0;
socklen_t retsize = sizeof(ret);
::getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &ret, &retsize);
LOG(ALWAYS, "fd %d sndbuf %d", fd, ret);
}
const int lowat = 4096;
if (lowat > 1 && S_ISSOCK(statbuf.st_mode))
{
ERRNOCHECK("tcp lowat",
::setsockopt(
fd, IPPROTO_TCP, TCP_NOTSENT_LOWAT, &lowat, sizeof(lowat)));
int ret = 0;
socklen_t retsize = sizeof(ret);
::getsockopt(fd, IPPROTO_TCP, TCP_NOTSENT_LOWAT, &ret, &retsize);
LOG(ALWAYS, "fd %d lowat %d", fd, ret);
}
create_gc_port_for_can_hub(hub_, fd, &closedNotify_, use_select);
}
15 changes: 10 additions & 5 deletions src/utils/ClientConnection.hxx
Original file line number Diff line number Diff line change
@@ -51,6 +51,10 @@ public:
* is dead. @returns true if there is a live connection. */
virtual bool ping() = 0;

/// @return the file descriptor, if this connection has one, or -1 if the
/// connection is down or doesn't have an fd.
virtual int fd() { return -1; }

virtual ~ConnectionClient()
{
}
@@ -114,18 +118,19 @@ public:
return fd_ >= 0;
}

int fd() override
{
return fd_;
}

protected:
/// Abstrct base function to attempt to connect (or open device) to the
/// destination.
virtual void try_connect() = 0;

/** Callback from try_connect to donate the file descriptor. @param fd is
* the file destriptor of the connection freshly opened. */
void connection_complete(int fd)
{
fd_ = fd;
create_gc_port_for_can_hub(hub_, fd, &closedNotify_);
}
void connection_complete(int fd);

private:
/// Will be called when the descriptor experiences an error (typivcally