I am looking to replicate the Ookla Speedtest displaying of data usage per application via the Android VPN service.
It appears they start a VPN service however they state that it is not routed through their servers.
How can this be done as you cannot initialise the VPN service with a null IP. Is there some sort of 'localhost' IP that can be used for this?
This can be done by simple packet manipulation, you will want to change the UDP and TCP packet headers to return to a new channel for the destination, in which case the channel will store a NAT session and return the packet to the appropriate place. Here's an example of something to get you started.
As for determining the application the packet originated from I have no idea how they may have done that, maybe you can check the originating socket and see if there's a way to determine what app opened the socket to begin with.
https://github.com/DrBrad/Android-VPN-to-Socket