I threw together a pair of shell scripts for calculating the cost of a remote using ping times. I don't know how useful this is in practice, but the theory seemed sound to me. If I'm in a hotel room with my two laptops, I'd rather annex try to get a file from the other laptop than from my NAS all the way back home. I'd love to figure out how to also detect if I'm on my VerizonWireless connection at the time and multiply the cost of all connections over the Internet accordingly, but that's down the road. Latest versions of the pair of scripts will be at https://gist.github.com/4410357. I'm interested in feedback, so please fork the git repo on gist and send me changes/updates. Also of note is that these were written for MacOSX. If you're interested in using them on a different linux, pay attention to the format of the summary line of your ping command.
You may want to use hop count, not ping times, for a rough guesstimate of distance.
Generally speaking, this is a highly non-trivial problem that's subject to university research projects so unless you find a well-maintained third party tool to solve this problem, it's unlikely that you will find a truly general solution.
Anyway, look into mtr for your distance measurements.
Richard