Analytical modeling of swarm intelligence in Wireless Sensor Networks