Method and Apparatus for Operating a Wireless Network for Gathering Data: a Distributed Approach