The invisible ‘Race-Off’ between your devices and the Wi-Fi
written by Javin Bachani
(Image source: http://techgenix.com/wifi-connected-but-no-internet/)
Tired of lying in bed watching YouTube when suddenly the Wi-Fi signal drops and the video is left buffering? Or if you are from the OG days of dial-up connection when your sweat-inducing Diablo II session was disconnected by your mom trying to call her best friend (I was just about to defeat Andariel mom!)
Networking technology has come a long way since then. Nowadays, you can swipe through snapchat stories while listening to your friend droning on about breaking her favorite nail on call (Can’t you just text Karen!?) which is all thanks to the advancements made in networking protocol and communication technology over the years. Almost everyone is connected to the internet right from their home due to a device called a modem and its subsequent communication device called a router. Routers are a more intelligent version of a switch; they act as a communication link between your devices and the internet.
The moment you switch on your Wi-Fi signal from your phone, an epic battle of sorts begins. The radio signal from your phone magically warps through walls (and over the 2 days old smelly laundry that you were supposed to wash!). Unfortunately, your signal has ‘limited roads’ or what is called a transmission link to your router and once in a blue moon, it comes face to face with the signal from your mom’s phone who’s carrying video bytes for cute cat videos on YouTube and in this unfortunate confrontation both the signals perish. In the networking world, a single transmission link ‘town’ is not big enough for the two of them.
(Image source: http://pages.cs.wisc.edu/~suman/pubs/diagnose.pdf)
The router then, detecting spilt blood immediately ceases all communications to your phone/node to prevent further bloodshed and bam your favorite PewDiePie video starts to buffer.
This common networking protocol is called CSDMA/CA or Carrier Sense Multiple Access/ Collision Avoidance used commonly in the IEEE 802.11 MAC (media access control) protocol for wireless networks. CSMA/CA works in a defined set of stages.
· First your router/sender gets ready to transmit data packets and checks whether the channel is idle or busy.
· If the channel is busy then the station waits until the channel becomes idle.
· If the channel is idle, the station waits for an IFS/IFG (Inter-frame Space/Gap) amount of time and then sends the frame.
· After sending the frame it sets a timer.
· The station then waits for acknowledgement from the receiver, if it receives the acknowledgement before expiry of timer, it makes a successful transmission
· Otherwise the transmission fails and it waits for a back-off period and restarts the algorithm.
(Flowchart representing CSMA algorithm)
Some good tips to counter signal collision are setting up your router to use a different, mostly empty frequency like 5 GHz alongside the more commonly used 2.4 GHz Wi-Fi band to prevent overcrowding on the same frequency (Check if your router and device support those frequencies first). Even within Wi-Fi frequencies there are only certain bands of frequency that are used to transmit your signal commonly called as a channel. You can use apps like Wi-Fi analyzer to see which channels your neighbors are using and change your Wi-Fi channel to a quieter one.
But Javin I hear you ask, why doesn’t this happen over Ethernet or Wired Connections? That is a very good question. Some of you might be inclined to answer that’s because wires are a separate medium duh, so how can signals interfere there and you would only be partially right. Even wired connections can be prone to signal interference by Electromagnetic interference which is commonly termed as noise (fiber optic cables are a workable solution for this). However, the correct answer would be that’s because CSMA/CA is only used in half duplex connections like Wi-Fi whereas full duplex connections like Ethernet can make use of better and more advanced protocols like CSMA/CD (Collision Detection). Half duplex connections are those connections wherein data can be sent or received only one at a time, kind of like traffic on a one-way road but in full duplex connections, data can be transmitted as well received simultaneously (like traffic on a two-way road).
(Image Source: https://www.cwtouchkeyer.com/simplex-versus-duplex-channel-systems/)
In full duplex connections unlike half duplex, Carrier detection is used which actively looks to improve recovery time after collision and retransmits data after collision while Collision avoidance looks to simply decrease probability of collision.
In this sense Carrier detection is far more efficient at communication than Carrier Avoidance. The efficiency of CSMA/CD is given by the formula, Efficiency(η) = 1/{1 + 6.44(Tp/Tt)} where:
Tp (Propagation Delay) = Distance/Speed & Tt (transmission delay) = Packet Size/Bandwidth. Taking average values for each variable; distance = 2.5m, speed = 2.3 x 108 m/sec, Bandwidth = 100 Mbps and maximum packet size = 1522 Bytes. We get Tp = 0.0108 μsec and Tt = 128 μsec , putting these values into the formula, we get efficiency(η) = 99.94%.Thus, Carrier Detection is highly efficient for small distances and fast speeds however this is not a practical scenario as many other variables like transmission noise or larger distances were not taken into account.
Thus, the next time your Wi-Fi signal stops, you can curse the Wi-Fi for being half duplex, Carrier Avoidance for being inadequate and your mom for video-calling her best friend (Some things never change!)