Aoshee / ics-openvpn

Automatically exported from code.google.com/p/ics-openvpn
0 stars 0 forks source link

High latency and packet loss over wifi #143

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My setup:
openvpn client ----> wifi router -----> vpn server
                  (192.168.1.0/24)   (10.222.222.0/24)

ping from vpn server get very high latency and suffer from packet loss while 
screen is off:
--- 10.222.222.166 ping statistics ---
155 packets transmitted, 150 received, 3% packet loss, time 154484ms
rtt min/avg/max/mdev = 61.472/1206.588/7632.653/1716.878 ms, pipe 8

but ping from local computer under the same wifi router has low latency even if 
screen is off:
--- 192.168.1.102 ping statistics ---
157 packets transmitted, 157 received, 0% packet loss, time 156271ms
rtt min/avg/max/mdev = 1.888/113.019/333.055/83.738 ms

those two ping tests are taken at the same time.

I also tested the stock vpn(PPTP), and get a much lower latency than openvpn 
while screen is off:
--- 10.222.222.11 ping statistics ---
139 packets transmitted, 139 received, 0% packet loss, time 138147ms
rtt min/avg/max/mdev = 44.855/245.766/657.210/131.596 ms

What is the expected output? What do you see instead?
Expect the latency is as same as stock vpn, and no packet loss

What mobile phone are you using?
Nexus 4

Which Android Version and stock ROM or aftermarket like cyanogenmod?
4.2.2 sotck

Original issue reported on code.google.com by chengzhicn@gmail.com on 21 Feb 2013 at 8:17

GoogleCodeExporter commented 9 years ago
Can you also provide ping statistics for openvpn server? I think your openvpn 
server might be the one which is slow.

Does this also happen if the screen is on?

Original comment by arne@rfc2549.org on 21 Feb 2013 at 9:56

GoogleCodeExporter commented 9 years ago
There is no problem while screen is on.

Here is ping statistics to openvpn server from Nexus 4 while screen is on:
--- 10.222.222.1 ping statistics ---
112 packets transmitted, 112 received, 0% packet loss, time 111232ms
rtt min/avg/max/mdev = 46.543/66.827/303.190/31.017 ms

Original comment by chengzhicn@gmail.com on 21 Feb 2013 at 1:40

GoogleCodeExporter commented 9 years ago
Okay to be honest I have no idea why it displays this behaviour. This must be 
something deep in the android OS.

Original comment by arne@rfc2549.org on 21 Feb 2013 at 2:06

GoogleCodeExporter commented 9 years ago
Here is a part of ping result(ping from vpn server and screen is off, using 
wifi):
64 bytes from 10.222.222.166: icmp_req=1198 ttl=64 time=242 ms
64 bytes from 10.222.222.166: icmp_req=1199 ttl=64 time=21220 ms
64 bytes from 10.222.222.166: icmp_req=1200 ttl=64 time=20215 ms
64 bytes from 10.222.222.166: icmp_req=1201 ttl=64 time=19215 ms
64 bytes from 10.222.222.166: icmp_req=1202 ttl=64 time=18215 ms
64 bytes from 10.222.222.166: icmp_req=1203 ttl=64 time=17215 ms
64 bytes from 10.222.222.166: icmp_req=1204 ttl=64 time=16216 ms
64 bytes from 10.222.222.166: icmp_req=1205 ttl=64 time=15216 ms
64 bytes from 10.222.222.166: icmp_req=1206 ttl=64 time=16034 ms
64 bytes from 10.222.222.166: icmp_req=1207 ttl=64 time=15035 ms
64 bytes from 10.222.222.166: icmp_req=1208 ttl=64 time=14035 ms
64 bytes from 10.222.222.166: icmp_req=1209 ttl=64 time=13035 ms
64 bytes from 10.222.222.166: icmp_req=1210 ttl=64 time=12035 ms
64 bytes from 10.222.222.166: icmp_req=1211 ttl=64 time=11036 ms
64 bytes from 10.222.222.166: icmp_req=1212 ttl=64 time=10037 ms
64 bytes from 10.222.222.166: icmp_req=1213 ttl=64 time=9039 ms
64 bytes from 10.222.222.166: icmp_req=1214 ttl=64 time=8041 ms
64 bytes from 10.222.222.166: icmp_req=1215 ttl=64 time=7041 ms
64 bytes from 10.222.222.166: icmp_req=1216 ttl=64 time=6042 ms
64 bytes from 10.222.222.166: icmp_req=1217 ttl=64 time=5042 ms
64 bytes from 10.222.222.166: icmp_req=1218 ttl=64 time=4043 ms
64 bytes from 10.222.222.166: icmp_req=1219 ttl=64 time=3044 ms
64 bytes from 10.222.222.166: icmp_req=1220 ttl=64 time=2044 ms
64 bytes from 10.222.222.166: icmp_req=1221 ttl=64 time=1051 ms
64 bytes from 10.222.222.166: icmp_req=1222 ttl=64 time=43.4 ms
64 bytes from 10.222.222.166: icmp_req=1223 ttl=64 time=412 ms
64 bytes from 10.222.222.166: icmp_req=1224 ttl=64 time=48.6 ms

