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 channel. #508

Draft
wants to merge 155 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
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
087b9e2
Fix netdrv pointer check.
Jakio815 Jan 21, 2025
6dfabf5
Fix memory uninitialized error.
Jakio815 Jan 21, 2025
6147df6
Fix get getaddrinfo memory error.
Jakio815 Jan 21, 2025
70e9e57
Add NULL setting after freed pointer.
Jakio815 Jan 22, 2025
dd4eb91
Fix for docker tests.
Jakio815 Jan 22, 2025
11b8088
Revert "Add NULL setting after freed pointer."
Jakio815 Jan 22, 2025
51a4257
Fix ref.
Jakio815 Jan 22, 2025
a75fefc
Remove shutdown socket on close on error.
Jakio815 Jan 22, 2025
b703ab0
Fix comments.
Jakio815 Jan 22, 2025
e1e84e8
Merge branch 'networkdriver' of https://github.com/lf-lang/reactor-c …
Jakio815 Jan 22, 2025
e95f6e5
Add socket = -1 check, to check if already closed.
Jakio815 Jan 22, 2025
dccd81a
Revert "Revert "Add NULL setting after freed pointer.""
Jakio815 Jan 22, 2025
8203388
Revert "Fix for docker tests."
Jakio815 Jan 22, 2025
561e07e
Fix formatting.
Jakio815 Jan 22, 2025
16ff0c0
Revert "Revert "Fix for docker tests.""
Jakio815 Jan 22, 2025
6b8758f
Formatting.
Jakio815 Jan 22, 2025
4ca4165
Add null check for accept()
Jakio815 Jan 22, 2025
18e47ef
Minor fix on void return.
Jakio815 Jan 22, 2025
3ea4614
Formatting.
Jakio815 Jan 22, 2025
b176d0a
Move get_peer_address to accept_socket
Jakio815 Jan 22, 2025
7d2f11d
Cleanup CMake.
Jakio815 Jan 22, 2025
d54c9ad
Move static function to top.
Jakio815 Jan 22, 2025
860520f
Merge separated functions to one, without wrappers on clock related f…
Jakio815 Jan 22, 2025
fcf63ce
Code cleanup
Jakio815 Jan 23, 2025
f707321
Minor fix.
Jakio815 Jan 23, 2025
b9f4c39
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 24, 2025
35e3ce1
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 24, 2025
743ab6e
Formatting.
Jakio815 Jan 24, 2025
df90300
Add get_socket_priv_t
Jakio815 Jan 24, 2025
beea2a2
Remove unimplemented communication policies yet.
Jakio815 Jan 24, 2025
71c83f8
Remove unnecessary info.
Jakio815 Jan 24, 2025
08ff765
Fix to not use socket_id.
Jakio815 Jan 24, 2025
1d98c85
Add set my port for specified ports.
Jakio815 Jan 24, 2025
d8ab5be
Fix name to set_server_hostname
Jakio815 Jan 24, 2025
e045b1e
Add comments and function descriptions.
Jakio815 Jan 24, 2025
31e4af0
Formatting
Jakio815 Jan 24, 2025
f15eba5
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 24, 2025
786b6cc
Add comments.
Jakio815 Jan 24, 2025
4d31c94
Fix netdrv_t to a typdef of void*
Jakio815 Jan 25, 2025
015eb29
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 25, 2025
ad75179
Minor fix.
Jakio815 Jan 25, 2025
57291b9
Merge branch 'shutdown' of https://github.com/lf-lang/reactor-c into …
Jakio815 Jan 25, 2025
d4a2bcd
Revert inbound socket closes to false.
Jakio815 Jan 25, 2025
42718b6
Merge branch 'networkdriver' of github.com:lf-lang/reactor-c into net…
Jakio815 Jan 25, 2025
1e31231
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 25, 2025
eb5378a
retrigger checks
Jakio815 Jan 25, 2025
6836620
Merge branch 'shutdown' of github.com:lf-lang/reactor-c into networkd…
Jakio815 Jan 25, 2025
aca1388
Formatting.
Jakio815 Jan 25, 2025
7370d8a
Remove redundant code.
Jakio815 Jan 28, 2025
bf557ef
Add guards to add Federated for network files.
Jakio815 Jan 28, 2025
b4720bb
Minor fix.
Jakio815 Jan 28, 2025
8a4c690
Formatting.
Jakio815 Jan 28, 2025
6665157
Add reference.
Jakio815 Jan 29, 2025
0df7bfb
Remove unused libraries.
Jakio815 Jan 29, 2025
421c4f2
Fix CMake to use user input, and default value as TCP.
Jakio815 Jan 29, 2025
34cd096
Try fixing comm_type options.
Jakio815 Jan 29, 2025
c878886
Formatting.
Jakio815 Jan 29, 2025
e432043
Add check_netdrv_closed.
Jakio815 Jan 29, 2025
e07c0cf
Fix comments.
Jakio815 Jan 29, 2025
d214190
Change comments.
Jakio815 Jan 29, 2025
72791c0
Fix comments.
Jakio815 Jan 30, 2025
1f2290e
Minor fix. Remove create_clock_server, directly using create_socket_s…
Jakio815 Jan 30, 2025
6e57f4b
Remove unnecessary headers.
Jakio815 Jan 30, 2025
9358e76
Fix comments and logs.
Jakio815 Jan 30, 2025
9f79d09
Move get_peer_addr to socket_common.c for reuse.
Jakio815 Jan 31, 2025
c3ca18f
Add comments.
Jakio815 Jan 31, 2025
22f6bb8
Minor fix.
Jakio815 Jan 31, 2025
f5960ff
Minor fix on comments.
Jakio815 Jan 31, 2025
93379ce
Add `void` to functions with no parameters.
Jakio815 Feb 1, 2025
aa66b62
Change clock-sync.c name to netchan
Jakio815 Feb 24, 2025
b50ba2f
Change federate.c name to netchan
Jakio815 Feb 24, 2025
7f3ce7b
Change main.c and rti_remote.c name to netchan
Jakio815 Feb 24, 2025
3ec6ade
Change clock-sync.h, federate.h, and rti_remote.h name to netchan
Jakio815 Feb 24, 2025
e2cc858
Change net_driver.h, socket_common.h, and rti_remote.h name to netchan
Jakio815 Feb 24, 2025
dfce153
Change lf_socket_support.c and socket_common.c name to netchan
Jakio815 Feb 24, 2025
b46e98d
Minor fix.
Jakio815 Feb 24, 2025
94cfbfd
Merge branch 'shutdown' of https://github.com/lf-lang/reactor-c into …
Jakio815 Mar 4, 2025
392166f
Minor fix on wrong merge.
Jakio815 Mar 4, 2025
287bdf8
FIx merge errors.
Jakio815 Mar 6, 2025
b3dd367
Merge branch 'shutdown' of https://github.com/lf-lang/reactor-c into …
Jakio815 Mar 6, 2025
613d691
Merge branch 'main' of https://github.com/lf-lang/reactor-c into netw…
Jakio815 Mar 11, 2025
718d56d
Formatting
Jakio815 Mar 14, 2025
b95329c
Minor change.
Jakio815 Mar 14, 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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ set(PlatformLib platform)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/include/core)
include_directories(${CMAKE_SOURCE_DIR}/include/core/federated)
include_directories(${CMAKE_SOURCE_DIR}/include/core/federated/network)
include_directories(${CMAKE_SOURCE_DIR}/include/core/modal_models)
include_directories(${CMAKE_SOURCE_DIR}/include/core/platform)
include_directories(${CMAKE_SOURCE_DIR}/include/core/threaded)
Expand Down
12 changes: 10 additions & 2 deletions 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,10 +95,19 @@ 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)

