Skip to contentSkip to conversation

Need help for adding feature: Selecting remote servers by best latency

Openvpn-devel Paul Garnier 6 participants 6 messages May 11, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

I’m actually trying to add an option in openvpn which will allow the client to connect to the server with the lowest latency in his remote list. For now there are only two options to choose between servers : “ *--remote-random*” which randomize the order of the address list, the default one which will try the hosts in the order of the config file, and I want to add a 3rd one. To start I want to do it for udp and unix servers and clients.

I’m a beginner in things like this so I started very simply : I wrote a little program in C to ping a host:port using udp but I can’t get an answer from an openvpn server. The only way I found to get an answer was to make the packet I send look like the start of a TLS transaction, but because of the TLS processing I can only get the first ping right, after it takes way too long to come back to be accurate.

So I started digging in the source code to find where my packet is thrown away and why I don’t get any answer (even an error message would be enough). I’ve found how a “normal” packet is sent but what I want is the latency with the server, not in the tunnel. I don’t want to establish a connection to test my link with each server and, how I understand it, if I want use function like *encrypt_sign*() so my packet is recognized I need to have a tunnel set. I can’t replicate how the existing *ping *and *occ *packets
are sent.

What I would like to know is :

- where my packet is processed and rejected ?

- why I don't get any answer at all nor an error message on my server ?

- is there a major issue making what I want to do impossible ?

Kind regards,

Paul Garnier

#1 lore raw

Why try to connect to the process itself? I think a standard ICMP ping to the server address should be sufficient for your test.

---
Eric F Crist

Quoted 49 lines · Paul Garnier

Hello,

I’m actually trying to add an option in openvpn which will allow the client to connect to the server with the lowest latency in his remote list. For now there are only two options to choose between servers :
“--REMOTE-RANDOM” which randomize the order of the address list, the default one which will try the hosts in the order of the config file, and I want to add a 3rd one. To start I want to do it for udp and unix servers and clients.

I’m a beginner in things like this so I started very simply : I wrote a little program in C to ping a host:port using udp but I can’t get an answer from an openvpn server. The only way I found to get an answer was to make the packet I send look like the start of a TLS transaction, but because of the TLS processing I can only get the first ping right, after it takes way too long to come back to be accurate.

So I started digging in the source code to find where my packet is thrown away and why I don’t get any answer (even an error message would be enough). I’ve found how a “normal” packet is sent but what I want is the latency with the server, not in the tunnel. I don’t want to establish a connection to test my link with each server and, how I understand it, if I want use function like ENCRYPT_SIGN() so my packet is recognized I need to have a tunnel set. I can’t replicate how the existing PING and OCC packets are sent.

What I would like to know is :

- where my packet is processed and rejected ?

- why I don't get any answer at all nor an error message on my server ?

- is there a major issue making what I want to do impossible ?

Kind regards,

Paul Garnier
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw
Quoted 2 lines · Eric F Crist

Why try to connect to the process itself? I think a standard ICMP ping to the server address should be sufficient for your test.

This implies that the OpenVPN servers respond to ICMP echo requests, and that there is no "firewall" in between which lets ICMP pass but not OpenVPN connections.

I think it makes a lot of sense to probe servers using a real connect - even though it usually takes longer time ... and it will be far more complex process all in all.

Signature · 3 lines
kind regards,

David Sommerseth
Quoted 64 lines · Paul Garnier
Quoted 38 lines

Hello,

I’m actually trying to add an option in openvpn which will allow the client to connect to the server with the lowest latency in his remote list. For now there are only two options to choose between servers :
“--REMOTE-RANDOM” which randomize the order of the address list, the default one which will try the hosts in the order of the config file, and I want to add a 3rd one. To start I want to do it for udp and unix servers and clients.

I’m a beginner in things like this so I started very simply : I wrote a little program in C to ping a host:port using udp but I can’t get an answer from an openvpn server. The only way I found to get an answer was to make the packet I send look like the start of a TLS transaction, but because of the TLS processing I can only get the first ping right, after it takes way too long to come back to be accurate.

So I started digging in the source code to find where my packet is thrown away and why I don’t get any answer (even an error message would be enough). I’ve found how a “normal” packet is sent but what I want is the latency with the server, not in the tunnel. I don’t want to establish a connection to test my link with each server and, how I understand it, if I want use function like ENCRYPT_SIGN() so my packet is recognized I need to have a tunnel set. I can’t replicate how the existing PING and OCC packets are sent.

What I would like to know is :

