Skip to content

Commit b081411

Browse files
author
Arto Kinnunen
committed
Corrections from review meeting
-Rename get_latency_estimate_to_address, use rtt instead of latency -Update descriptions of added methods
1 parent a14ccad commit b081411

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

features/netsocket/InternetSocket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ int InternetSocket::leave_multicast_group(const SocketAddress &address)
114114
return modify_multicast_group(address, NSAPI_DROP_MEMBERSHIP);
115115
}
116116

117-
int InternetSocket::get_latency_estimate_to_address(const SocketAddress &address, uint32_t *latency)
117+
int InternetSocket::get_rtt_estimate_to_address(const SocketAddress &address, uint32_t *rtt_estimate)
118118
{
119119
nsapi_error_t ret;
120120
nsapi_latency_req_t ns_api_latency_req;
121121
unsigned opt_len = sizeof(nsapi_latency_req_t);
122122

123-
if (!latency) {
123+
if (!rtt_estimate) {
124124
return NSAPI_ERROR_PARAMETER;
125125
}
126126

@@ -129,8 +129,8 @@ int InternetSocket::get_latency_estimate_to_address(const SocketAddress &address
129129

130130
ret = this->getsockopt(NSAPI_SOCKET, NSAPI_LATENCY, (void *)&ns_api_latency_req, &opt_len);
131131
if (ret == NSAPI_ERROR_OK) {
132-
// success, latency found
133-
*latency = ns_api_latency_req.latency;
132+
// success, latency found. Convert to RTT.
133+
*rtt_estimate = ns_api_latency_req.latency * 2;
134134
}
135135

136136
return ret;

features/netsocket/InternetSocket.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,30 @@ class InternetSocket : public Socket {
8686
*/
8787
int leave_multicast_group(const SocketAddress &address);
8888

89-
/** Get estimated latency to reach destination address.
89+
/** Get estimated round trip time to destination address.
9090
*
91-
* @param address Destination address to estimate latency.
92-
* @param latency Returned latency value in milliseconds.
91+
* Use estimated round trip time to adjust application retry timers to work in networks
92+
* that have low data rate and high latency.
93+
*
94+
* @param address Destination address to use in rtt estimate.
95+
* @param rtt_estimate Returned round trip time value in milliseconds.
9396
* @return NSAPI_ERROR_OK on success.
9497
* @return NSAPI_ERROR_PARAMETER if the provided pointer is invalid.
9598
* @return negative error code on other failures (@see InternetSocket::getsockopt).
9699
*/
97-
int get_latency_estimate_to_address(const SocketAddress &address, uint32_t *latency);
100+
int get_rtt_estimate_to_address(const SocketAddress &address, uint32_t *rtt_estimate);
98101

99-
/** Get estimated stagger value to reach destination address.
102+
/** Get estimated stagger value.
103+
*
104+
* Stagger value is a time that application should wait before using heavy network operations after connecting to network.
105+
* Purpose of staggering is to avoid network congestion that may happen in low bandwith networks if multiple
106+
* applications simultaneously start heavy network usage after joining to the network.
100107
*
101-
* @param address Address to estimate stagger values.
108+
* @param address Destination added used to estimate stagger value.
102109
* @param data_amount Amount of bytes to transfer in kilobytes.
103110
* @param stagger_min Minimum stagger value in seconds.
104111
* @param stagger_max Maximum stagger value in seconds.
105-
* @param stagger_rand Randomized stagger value in seconds.
112+
* @param stagger_rand Randomized stagger value between stagger_min and stagger_max in seconds.
106113
* @return NSAPI_ERROR_OK on success.
107114
* @return negative error code on other failures (@see InternetSocket::getsockopt).
108115
*/

0 commit comments

Comments
 (0)