Distributed algorithmic design and implementation for enabling autonomic computing over ad hoc sensor networks