Time synchronization protocol for wireless sensor networks