androidkotlinvpn

Measure internet speed continuously in kotlin


How can i measure the internet speed (download / upload)rate continuously? like when a vpn is connected and shows the speed rate until vpn disconnects


Solution

  • The VPN is sending packets to the VPN server. The VPN knows how large those packets are and knows how much time they take to transfer. Dividing packet size by time gives you the rate.

    You would then need to decide how best to average that over some window of time (e.g., rolling one-minute average) to smooth the data out a bit.

    You might consider looking at existing open source VPN clients for some of your VPN questions and ideas for their solutions.