Mobile agents for routing, topology discovery, and automatic network reconfiguration in ad-hoc networks