If two devices are emitting a wifi signal in the same frequency at the same time and reach an antenna at the same time, how can the data not overlap?

I mean, I know each packet is sent with a MAC address, but what about streaming?

What happen if while the router is receiving one packet, a packet from another device arrives?

How can the router know that the photons colliding with the antenna are part of the first packet or the second packet?

Or is it that the speed of light is so fast that this almost never happens and the packets are just reported as corrupt and are sent again?


Solution 1:

In a wireless network, only one device is actually "speaking" at once. Each other device listens and waits for the air on that channel to be quiet before speaking. This technique is called carrier sense multiple access with collision avoidance (CSMA/CA)

An RTS/CTS exchange helps all the nodes stay in sync efficiently by providing a way for one node to say "hey, I'm going to talk for this long so wait this long" to every other node.

@Petr Abdulin is correct but I think all Wifi networks use CSMA/CA. Old 10BaseT non-switched wired networks relied on carrier sense multiple access with collision detection (CSMA/CD). Collisions don't happen on networks where all nodes are connected to a switch.

Solution 2:

If it happens that two transmissions interfere each other (collision), then both transmissions will be corrupted and they will be retransmitted after a random delay, reducing risk of collision repeat.

Solution 3:

What happen if while the router is receiving one packet, a packet from another device arrives?

The immediate consequence is that some of the overlapping bits are corrupted. Often so many bits are corrupted that the receiver sees that the frame check sequence doesn't match up, and the receiver simply throws the bad data out and otherwise acts as if it didn't hear either packet.

Later, higher-level protocols eventually notice that a packet hasn't been acknowledged (ACK'ed) and re-send the packet.

However, the WiFi standards include many different ways of preventing such collisions, including:

  • Most versions of WiFi use COFDM or some other combination of spread-spectrum + extra error correction bits. If you are lucky only a few bits have been flipped, all of those bits can be corrected at the receiver, and one of the packets gets through without error.

  • As LawrenceC already pointed out, most versions of WiFi use carrier sense multiple access with collision avoidance (CSMA/CA): The wireless access point coordinates all the laptops communicating with it so that (usually) only one device at a time is transmitting, so (usually) there is no collision. (Sometimes you still get a collision with a packet from some other laptop trying to talk to some other wireless access point, or interference with various other devices).

what about streaming?

What about it?

When a laptop is playing streaming audio (or streaming video; roughly 5 Mbit/s for 1080p video streams), the sender sends it as a series of small packets. Modern communication hardware is fast (802.11a transmits at over 20 Mbit/s, and more recent Wi-Fi standards are even faster), so there are (relatively) long gaps between one packet to that laptop, and the next packet to the same laptop.

Between each packet there's plenty of time for the wireless access point to send packets to several other laptops, listening for the occasional packets from those laptops that ACK the previous transmissions and request the next piece of the stream, and even more occasionally re-sending packets when there is a collision or some other error.

If all of these laptops are talking to the same access point, then the access point coordinates the transmissions so only one device at a time is transmitting.

If some of these laptops are talking to one access point, and others are talking to some other (uncoordinated) access point, and all those devices are located close enough that they can easily overhear each other, then there will be frequent collisions.

Any packets that collide are re-transmitted. Typically the re-transmitted packet eventually gets through, long before it's time to play it, so no human even notices there was a problem. So (typically) every human gets the illusion of their own "continuous" dedicated stream.