-
Notifications
You must be signed in to change notification settings - Fork 3k
Add property API to InternetSocket #12522
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
Add property API to InternetSocket #12522
Conversation
* @return NSAPI_ERROR_OK on success | ||
* @return NSAPI_ERROR_UNSUPPORTED, NSAPI_ERROR_NO_CONNECTION | ||
*/ | ||
virtual nsapi_error_t get_interface_property(unsigned int data_amount, unsigned int *jitter); |
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.
Why is it needed in top level?
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.
Having API here allows application to be independent of actual interface.
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.
The ROM cost here due to the virtual methods, particularly if broken up, is significant. And these are quite specialised calls.
Therefore my inclination would be to do this via new reason codes for getsockopt
, avoiding adding anything to the vtable.
Particularly as something like RTT information may in principle be connection/remote-peer-specific, not simply a property of the interface, and the application ultimately is going to want to be working with a socket anyway.
Note that you can still have "nice wrappers" around a setsockopt, such as InternetSocket::join_multicast_group
or TLSSocket::set_hostname
(offboard implementation). They would be non-virtual, so no overhead.
f23e06c
to
52a00e2
Compare
cffa107
to
1e0e5f8
Compare
Is there need to get this information without socket creation? example setting DTLS retry timers on creation? Is the random Jitter for startup in separate pull request? |
1e0e5f8
to
db2c970
Compare
Latency and stagger helper methods added to InternetSocket. @mikter , @kjbracey-arm, @AnttiKauppila, @SeppoTakalo would you please review? |
ret = this->getsockopt(NSAPI_SOCKET, NSAPI_STAGGER, (void *)&nsapi_stagger, &opt_len); | ||
if (ret == NSAPI_ERROR_OK) { | ||
// success, stagger found | ||
*stagger_min = nsapi_stagger.stagger_min; |
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.
Should you have null checks for parameter existence so this can be called just to get the rand_value only
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.
Absolutely! Added in the next commit.
Pull request has been modified.
I don't understand the point of extending If properly documented, application may call |
@artokin What is the next action for this PR? Shall we keep it still opened or not? |
Add getsockopt options NSAPI_LATENCY and NSAPI_STAGGER to read network specific timing constraints from socket. -NS_LATENCY returns estimated latency to given address. -NSAPI_STAGGER returns estimated initial delay that application should wait before transmitting data to network. Application can use the new options to avoid network congestion by adjusting transmission delays and retry timeouts.
-Check pointer before writing to it. It allows application to ask only some of the stagger values. -Change type of data_amount in get_stagger_estimate_to_address to be uint16_t.
9f209c5
to
a14ccad
Compare
Add unit tests for added methods: -get_rtt_estimate_to_address -get_stagger_estimate_to_address
@0xc0170 , thanks for reminding. A new test case added to unit tests. I'm assuming that method descriptions would be enough and there is no need to update documentation because of these added methods. |
CI started |
Test run: SUCCESSSummary: 7 of 7 test jobs passed |
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.
Seems fine. Not 100% sure of the value of the wrapper around the socket option - stagger is a complex multivalue call, so not sure that all the pointer out parameters are really any simpler than using the socket option with the structure output. But I guess we set the precedent with the multicast options.
// Set up address | ||
memcpy(ns_api_latency_req.addr, address.get_ip_bytes(), 16); | ||
|
||
ret = this->getsockopt(NSAPI_SOCKET, NSAPI_LATENCY, (void *)&ns_api_latency_req, &opt_len); |
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.
Unnecessary cast.
CI started |
Test run: FAILEDSummary: 1 of 7 test jobs failed Failed test jobs:
|
Restarted failing CI job, seems to be OK now. |
Add getsockopt options NSAPI_LATENCY and NSAPI_STAGGER to read network specific timing constraints from socket. -NS_LATENCY returns estimated latency to given address. -NSAPI_STAGGER returns estimated initial delay that application should wait before transmitting data to network. Application can use the new options to avoid network congestion by adjusting transmission delays and retry timeouts. Add wrappers to make API usage easier: -get_rtt_estimate_to_address -get_stagger_estimate_to_address This is backport of the ARMmbed#12522
Add getsockopt options NSAPI_LATENCY and NSAPI_STAGGER to read network specific timing constraints from socket. -NS_LATENCY returns estimated latency to given address. -NSAPI_STAGGER returns estimated initial delay that application should wait before transmitting data to network. Application can use the new options to avoid network congestion by adjusting transmission delays and retry timeouts. Add wrappers to make API usage easier: -get_rtt_estimate_to_address -get_stagger_estimate_to_address This is backport of the ARMmbed#12522
Summary of changes
Add new API to network interface.
Property API allows application to ask network specific properties
from the
NetworkInterfaceInternetSocket . Queried information can be used to avoidnetwork congestion by adjusting transmission jitter and retry
timeouts.
Please note, this work is in progress.Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers
@mikter