Optimal range estimation for energy efficient dynamic packet size