A distributed algorithm for virtual traffic lights with IEEE 802.11p