Added ping optimizations.

Added ping frequency as an option. As long as there is connectivity, actual ping will be performed at the specified frequency (default is 5 minutes). But if there is no connectivity, actual ping is performed every time the ping method is called.