if(DEFINED FEDERATED)
if(NOT DEFINED COMM_TYPE)
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)
endif()

target_include_directories(reactor-c PUBLIC ../include)
target_include_directories(reactor-c PUBLIC ../include/core)
target_include_directories(reactor-c PUBLIC ../include/core/federated)
target_include_directories(reactor-c PUBLIC ../include/core/federated/network)
target_include_directories(reactor-c PUBLIC ../include/core/platform)
target_include_directories(reactor-c PUBLIC ../include/core/modal_models)
target_include_directories(reactor-c PUBLIC ../include/core/threaded)
Expand Down
16 changes: 13 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,17 @@ 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)

if(NOT DEFINED COMM_TYPE)
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 +72,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
13 changes: 8 additions & 5 deletions core/federated/RTI/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ static void send_failed_signal(federate_info_t* fed) {
if (rti.base.tracing_enabled) {
tracepoint_rti_to_federate(send_FAILED, fed->enclave.id, NULL);
}
int failed = write_to_socket(fed->socket, bytes_to_write, &(buffer[0]));
int failed = write_to_netchan(fed->fed_netchan, bytes_to_write, &(buffer[0]));
if (failed == 0) {
LF_PRINT_LOG("RTI has sent failed signal to federate %d due to abnormal termination.", fed->enclave.id);
} else {
lf_print_error("RTI failed to send failed signal to federate %d on socket ID %d.", fed->enclave.id, fed->socket);
lf_print_error("RTI failed to send failed signal to federate %d.", fed->enclave.id);
}
}

Expand Down Expand Up @@ -234,6 +234,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 @@ -247,6 +248,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 @@ -327,9 +331,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