- where my packet is processed and rejected ?

- why I don't get any answer at all nor an error message on my server ?

- is there a major issue making what I want to do impossible ?

Kind regards,

Quoted 13 lines

Paul Garnier
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw
In reply to Paul Garnier

how are you going to resolve

a) host.example.com resolves in multiple "A" records
b) host.example.com resolves in both "AAAA" and "A" records

?

2016-05-11 20:41 GMT+05:00 Paul Garnier <[email protected]...>:

Quoted 58 lines

Hello,

I’m actually trying to add an option in openvpn which will allow the client to connect to the server with the lowest latency in his remote list. For now there are only two options to choose between servers : “ *--remote-random*” which randomize the order of the address list, the default one which will try the hosts in the order of the config file, and I want to add a 3rd one. To start I want to do it for udp and unix servers and clients.

I’m a beginner in things like this so I started very simply : I wrote a little program in C to ping a host:port using udp but I can’t get an answer from an openvpn server. The only way I found to get an answer was to make the packet I send look like the start of a TLS transaction, but because of the TLS processing I can only get the first ping right, after it takes way too long to come back to be accurate.

So I started digging in the source code to find where my packet is thrown away and why I don’t get any answer (even an error message would be enough). I’ve found how a “normal” packet is sent but what I want is the latency with the server, not in the tunnel. I don’t want to establish a connection to test my link with each server and, how I understand it, if I want use function like *encrypt_sign*() so my packet is recognized I need to have a tunnel set. I can’t replicate how the existing *ping *and *occ *packets are sent.

What I would like to know is :

- where my packet is processed and rejected ?

- why I don't get any answer at all nor an error message on my server ?

- is there a major issue making what I want to do impossible ?

Kind regards,

Paul Garnier

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#4 lore raw

I think he will map:
host.example.com -> a.a.a.a

                 -> b.b.b.b
                 -> c.c.c.c
and/or
host.example.com -> aaaa.aaaa.ipv6
                 -> bbbb.bbbb.ipv6
                 -> b.b.b.b

Make some kind of a table kept in temporary memory / RAM / disk with all values (ip addresses) probe them individually with real tcp connections, assign a 'latency' value to each entry in the table and sort the final result by selecting the entry with lowest 'latency' value.

This can be quite time consuming there are many servers to probe, and sane values should be chosen for timeouts and max retries as well as trying v6 servers or not (maybe the client can't even reach v6 hosts) otherwise this can lead to and endless loop.

Quoted 59 lines · Илья Шипицин

how are you going to resolve

a) host.example.com <http://host.example.com> resolves in multiple "A" records
b) host.example.com <http://host.example.com> resolves in both "AAAA" and "A" records

?

2016-05-11 20:41 GMT+05:00 Paul Garnier <[email protected]... <mailto:[email protected]...>>:

Hello,

I’m actually trying to add an option in openvpn which will allow the client to connect to the server with the lowest latency in his remote list. For now there are only two options to choose between servers : “*--remote-random*” which randomize the order of the address list, the default one which will try the hosts in the order of the config file, and I want to add a 3^rd one. To start I want to do it for udp and unix servers and clients.

I’m a beginner in things like this so I started very simply : I wrote a little program in C to ping a host:port using udp but I can’t get an answer from an openvpn server. The only way I found to get an answer was to make the packet I send look like the start of a TLS transaction, but because of the TLS processing I can only get the first ping right, after it takes way too long to come back to be accurate.

So I started digging in the source code to find where my packet is thrown away and why I don’t get any answer (even an error message would be enough). I’ve found how a “normal” packet is sent but what I want is the latency with the server, not in the tunnel. I don’t want to establish a connection to test my link with each server and, how I understand it, if I want use function like *encrypt_sign*() so my packet is recognized**I need to have a tunnel set. I can’t replicate how the existing *ping *and *occ *packets are sent.

What I would like to know is :

- where my packet is processed and rejected ?

- why I don't get any answer at all nor an error message on my server ?

- is there a major issue making what I want to do impossible ?

Kind regards,

Paul Garnier

#5 lore raw
In reply to Илья Шипицин

hi,

Quoted 6 lines · ???????? ??????????????

how are you going to resolve

a) host.example.com resolves in multiple "A" records
b) host.example.com resolves in both "AAAA" and "A" records

?

By treating them the way the current code effectively does - "multiple remote servers"

You do not really need to distinguish between "2x remote in the config" vs. "1x remote in the config which points to 2x A records" - find out which one is the fastest, and use that.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...