Optimal Routing in Dense Wireless Multihop Networks as a Geometrical Optics Solution to the Problem of Variations