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

Draft: Create network driver. #508

Draft
wants to merge 87 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
0af50a5
Add shutdown_socket()
Jakio815 Dec 20, 2024
e5129c5
Use shutdown_socket() in rti_remote.c and federate.c
Jakio815 Dec 20, 2024
1b00ed3
Fix comments.
Jakio815 Dec 20, 2024
de2fbde
Fix port type && change to print_log on shutdown failures && Refactor…
Jakio815 Dec 21, 2024
9ea9f1d
Refactor close_outbound_socket().
Jakio815 Dec 21, 2024
d9a67a2
Merge branch 'refactor-only-comm-type' into shutdown
Jakio815 Dec 21, 2024
996896c
Add comment to shutdown_socket function.
Jakio815 Dec 21, 2024
e3b0ea1
Add commnets.
Jakio815 Dec 21, 2024
30a9446
Properly replace close() to shutdown_socket()
Jakio815 Dec 21, 2024
276d7b4
Minor fix.
Jakio815 Dec 21, 2024
93adf2e
Minor fix.
Jakio815 Dec 21, 2024
d27c743
Properly close federate's socket connected to the RTI.
Jakio815 Dec 21, 2024
ef3345b
Minor fix.
Jakio815 Dec 21, 2024
311205d
Merge branch 'main' of github.com:lf-lang/reactor-c into shutdown
Jakio815 Jan 8, 2025
c0d59db
Fix merge error.
Jakio815 Jan 13, 2025
45b7f48
Move files to reactor-c/network/
Jakio815 Jan 15, 2025
536cdc7
Remove unnecessary #include on socket_common.h
Jakio815 Jan 15, 2025
684ab06
Add net_driver.
Jakio815 Jan 15, 2025
43960cf
Create CMake files to make the network related c files as a library.
Jakio815 Jan 15, 2025
6b00c23
Remove parameter from create_server()
Jakio815 Jan 15, 2025
d62bf0c
Fix create_server to use netdriver. First only fix RTI. Separate the …
Jakio815 Jan 15, 2025
fdf009c
Add initialize_netdrv()
Jakio815 Jan 15, 2025
83d92bd
Move create_server to lf_socket_support.c
Jakio815 Jan 15, 2025
ce9ee88
Fix start_rti_server() and wait_for_federates() parameters.
Jakio815 Jan 15, 2025
f02fa2a
Start fixing lf_connect_to_federates() && add accept_netdrv()
Jakio815 Jan 16, 2025
839f58b
Fix lf_connect_to_federates() to use network drivers.
Jakio815 Jan 16, 2025
6d03173
Add read() write() shutdown() functions using netdrver
Jakio815 Jan 16, 2025
9726b86
Fix send_reject() read() write() shutdown() functions on remote.c && …
Jakio815 Jan 16, 2025
418d2c9
Add get_peer_address()
Jakio815 Jan 16, 2025
32975a6
Minor fix on not using server_ip_addr
Jakio815 Jan 16, 2025
7922ae1
Minor fix on not using server_ip_addr
Jakio815 Jan 16, 2025
3bafaba
Merge branch 'networkdriver' of github.com:lf-lang/reactor-c into net…
Jakio815 Jan 16, 2025
170f923
Formatting on ifdefs.
Jakio815 Jan 16, 2025
5f3d831
Fix handle_address_query to combine the message and write() it in onc…
Jakio815 Jan 16, 2025
373a623
Add get and set functions to be used in rti_remote.c
Jakio815 Jan 16, 2025
d2d982b
Minor fix.
Jakio815 Jan 16, 2025
d647120
Revert to sending two write()s in handle_address_query()
Jakio815 Jan 16, 2025
225e0b5
Add logic in handle_address_query(), to check if the remote_fed's net…
Jakio815 Jan 16, 2025
0de9584
Update CMakeLists.txt
Jakio815 Jan 17, 2025
de83454
Update CMakeLists.txt
Jakio815 Jan 17, 2025
5cf0a47
Fixing data types to netdriver.
Jakio815 Jan 19, 2025
e190e14
Merge branch 'networkdriver' of github.com:lf-lang/reactor-c into net…
Jakio815 Jan 19, 2025
9c7c4ab
Fix names to netdriver.
Jakio815 Jan 19, 2025
aa3237e
Remove old TCP related parameters.
Jakio815 Jan 19, 2025
bfea77a
Remove old TCP related parameters.
Jakio815 Jan 19, 2025
8869278
Merge branch 'networkdriver' of github.com:lf-lang/reactor-c into net…
Jakio815 Jan 19, 2025
f8f45e2
Minor fix.
Jakio815 Jan 19, 2025
dc79adf
Set hostname and port for federate. Also move get_peer_address to bot…
Jakio815 Jan 19, 2025
56ff3be
Add create client.
Jakio815 Jan 19, 2025
7001175
Minor fix setting server port and host name.
Jakio815 Jan 19, 2025
caebf9b
Add connect to network driver.
Jakio815 Jan 19, 2025
12a88f0
Minor fix.
Jakio815 Jan 19, 2025
83cd10e
Fix all read and write namings.
Jakio815 Jan 19, 2025
9d47c70
Fix parameter on lf_send_neighbor_structure_to_RTI
Jakio815 Jan 19, 2025
4b172d1
Change socket_mutex to netdrv_mutex
Jakio815 Jan 19, 2025
9dbf5be
Remove server_type. just leave it as true false for increment on retry.
Jakio815 Jan 19, 2025
df0c3ef
Fix lf_create_server.
Jakio815 Jan 19, 2025
df2bcd5
Add setting server netdriver to federate.
Jakio815 Jan 19, 2025
6cc28d5
Fix on accept netdriver, to return NULL, when failed to accept.
Jakio815 Jan 19, 2025
bde87c4
Add free_netdrv()
Jakio815 Jan 19, 2025
96567d6
Add get_socket_id()
Jakio815 Jan 19, 2025
21d2f23
Fix on listen_to_federates and lf_connect_to_federate
Jakio815 Jan 19, 2025
255ddb3
Fix listen_to_rti_TCP to use netdriver.
Jakio815 Jan 19, 2025
a64adfc
Fix read to handle ECONNRESET errors.
Jakio815 Jan 19, 2025
89c8b07
Fix perform_hmac_authentication() to use network driver.
Jakio815 Jan 19, 2025
0e73e79
Fix all RTI sockets to network drivers.
Jakio815 Jan 19, 2025
04e71e3
Remove server socket and port from federate instance.
Jakio815 Jan 19, 2025
6a851e3
Fix peek_from_netdrv().
Jakio815 Jan 19, 2025
3149615
Remove socket_TCP_RTI
Jakio815 Jan 19, 2025
18caa30
Fix all socket to netdrivers.
Jakio815 Jan 19, 2025
ce8be14
Remove socket.h header from federate.c
Jakio815 Jan 19, 2025
2e53546
Add create_client() and connect_to_netdrv() in net_driver.h header file.
Jakio815 Jan 19, 2025
1c44f2e
Fix accept_netdrv to use accept_socket.
Jakio815 Jan 19, 2025
9e45794
Fix create_server() to call create_socket_server()
Jakio815 Jan 19, 2025
02f041b
Create UDP default port, because there can be situations not using T…
Jakio815 Jan 19, 2025
aacd379
Add logic to check the netdriver is null, when the rti_drv is not ava…
Jakio815 Jan 19, 2025
0406a02
Fis to not shutdown the netdrv, but the socket.
Jakio815 Jan 20, 2025
8f589ea
Remove comments.
Jakio815 Jan 20, 2025
36b29ee
Fix clock sync to split down network drivers with UDP.
Jakio815 Jan 20, 2025
fb46c59
Code cleanup.
Jakio815 Jan 20, 2025
4464284
Cleanup read and write functions.
Jakio815 Jan 20, 2025
d4d78a9
Rollback create socket server to one function.
Jakio815 Jan 21, 2025
5d1bf72
Minor fix and formatting.
Jakio815 Jan 21, 2025
4c6e5e7
Minor fix on clock-sync.
Jakio815 Jan 21, 2025
e0d7fd1
Fix sending clocks.
Jakio815 Jan 21, 2025
30ecc8b
Fix sending clocks.
Jakio815 Jan 21, 2025
ee8b550
Merge branch 'networkdriver' of github.com:lf-lang/reactor-c into net…
Jakio815 Jan 21, 2025
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
11 changes: 10 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ list(APPEND REACTORC_SOURCES ${GENERAL_SOURCES})
# Add sources for either threaded or single-threaded runtime
if(DEFINED FEDERATED)
include(federated/CMakeLists.txt)
include(federated/network/CMakeLists.txt)
endif()

