Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

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

to review the following change.


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/1

diff --git a/src/openvpn/oob_client.c b/src/openvpn/oob_client.c
index 43aee8d..74b892b 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 */
 };

 /* Build a plaintext SERVER_PROBE packet:
@@ -173,10 +174,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;
         }
     }
@@ -403,6 +410,7 @@
         }
         else
         {
+            openvpn_gettimeofday(&targets[i].sent_at, NULL);
             targets[i].destlen = destlen;
             targets[i].sent = true;
             sent_count++;
@@ -424,8 +432,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: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I375a41749060b7d006647bc27002c55436c8a8bb
Gerrit-Change-Number: 1748
Gerrit-PatchSet: 1
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

Reply via email to