[S] Change in openvpn[master]: oob: Measure probe RTT for candidate-band selection

"stipa \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <9e15b991b5ac8328d52cbf3a15f5ade378ab083a-EmailReplacePatchSet-HTML@gerrit.openvpn.net>
Attention is currently required from: plaisthos.

Hello plaisthos, 

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1748?usp=email

to look at the new patch set (#5).


Change subject: oob: Measure probe RTT for candidate-band selection
......................................................................

oob: Measure probe RTT for candidate-band selection

Record each probe's round-trip time (per-target send timestamp vs reply
arrival) and feed it to oob_rank_probe_results(), where RTT forms the
candidate band: responders within the effective margin of the fastest compete
on weight, slower ones fall behind. Log the measured RTT and the effective
margin (with its source: client / server-advertised / default) at verb 4.

Before this the client never measured RTT, so every responder sat in the band
and selection was purely weighted-random; with real measurements the
latency-based candidate selection takes effect.

Change-Id: I375a41749060b7d006647bc27002c55436c8a8bb
Signed-off-by: Lev Stipakov <[email protected]>
---
M src/openvpn/oob_client.c
1 file changed, 21 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/48/1748/5

diff --git a/src/openvpn/oob_client.c b/src/openvpn/oob_client.c
index 9a53dd5..0733508 100644
--- a/src/openvpn/oob_client.c
+++ b/src/openvpn/oob_client.c
@@ -56,6 +56,7 @@
     struct sockaddr_storage dest;
     socklen_t destlen;
     bool sent;
+    struct timeval sent_at; /* when the probe was sent, for RTT measurement */
 };
 
 /* The probe uses one native socket per address family, so every remote is probed
@@ -175,10 +176,16 @@
             && addr_port_match((const struct openvpn_sockaddr *)(const void *)from,
                                (const struct openvpn_sockaddr *)(const void *)&targets[i].dest))
         {
+            struct timeval rcv;
+            openvpn_gettimeofday(&rcv, NULL);
+            long ms = (long)(rcv.tv_sec - targets[i].sent_at.tv_sec) * 1000
+                      + (rcv.tv_usec - targets[i].sent_at.tv_usec) / 1000;
+
             results[i].responded = true;
             results[i].priority = reply.priority;
             results[i].weight = reply.weight;
             results[i].max_latency_diff = reply.max_latency_diff;
+            results[i].rtt_ms = (ms > 0) ? (unsigned int)ms : 0;
             break;
         }
     }
@@ -432,6 +439,7 @@
             }
             else
             {
+                openvpn_gettimeofday(&targets[i].sent_at, NULL);
                 targets[i].destlen = destlen;
                 targets[i].sent = true;
                 sent_count++;
@@ -454,8 +462,19 @@
         if (results[i].responded)
         {
             responded++;
-            msg(D_LOW, "server-probe: %s:%s answered (priority %d, weight %d)", ce->remote,
-                ce->remote_port, results[i].priority, results[i].weight);
+            /* Effective candidate-band margin and where it came from: the
+             * client's own setting wins, else the server's advertised value,
+             * else the built-in default. */
+            int client_margin = c->options.server_probe_latency_margin;
+            int margin = oob_effective_margin(&results[i], client_margin);
+            const char *margin_src = client_margin >= 0                ? "client"
+                                     : results[i].max_latency_diff > 0 ? "server-advertised"
+                                                                       : "default";
+            msg(D_LOW,
+                "server-probe: %s:%s answered (priority %d, weight %d, rtt %u ms;"
+                " latency margin %d ms [%s])",
+                ce->remote, ce->remote_port, results[i].priority, results[i].weight,
+                results[i].rtt_ms, margin, margin_src);
         }
         else
         {

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1748?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I375a41749060b7d006647bc27002c55436c8a8bb
Gerrit-Change-Number: 1748
Gerrit-PatchSet: 5
Gerrit-Owner: stipa <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.