summaryrefslogtreecommitdiff
path: root/nocompile/bin/ipdist.sh
blob: ca9769634d259c5cb60ab49ede58d29ee948a3f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
if [ "_$1" = "_" -o "_$2" = "_" ];then
 echo "usage: $0 hostA hostB"
 exit
fi

#constants for now.
c=299.792458 #km/ms of light in vacuum
iof=1.4475 #picked the higher of two from wikipedia.
# http://en.wikipedia.org/wiki/Optical_fiber#Index_of_refraction

ipA=$(gethostbyname "$1")
ipB=$(gethostbyname "$2")
A=$(whob "$ipA" | egrep "^Lat|^Lon" | cut '-d ' -f2 | tr '\n' ' ')
B=$(whob "$ipB" | egrep "^Lat|^Lon" | cut '-d ' -f2 | tr '\n' ' ')
km=$(echo "$A" "$B" \
  | geod +ellps=clrk66 -I +units=km \
  | cut -f3)
ms=$(printf '%s / %s * %s\n' "$km" "$c" "$iof" | bc)

echo "ipA: $ipA"
echo "ipB: $ipB"
echo "c: $c"
echo "iof: $iof"
echo "km: $km"
echo "ms: $ms"