-
Notifications
You must be signed in to change notification settings - Fork 24
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
Jakio815
wants to merge
168
commits into
main
Choose a base branch
from
networkdriver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… close_inbound_socket()
…create_clock_server, because there are no plans using other network stacks rather than UDP.
Jakio815
commented
Jan 29, 2025
Comment on lines
+109
to
112
/** The desired port specified by the user on the command line. | ||
* This should be not moved to the net_driver, because the user can configure this as -p or --port. | ||
*/ | ||
uint16_t user_specified_port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check minor changes section in PR description for more details.
…erver for clock servers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
lf-lang/lingua-franca#2455
Summary
This PR adds a network interface layer to support interoperability in terms of network protocols, and security, using the
netdrv
.The original code is very tied up with sockets, making it hard to add different network features.
However, I clarify that this PR does not remove all socket related functions out of the main flow from the RTI and federate, for two reasons.
MSG_TYPE_ADDRESS_ADVERTISEMENT
andMSG_TYPE_ADDRESS_QUERY
uses the port and IP address in the protocol itself.We can completely take these socket-related stuff using
#ifdef COMM_TYPE_TCP
; however, I highlight that this PR is more concentrated on supporting end-to-end pluggable network security based on TCP. Thus, in this PR, I have not added the#ifdef
guards, and have not changed the protocol forMSG_TYPE_ADDRESS_ADVERTISEMENT
andMSG_TYPE_ADDRESS_QUERY
.Features
Plugin API for
network
This PR creates a separate-compiled library on the
network
instead of a part of the core runtime.I followed the prior work on
low_level_platform.h
andplatform.h
.All source files related to network is moved under
network/impl/src
, and all headers are undernetwork/api
. Also there are separateCMakelists.txt
for each.Add
COMM_TYPE
target property.The
comm-type
keyword is available in theC
target as follows.Currently only supports
TCP
, and plan to supportSST
for security.Refactoring on clock-synchronization.
There is no other reason to do clock synchronization besides UDP. So, I left all clock-sync functions to directly use UDP sockets, and refactored these functions.
rti_remote.c
and
handle_physical_clock_sync_message(): Uses boolean flag
use_UDP` when UDP socket used.clock-sync.c
handle_T4_clock_sync_message()
: Uses boolean flaguse_UDP
when UDP socket used.handle_T1_clock_sync_message()
: Usevoid* socket_or_netdrv
as parameter to support both socket and network driver.handle_address_ad()
andhandle_address_query()
There are no changes in the protocol.
As explained in the summary,
MSG_TYPE_ADDRESS_ADVERTISEMENT
andMSG_TYPE_ADDRESS_QUERY
uses port numbers and IP addresses in the protocol itself. To explain further, for physical connections or decentralized coordination, thefederateA
has to know the peerfederateB
's port number and IP address to directly connect to it. This is done byfederateA
sending aMSG_TYPE_ADDRESS_ADVERTISEMENT
to theRTI
it's port, and theRTI
sends aMSG_TYPE_ADDRESS_QUERY_REPLY
message to the peerfederateB
, including the port number and IP address. Thus, the port number and IP address itself cannot be encapsulated under the network driver layer, as it is included in the protocol.Therefore, there are some
get()
andset()
calls to the network interface.FedA
- >RTI
:MSG_TYPE_ADDRESS_ADVERTISEMENT
:FedA
callsget_my_port()
to send its own port to theRTI
.FedB
->RTI
:MSG_TYPE_ADDRESS_QUERY
: No changes.RTI
->FedB
:MSG_TYPE_ADDRESS_QUERY_REPLY
:RTI
callsget_server_port()
andget_ip_addr()
to encode it to the message to send toFedB
.FedB
: Sets the received port and IP address byset_server_port()
andset_server_host_name()
to directly connect toFedA
.Minor logic change: Move
getpeername()
logic toaccept_netdrv()
The RTI should know the connected federate(FedA)'s IP address, to pass the IP address to the other federate(FedB), as explained above.
Before, this was done in
rti_remote.c
'sreceive_and_check_fed_id_message()
. I moved this tolf_socket_support.c
'saccept_netdrv()
, because it looks more appropriate to set the connected peer's information inside this function.One inefficiency that happens is that in decentralized coordination, the server federate does not need to save the connected peer federate's IP address. However, I think this will barely affect the performance.
Add default UDP port number as 15061.
The UDP port was usually set to the
RTI's port + 1
, inrti_remote.c
'screate_server()
function call. However, I did not want to expose the port number in thecreate_server()
interface, so I took the parameterport
out fromcreate_server()
.Minor changes
start_rti_server()
function does not get theport
as a parameter. Theport
will be saved inrti_remote_t
;suser_specified_port
, with a default value when not set up.