{"id":846,"date":"2011-03-08T21:41:02","date_gmt":"2011-03-08T20:41:02","guid":{"rendered":"http:\/\/www.stenyak.com\/?p=846"},"modified":"2011-03-08T21:41:02","modified_gmt":"2011-03-08T20:41:02","slug":"surfing-the-electromagnetic-waves-debugging-ieee-802-11-with-wi-spy","status":"publish","type":"post","link":"https:\/\/www.stenyak.com\/?p=846","title":{"rendered":"Surfing the electromagnetic waves &#8211; Debugging IEEE 802.11 with Wi-Spy"},"content":{"rendered":"<p>Some months ago, when I moved to this house, I found it was pretty difficult to get any WiFi device to connect to my wireless home network. Recently I tried debugging it, and these are the results&#8230;<\/p>\n<p>&nbsp;<\/p>\n<h2>Finding a proper WiFi channel<\/h2>\n<p>Finding an appropriate WiFi channel is part of the usual initial setup. Some routers and APs can choose channels automatically, but that&#8217;s not my case, so I had to resort to third party applications.\u00a0One of my favourites is <a class=\"vt-p\" href=\"https:\/\/market.android.com\/details?id=com.farproc.wifi.analyzer\">Wifi Analyzer<\/a> for Android, which looks like this:<\/p>\n<p style=\"text-align: center;\"><a class=\"vt-p\" href=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wifi_analyzer_android.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-850\" style=\"border: 2px solid black;\" title=\"Wi-Fi Analyzer for Android\" src=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wifi_analyzer_android-180x300.png\" alt=\"Wi-Fi Analyzer for Android\" width=\"180\" height=\"300\" srcset=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wifi_analyzer_android-180x300.png 180w, https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wifi_analyzer_android.png 480w\" sizes=\"(max-width: 180px) 100vw, 180px\" \/><\/a><\/p>\n<p>You can see what channels are used by which networks, and so the <strong>less used channels<\/strong> can be easily spotted. In my case, I decided to go for channel 10, which was pretty much free.<\/p>\n<p>&nbsp;<\/p>\n<p>I tested Wi-Fi networks with 2 different routers, 1 dedicated AP, 2 Android phones, 1 iOS device, 1 laptop and 2 netbooks. Some specific combinations of them seemed to work, but most of them <strong>didn&#8217;t<\/strong>, sometimes even if they were in the same room as the access point.<\/p>\n<p>How could this be?<\/p>\n<p>&nbsp;<\/p>\n<h2>Extending Wi-Fi range with WDS<\/h2>\n<p>First of all, I thought that the thin room walls might be thicker than\u00a0I initially supposed. Therefore, I decided to put an AP in each of the two rooms I wanted to wirelessly link together.<\/p>\n<p>One of the easiest ways is to use a <a class=\"vt-p\" href=\"http:\/\/en.wikipedia.org\/wiki\/Wireless_Distribution_System\">Wireless Distribution System<\/a> (WDS). You set up each of the two APs with the other&#8217;s MAC address, do some reboots, and off you go.<\/p>\n<p style=\"text-align: center;\"><a class=\"vt-p\" href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wds.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-851\" title=\"Extending Wi-Fi range with WDS\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wds.png\" alt=\"Extending Wi-Fi range with WDS\" width=\"371\" height=\"206\" \/><\/a><\/p>\n<p>However, simple ping tests demonstrated I was still having a packet loss as high as 40%. Even if the APs were just <strong>a meter and a wall away<\/strong> from each other!<\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<h2>Extending Wi-Fi range with FEC<\/h2>\n<p><a class=\"vt-p\" href=\"http:\/\/www.flickr.com\/photos\/21891176@N00\/379289594\/\"><img loading=\"lazy\" class=\"alignright size-thumbnail wp-image-855\" style=\"margin: 5px; border: 2px solid black;\" title=\"Rj45\" src=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/rj45-150x150.jpg\" alt=\"RJ45\" width=\"150\" height=\"150\" \/><\/a>So the next option was to get a stronger signal in the other room, not with WDS, but using a\u00a0<em><strong>F<\/strong>reaking <strong>E<\/strong>thernet <em><strong>C<\/strong><\/em>able<\/em>. Once I got hold of a 10 meters cable, I plugged an AP at the end of the cable, in the other room.<\/p>\n<p>To my dismay, it was barely possible to get a MacBook Pro to connect to the AP. There was a distance of <strong>50 cm<\/strong> between the two!<\/p>\n<p>So apparently, the wireless signal was being lost <strong>inside the room<\/strong>, and <strong>not due to the wall<\/strong> (<em>this quickly ruled out the possibility of my walls being built of a thin layer of pure lead&#8230;.).<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2>Checking for electromagnetic interferences<\/h2>\n<p>Next up, and thinking it could be some sort of EMI, I decided to get help at the mailing list where the local computer geek<code>^H^H^H<\/code>urus hang around, the <a class=\"vt-p\" href=\"http:\/\/www.e-ghost.deusto.es\/\">e-ghost<\/a>. A few emails later, and thanks to the kindness of\u00a0<a class=\"vt-p\" href=\"http:\/\/twitter.com\/#!\/txipi\">@txipi<\/a>, I was holding a USB \ufeff2.4GHz <strong>spectrum analyzer<\/strong> on my hands.<\/p>\n<p style=\"text-align: center;\"><a class=\"vt-p\" href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wispy.jpg\"><img loading=\"lazy\" class=\"size-full wp-image-874 aligncenter\" style=\"margin-top: 5px; margin-bottom: 5px; border: 2px solid black;\" title=\"Wi-Spy\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wispy.jpg\" alt=\"Wi-Spy\" width=\"400\" height=\"236\" \/><\/a><\/p>\n<p>The <a class=\"vt-p\" href=\"http:\/\/www.metageek.net\/products\/wi-spy\/\">Wi-Spy 2.4i<\/a> is a nice piece\u00a0of hardware, with a similar functionality to the <em>WiFi Analyzer<\/em> program mentioned at the beginning of this article. Main difference being, it can detect\u00a0<strong><em>all<\/em> kinds of EM signals<\/strong> (not just those identified as wifi networks). For example, it&#8217;ll pick up signals coming from bluetooth devices, wireless security cameras, microwave ovens, baby monitors, etc.<\/p>\n<p>There&#8217;s some tools for linux, which can be installed with\u00a0<code>sudo apt-get install spectools<\/code>, and look like this:<\/p>\n<p style=\"text-align: center;\"><a class=\"vt-p\" href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/Wi-SPY-spectools-screenshot.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-854\" style=\"border: 2px solid black;\" title=\"Wi-SPY spectools for Linux\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/Wi-SPY-spectools-screenshot-300x161.png\" alt=\"Wi-SPY spectools for Linux\" width=\"300\" height=\"161\" \/><\/a><\/p>\n<p>There&#8217;s also native software for Windows in the Wi-Spy CD which I sadly <strong>had<\/strong> to use, since I couldn&#8217;t configure the timescale of the spectrographs on linux spectools.<\/p>\n<p>Once the software was correctly set up, I disabled my 802.11 network completely, and started logging data. Here&#8217;s the <strong>spectrograph for a period of about 30 non-continuous hours<\/strong>:<\/p>\n<div>\n<div id=\"attachment_860\" style=\"width: 160px\" class=\"wp-caption aligncenter\"><a class=\"vt-p\" href=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wispy-spectrograph.png\"><img aria-describedby=\"caption-attachment-860\" loading=\"lazy\" class=\"size-thumbnail wp-image-860 \" title=\"2.4GHz spectrograph\" src=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/wispy-spectrograph-150x150.png\" alt=\"2.4GHz spectrograph\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-860\" class=\"wp-caption-text\">(click to zoom)<\/p><\/div>\n<\/div>\n<p>Vertical axis is <strong>time<\/strong>, horizontal axis is the <strong>frequency<\/strong> (wifi channel numbers are shown at the bottom for your convenience), and color axis is the maximum <strong>signal<\/strong> power.<\/p>\n<h2>Analyzing the 2.4GHz spectral graph<\/h2>\n<p>Several interesting patterns emerge from the graph:<\/p>\n<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-863\" style=\"margin: 5px; border: 2px solid black;\" title=\"noise\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/noise.png\" alt=\"\" width=\"100\" height=\"76\" \/>First of all, there&#8217;s these <strong>red-yellow dots<\/strong> all over the spectrograph. They seem to represent <strong>network scans<\/strong> made by wifi devices every once in a while. The pattern can be consistently repeated by turning the WiFi of any device <em>OFF<\/em> and then <em>ON<\/em>; or by simply trying to <em>refresh<\/em> the list of networks.<\/p>\n<div style=\"clear: both;\">\n<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-864\" style=\"margin: 5px; border: 2px solid black;\" title=\"channels\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/channels.png\" alt=\"\" width=\"101\" height=\"69\" \/>Then there&#8217;s the prominent <strong>vertical patterns<\/strong> hovering around channels 1, 2 and 3. These obviously represent other existing <strong>WiFi networks<\/strong> around my house. There are other similar vertical patterns that cannot be easily appreciated with the color coding in this graph, but they&#8217;re logically low signal and won&#8217;t interfere much anyway.<\/p>\n<div style=\"clear: both;\"><img loading=\"lazy\" class=\"size-full wp-image-867 alignleft\" style=\"margin: 5px; border: 2px solid black;\" title=\"emi\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2011\/03\/emi.png\" alt=\"\" width=\"299\" height=\"28\" \/>Finally, there&#8217;s the massive\u00a0<strong>horizontal patterns<\/strong> that appear from time to time. They use up varied frequencies, ranging from two channels, to almost all of the 802.11 spectrum. To make matters worse, the signal is <strong>very<\/strong> strong when present. The duration can range from a few minutes, to well over an hour straight.<\/div>\n<p>&nbsp;<\/p>\n<h2>Conclusion<\/h2>\n<p>I suspect it is <strong>this last type of interferences<\/strong> which makes my WiFi connectivity act so erratic. Sometimes, all my devices will connect just fine, but sometimes it&#8217;s impossible to connect <strong>even 10cm away<\/strong> from the AP.<\/p>\n<p>It&#8217;s possible that a <em>Police station<\/em> located half a kilometer away (with\u00a0direct line-of-sight)\u00a0produces it, or maybe it&#8217;s the hardware of some\u00a0neighbors. Building a huge Faraday cage is unthinkable, and hopping from channel to channel has proven useless, so I guess I&#8217;m irrevocably\u00a0<strong>stuck with wired conections<\/strong> until I move to another house.<\/p>\n<p>On the bright side, debugging these WiFi issues surely has been an interesting fun ride \ud83d\ude42<\/p>\n<p>Since I am by no means an expert in telecommunications, any further explanations or corrections are more than welcome. Feel free to use the comments box below!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Some months ago, when I moved to this house, I found it was pretty difficult to get any WiFi device to connect to my wireless home network. Recently I tried debugging it, and these are the results&#8230; &nbsp; Finding a proper WiFi channel Finding an appropriate WiFi channel is part of the usual initial setup. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[13,23],"_links":{"self":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts\/846"}],"collection":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=846"}],"version-history":[{"count":0,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts\/846\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}