# Add sources for either threaded or single-threaded runtime
Expand Down Expand Up @@ -96,6 +95,16 @@ include(${LF_ROOT}/platform/impl/CMakeLists.txt)
target_link_libraries(reactor-c PUBLIC lf::platform-api)
target_link_libraries(reactor-c PRIVATE lf::platform-impl)

option(COMM_TYPE "Communication type between RTI and federate(s)." ON)
IF(COMM_TYPE MATCHES ON)
set(COMM_TYPE TCP)
ENDIF()

include(${LF_ROOT}/network/api/CMakeLists.txt)
include(${LF_ROOT}/network/impl/CMakeLists.txt)
target_link_libraries(reactor-c PUBLIC lf::network-api)
target_link_libraries(reactor-c PRIVATE lf::network-impl)

target_include_directories(reactor-c PUBLIC ../include)
target_include_directories(reactor-c PUBLIC ../include/core)
target_include_directories(reactor-c PUBLIC ../include/core/federated)
Expand Down
17 changes: 14 additions & 3 deletions core/federated/RTI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ add_library(${RTI_LIB} STATIC
${CoreLib}/utils/util.c
${CoreLib}/tag.c
${CoreLib}/clock.c
${CoreLib}/federated/network/net_util.c
${CoreLib}/federated/network/socket_common.c
${CoreLib}/utils/pqueue_base.c
${CoreLib}/utils/pqueue_tag.c
${CoreLib}/utils/pqueue.c
Expand All @@ -29,14 +27,18 @@ add_executable(${RTI_MAIN} main.c)
target_include_directories(${RTI_LIB} PUBLIC ../../../include)
target_include_directories(${RTI_LIB} PUBLIC ${IncludeDir})
target_include_directories(${RTI_LIB} PUBLIC ${IncludeDir}/federated)
target_include_directories(${RTI_LIB} PUBLIC ${IncludeDir}/federated/network)
target_include_directories(${RTI_LIB} PUBLIC ${IncludeDir}/modal_models)
target_include_directories(${RTI_LIB} PUBLIC ${IncludeDir}/utils)

if (NOT DEFINED LOG_LEVEL)
set(LOG_LEVEL 0)
ENDIF(NOT DEFINED LOG_LEVEL)

# option(COMM_TYPE "Communication type between RTI and federate(s)." ON)
# IF(COMM_TYPE MATCHES ON)
set(COMM_TYPE TCP)
# ENDIF()

IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
# Set the LOG_LEVEL to 4 to get DEBUG messages
message("-- Building RTI with DEBUG messages enabled")
Expand Down Expand Up @@ -71,13 +73,22 @@ target_link_libraries(${RTI_LIB} PUBLIC lf::low-level-platform-impl)
include(${LF_ROOT}/low_level_platform/api/CMakeLists.txt)
target_link_libraries(${RTI_LIB} PUBLIC lf::low-level-platform-api)

include(${LF_ROOT}/network/impl/CMakeLists.txt)
target_link_libraries(${RTI_LIB} PUBLIC lf::network-impl)

include(${LF_ROOT}/network/api/CMakeLists.txt)
target_link_libraries(${RTI_LIB} PUBLIC lf::network-api)

# Set the STANDALONE_RTI flag to include the rti_remote and rti_common.
target_compile_definitions(${RTI_LIB} PUBLIC STANDALONE_RTI=1)

# Set FEDERATED to get federated compilation support
target_compile_definitions(${RTI_LIB} PUBLIC FEDERATED=1)
target_compile_definitions(${RTI_LIB} PUBLIC PLATFORM_${CMAKE_SYSTEM_NAME})

# Set communication type.
target_compile_definitions(${RTI_LIB} PUBLIC COMM_TYPE_${COMM_TYPE})

# Set RTI Tracing
target_compile_definitions(${RTI_LIB} PUBLIC RTI_TRACE)

Expand Down
9 changes: 6 additions & 3 deletions core/federated/RTI/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ int process_args(int argc, const char* argv[]) {
rti.base.number_of_scheduling_nodes = (int32_t)num_federates; // FIXME: Loses numbers on 64-bit machines
lf_print("RTI: Number of federates: %d", rti.base.number_of_scheduling_nodes);
} else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--port") == 0) {
#ifdef COMM_TYPE_TCP
if (argc < i + 2) {
lf_print_error("--port needs a short unsigned integer argument ( > 0 and < %d).", UINT16_MAX);
usage(argc, argv);
Expand All @@ -246,6 +247,9 @@ int process_args(int argc, const char* argv[]) {
return 0;
}
rti.user_specified_port = (uint16_t)RTI_port;
#else
lf_print_error("--port is only available for TCP.");
#endif
} else if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--clock_sync") == 0) {
if (argc < i + 2) {
lf_print_error("--clock-sync needs off|init|on.");
Expand Down Expand Up @@ -324,9 +328,8 @@ int main(int argc, const char* argv[]) {
rti.base.scheduling_nodes[i] = (scheduling_node_t*)fed_info;
}

int socket_descriptor = start_rti_server(rti.user_specified_port);
if (socket_descriptor >= 0) {
wait_for_federates(socket_descriptor);
if (!start_rti_server()) {
wait_for_federates();
normal_termination = true;
if (rti.base.tracing_enabled) {
// No need for a mutex lock because all threads have exited.
Expand Down
Loading
Loading