Services and Algorithms for Sensor Networks  a Theoretical Perspective