But if I connect to openvpn server over mobile network(HSPA+), there is no 
latency issue, here is ping statistics from vpn server while screen is off, 
using mobile network:
--- 10.222.222.166 ping statistics ---
517 packets transmitted, 517 received, 0% packet loss, time 516509ms
rtt min/avg/max/mdev = 35.080/77.737/725.140/71.627 ms

Original comment by chengzhicn@gmail.com on 21 Feb 2013 at 2:33

GoogleCodeExporter commented 9 years ago
Oh, this bug is still not fixed. That is a broadcom wifi module issue and I 
suffer from it as well on my HTC Inspire 4G (HTC Desire HD).

http://code.google.com/p/android/issues/detail?id=9781
http://code.google.com/p/android/issues/detail?id=40065

For developers: Lock WIFI_MODE_FULL_HIGH_PERF can work on Nexuses, but it's not 
working for my device.

Original comment by ad...@prostovpn.ru on 21 Feb 2013 at 4:08

GoogleCodeExporter commented 9 years ago
I will mark the issue as invalid since this is outside of the control of the 
app.

Original comment by arne@rfc2549.org on 21 Feb 2013 at 4:11

GoogleCodeExporter commented 9 years ago
@admin
I don't think these issues are related, and it doesn't explain why stock 
vpn(PPTP) is not affected.
http://code.google.com/p/android/issues/detail?id=9781 is about wifi Power Save 
Polling, but in this case ping from local subnet is just fine.
http://code.google.com/p/android/issues/detail?id=40065 is about stops 
responding to ARP requests when screen is off, since I have already used static 
ARP entry, this is not a problem.

@arne
I have did some further tests with openvpn: using 50sec for keep-alive, and 
tcpdump on vpn server shows Nexus 4 not sending keep-live in time. In theory, 
openvpn should send keep-alive packet if there is no outgoing traffic in the 
past 50 seconds, but the interval of keep-alive packets which send by Nexus 4 
observed on the vpn server is up to 100s.

Initially I thought it might because stock vpn is running in kernel and openvpn 
is running in userlands caused the different latency. But then I did some tests 
with csipsimple, connect it to an asterisk server over wifi and set 
keep-alive(using it's own mechanism) to 50s. tcpdump on asterisk server 
indicated that all keep-alive packets send by csipsimple have exactly interval 
of 50s even screen is off.

I also tested running both csipsimple and openvpn at the same time, and set 
csipsimple's own keep-alive mechanism to 500s to keep vpn tunnel idle, but 
openvpn still not sending keep-live in time.

Original comment by chengzhicn@gmail.com on 22 Feb 2013 at 4:09

GoogleCodeExporter commented 9 years ago
That is really strange. Which protocols do csip and openvpn use? udp or tcp?

Original comment by arne@rfc2549.org on 22 Feb 2013 at 4:14

GoogleCodeExporter commented 9 years ago
Both are udp.

vpn.cap is tcpdump result on openvpn server(udp 192.168.0.1:8089), client 
address is 192.168.0.83, keep-alive is set to 50s. 'udp.length == 61' are 
keep-alive packets, others are normal data packet.

voip.cap is tcpdump result on asterisk server(udp 192.168.0.213:5060), client 
address is still 192.168.0.83, csipsimple's keep-alive is set to 50s. 
'udp.length == 10' are keep-alive packets send by csipsimple.

Original comment by chengzhicn@gmail.com on 22 Feb 2013 at 4:55

Attachments: