Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
4  
That is called a collision. Both packets are lost. – vonbrand Feb 27 '13 at 4:15
up vote 20 down vote accepted

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.

share|improve this answer
4  
Mostly correct, except it's possible for the collisions to happen with CSMA/CA. Consider three devices A, B and C, where A and C are too far from each other to receive each other's data, but B is between them and can receive from either. A and C cannot detect collisions (as far as they are concerned, there are none), but B will not be able to receive data from either of them, unless one happens to be silent. – George Skoptsov Feb 27 '13 at 4:38
    
@GeorgeSkoptsov - Of course its still possible for a collision, if collisions were not possible, everything would be wireless since there wouldn't be any packet loss. – Ramhound Feb 27 '13 at 13:17
4  
@Ramhound - Collision is not the primary reason there is packet loss, and packet loss is not the primary reason not everything is wireless. – George Skoptsov Feb 27 '13 at 15:19

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.

share|improve this answer

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.

share|improve this answer
    
Remind me never to write wireless router firmware, it sounds excruciatingly painful. – cat Feb 13 at 4:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .