Fault tolerance in wireless sensor networks based on the gossip algorithm