Skip to content

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

Merged
merged 5 commits into from
Apr 28, 2020

Conversation

artokin
Copy link
Contributor

@artokin artokin commented Feb 27, 2020

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 avoid
network 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

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[x] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@mikter


@mergify mergify bot added the needs: work label Feb 27, 2020
@ciarmcom ciarmcom requested review from mikter and a team February 27, 2020 10:00
@ciarmcom
Copy link
Member

@artokin, thank you for your changes.
@mikter @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

* @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);

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@0xc0170 0xc0170 changed the title [WIP] Add property API to NetworkInterface WIP: Add property API to NetworkInterface Feb 28, 2020
@mergify mergify bot added the do not merge label Feb 28, 2020
@artokin artokin force-pushed the network_interface_property_api branch from f23e06c to 52a00e2 Compare March 3, 2020 11:12
@artokin artokin force-pushed the network_interface_property_api branch from cffa107 to 1e0e5f8 Compare March 9, 2020 15:23
@mikter
Copy link

mikter commented Mar 10, 2020

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?

@artokin artokin requested a review from kjbracey March 10, 2020 09:38
@mikter mikter requested a review from yogpan01 March 16, 2020 09:45
@artokin artokin force-pushed the network_interface_property_api branch from 1e0e5f8 to db2c970 Compare March 17, 2020 14:32
@artokin
Copy link
Contributor Author

artokin commented Mar 17, 2020

Latency and stagger helper methods added to InternetSocket.
Previous commits squashed and work rebased (won't compile with new Nanostack).

@mikter , @kjbracey-arm, @AnttiKauppila, @SeppoTakalo would you please review?

AnttiKauppila
AnttiKauppila previously approved these changes Mar 20, 2020
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;
Copy link

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

Copy link
Contributor Author

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.

@mergify mergify bot dismissed AnttiKauppila’s stale review March 20, 2020 09:33

Pull request has been modified.

@SeppoTakalo
Copy link
Contributor

I don't understand the point of extending InternetSocket API with wrappers that only call getsockopt().

If properly documented, application may call getsockopt() directly.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 14, 2020

@artokin What is the next action for this PR? Shall we keep it still opened or not?

@artokin
Copy link
Contributor Author

artokin commented Apr 14, 2020

@0xc0170 , this is waiting for new Nanostack that is coming via #12754 . Please keep this open, work will continue soon.

Arto Kinnunen added 2 commits April 17, 2020 08:55
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.
@artokin artokin force-pushed the network_interface_property_api branch from 9f209c5 to a14ccad Compare April 17, 2020 05:56
Add unit tests for added methods:
 -get_rtt_estimate_to_address
 -get_stagger_estimate_to_address
@mergify mergify bot dismissed mikter’s stale review April 23, 2020 09:01

Pull request has been modified.

@artokin
Copy link
Contributor Author

artokin commented Apr 23, 2020

@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.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 23, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Apr 23, 2020

Test run: SUCCESS

Summary: 7 of 7 test jobs passed
Build number : 4
Build artifacts

kjbracey
kjbracey previously approved these changes Apr 27, 2020
Copy link
Contributor

@kjbracey kjbracey left a 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary cast.

@mergify mergify bot dismissed kjbracey’s stale review April 27, 2020 07:26

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 27, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Apr 27, 2020

Test run: FAILED

Summary: 1 of 7 test jobs failed
Build number : 5
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_wisun-mesh-test

@artokin
Copy link
Contributor Author

artokin commented Apr 28, 2020

Restarted failing CI job, seems to be OK now.

@0xc0170 0xc0170 merged commit 58c0259 into ARMmbed:master Apr 28, 2020
@mergify mergify bot removed the ready for merge label Apr 28, 2020
artokin pushed a commit to artokin/mbed-os that referenced this pull request Apr 29, 2020
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
artokin pushed a commit to artokin/mbed-os that referenced this pull request Apr 29, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants