The choice of the transmission power levels adopted in Wireless Sensor Networks (WSNs) is critical to determine the performance of the network itself in terms of energy efficiency, connectivity and spatial reuse, since it has direct impact on the physical network topology. In this paper, a cooperative, lightweight and fully distributed approach is introduced to adaptively tune the transmission power of sensors in order to match local connectivity constraints. To accurately evaluate the topology control solution, a small-scale testbed based on MicaZ sensor nodes is deployed in indoor and outdoor scenarios. Practical measures on local and multi-hop connectivity, convergence time and emitted power are used to compare the proposed approach against previous solutions. Moreover, mathematical programming formulations of the topology (power) control problem are introduced to assess the optimality of the distributed algorithm. Finally, simulation analysis complements the experimental evaluation in large-scale static and mobile WSN scenarios, where a testbed implementation becomes unfeasible.