Friday, March 28, 2008

On managing home wireless networks

My roommates were complaining that the wireless network at our place was finicky these days. So I decided to do some wireless network troubleshooting. There were two distinct possibilities: either the wireless router was causing the mischief or the network was seeing a lot of interference from other neighbouring networks (I live in an apartment, and my card senses around 13-14 networks all the time). I have more faith in hardware than in networks, so I decide to investigate the network health first. I write this entry as a summary of my experiences in setting up and maintaining wireless networks.

First a very brief intro about the wireless networks: the protocol that our wireless networks use is called 802.11 and comes in various flavours, which roughly decides (if we think of wireless communication as speaking) at what pitch we talk to our routers. The most common ones are 802.11b/g which work around 2.4GHz frequency band and 802.11a which runs at 5 GHz band. 802.11 b/g are more prone to noise because many other devices (microwave being the most significant of them) run in the same frequency band and create interference (shouts so that router can't hear what laptops are saying). 802.11a has its own faults, noticeably the fact that it has a smaller range than 802.11b/g. My own router is a b/g router.

In each "band" there are many frequency channels: think of them as languages in which you can speak. The router and your laptop should agree on which language they are going to talk apriori. In the 2.4 GHz band, there are 11 channels. Some channels overlap: this is bad, if two languages sound the same sometimes, it may be hard to figure out what is being said. Channel 1,6 and 11 are the only non-overlapping channels in 802.11b/g, so most routers pick one of these channels as default when setting up the network for the first time. If a neighbouring network runs on a different (and non-overlapping) channel, it does not cause interference; if however, it does run on the same channel, thats bad: this means some other machines are speaking in the same language that you understand (and you need to shut up while they speak to their routers.)

Phew! with all that physics out of the way, lets get our hands dirty: first thing to do, figuring out which networks are the closest (most heard) in the apartment apart from my own, and what channel they use: I stumbled upon (not literally :) ) a nifty little piece of software that gives me that information: its called network stumbler. It tells me the Signal strength, Signal to noise ratio and channel for each network SSID (name) that my laptop can hear. ( Click on the screenshot below to get an enlarged view )


The fields of interest are : address of router, SSID(name) of network, channel number, data rate, encryption technique, Signal to noise ratio (SNR), Signal strength in that order.

First field to look at is signal strength: I have arranged it in an increasing order of signal strength:so the last network is mine( which now runs on channel 1: earlier it ran on channel 6 before I troubleshooted) The closest interferers(previous two entries) run in channel 9 and 6, in that order. (this screenshot was taken from my room where the router is, all our wireless problems were in the other bedroom) When my network was on channel 6, in the other bedroom, the other channel 6 network (3rd from bottom) was having a high signal strength and was degrading the SNR for my network. Another point that this screenshot illustrates: there are so many networks that run on channels 11 and 6, so likelyhood of running into noise there is more.

My network is much faster(I got a 30Kbps jump in downloads) and more reliable now, though it has to stand the test of time: here are some of the points that I have extracted out which may be of help when configuring wireless networks:

- Have some sort of encryption: Wireless security is mocked at by many, but having an encrypted network prevents squatters from just hooking on to your network and slowing things down for legitimate users.

- Avoid the overlapping channels(all except 1,6,11) if possible (however, go for them if all non-overlapping ones are heavily used in the neighbouring networks)

- Avoid channels 7-10 in general and 9 in particular: channel 9 operates at 2.452 GHz - very close to the natural resonant frequency of water. While microwaves are supposed to contain the radiation, its enough to cause packet drops (I tried :) -- I configured to channel 9 and had milk -- the SNR just collapsed!!) Channels 7-10 all experience some noise as microwave frequency is not always steady.

- Try frame bursting to see if that helps, in uploads. It reduces the overhead, and most routers have it built in. This might require some networking skills; it would be one of the advanced settings, and may not have a nice GUI interface, and require manual turning on by logging into the router.

- Check channels when there's sudden degradation in performance. This is quite tedious, having to do this manually (unless you're crazy about networks, like me: then its a welcome distraction :) ). It would be quite nice if the routers were smart enough to figure out the right channel to talk on. I think this is now a draft (802.11h? -- not sure) standard, so in future we might see smarter routers and wireless cards that know what language to speak!

Sunday, March 23, 2008

Managing Complexity in (ahm) Complex Systems..

As I think about wireless networks, my mind goes into philosophical overdrive :) . Most systems are complex because we want some level of performance (performance in a very very broad sense -- performance for a building may mean how long it can withstand certain winds), and Its much simpler to make stuff that doesn't work so well than the one which does. Yet at the same time, we'd like to keep things simple enough for designers/maintainers.

I do speak in a computers context to begin with, and I am limited to my myopic world view -- I'll be grateful if my smarter friends in more diverse fields speak their mind; after all anything that does a good job is complex: good buildings/circuit systems/biological systems/economy..

I guess the only way to manage complexity is to break a complex system into more manageable chunks. There are really two ways of breaking up a system: vertically, with each "piece" performing some task and interacting with other pieces, or go for a layering paradigm -- starting from a 10,000 foot view and delving deeper slowly and considering the "view" at that level.

From a Biology point of view (with my very limited high school knowledge), breaking up vertically would have to mean the way we attribute "functions" to organs (or even cell components like whatsitsname.. um Mitochondria) and then talk about each organ as an "entity" and its interactions with other entities. This makes it easy to categorize stuff into neat compartment = (function,interaction) pairs. Another example would be the Von Neumann Architecture for computers .

When thinking of layering (the most obvious example that would come to me would be the network stack but we'll save that for later :P ), one good example would be the memory hierarchy in computers, where you worry about interactions only between adjacent layers while designing.

When data travels from disk to CPU, it goes through the following path (in most cases)

Hard disk --> main memory --> cache --> on chip cache --> registers

and the same way back when data is to be stored into hard disk..

I have thought hard about this, but I can't think of a "natural" (occurring in nature, like evolutionary, biological) example of this kind of layering, and I'll be obliged to anyone who points one out for me, but I think I have a clue as to why this kind of layering is not visible in nature.

Now for the whole crux of my point -- I think, designing with vertical partitioning gives us performance, while going for a layering paradigm sacrifices performance for ease of manageability in design and maintenance.

If you break up functionality into vertical components, each component can be rigged up to give the best possible performance internally, only the interface with other components need be maintained. For example, If CPU and memory are two independent units, each can be rigged up internally to give the best possible performance, as long as they can "talk" to each other(maintain the interface). The only catch is, since you can rig it up as much as you'd like, these components themselves tend to be very complicated (think CPU)

Imagine a computer where cache coherency algorithm depends on hard disk drive head position. One can envisage that it may lead to improvement in performance, (For example, off top of my head, An optimization (assuming all data in cache goes from cpu to disk): Evict data from cache in order of disk head position, to reduce disk latency), but writing the disk driver and the cache coherency algorithm would be (ahm.. to put it mildly) crazy. Also imagine, then we would have problems like a particular disk drive not working with a certain chipset. This may sound vague, but isn't as remote as all that: think cameras and non AA battery sizes: Non AA batteries are smaller/lighter in weight but then the camera has to be charged in situ.

I speculate that we don't see this layering in nature is because, nature doesn't care about ease of design -- it has infinite chances of getting it right (by trying our random combinations by way of mutations and evolution) , or maintenance-- after all what price one creature?Perhaps thats why medicine is so hard..

Its a known fact that for various reasons our Wireless networks don't perform as well as the wired networks - they are generally slower, more error prone than the ones which we wire down. Some of this is because the "channel" we transmit in isn't as reliable (bit error rates are much higher in air than in a co-axial cable), but thats not all -- We are dragging the dead weight of our engineering decisions of wired networks (Our design for wired networks had assumptions that don't hold for wireless networks).

Networks have followed a Layered architecture(TCP/IP) all this while, to manage the crazy complexity of making any two (possibly radically) different machines communicate over versatile links (dial up, broadband, submarine cables,satellite links and even pigeon post I hear) across huge distances in the world. Because of the wireless performance problems that we have, more and more people are saying that layering should be sacrificed for more tightly coupled cross layer solutions. . I have even come across work where people do power aware(at physical layer) encryption (at application layer) to squeeze every bit of performance out!

The open question is, where is the sweetspot between performance and manageability for wireless networks? Are we at a cornerstone right now? The same kind of tipping point came for operating systems sometime in the 70s, when clean, layered but slow operating systems were abandoned for the better performing ugly ones.

Maybe this post is too vague, the ideas are wrong/trivial/uninteresting or plain gibberish and unfit for human consumption -- but what the heck! :) If you've got some enlightening thoughts, I'd love to hear them, (even if all you've got to say is that I'm insane and should quit inflicting blog posts on innocent people)... :P

Monday, March 17, 2008

Justifying the GIMPressionist

A close friend complained after looking at the previous GIMPressionist work that it looks like I just blurred the image/added jaggies :). A very valid criticism. So here I try to better that and justify my GIMP skills :) .. Note that a painting would never be as sharp as a photo, so some blurring is expected.

So here's another shot at it( click on images to enlarge ):



And the GIMPressionist ones follow:




Saturday, March 15, 2008

Being the Imprssionist with GIMP..

Here is some of promised GIMP magic at work. The idea is to make a photo look like painting. The way to do it is to sample the colour underneath and then create a brush stroke of the same colour. Varying the brush orientation, shape, size and opacity gives different effects.

I am at best a GIMP novice, and the effects I apply are mostly hacks that I think would look good :) . So the images should be judged considering that in mind, a more deft hand would be able to get much more out of the pictures.

Here is a picture of Sun Temple at Motera in India that I captured using my Canon A75 on my India trip this December. Our aim -- to make it resemble a painting as much as possible..(Click on images to enlarge.. )

And here's the GIMP artifact..

I have applied the Canvas filter and then used the GIMPressionist tool to get the desired effect, with the "paintbrush" brush type using 12 different brush sizes between 2 and 14 pixels, and orientation of upto 45 degrees . The darkening of the image is because I played with the brightness and contrast a bit, and liked the result of my fiddling around..

To underline the whole point, Here is one photograph:


Here is what I could get using my own impressionist software (the one I wrote as part of my graduate computer graphics class)

And Here's what GIMP gives you using its GIMPressionist tool:



Of course, the tool that I wrote required me to do all the 'artwork' by hand: select the brushes, the "alpha" (or transparency factor) and the inclination of the brushes. The artifact required about 4 hours to create, (though, of course extending the software to "repaint" the whole picture with same settings would have been an easy and worthwhile extension of the existing program). The time it took GIMP, umm -- a bit under 30 seconds, since its completely automated :)... go GIMP!!!

Friday, March 14, 2008

A wireless Analogy to Speaking/Hearing

In recent months, I have been delving deeper into Wireless Networks. And only now,have I started to have a good intuitive understanding to the whole business. I do not claim that all the thoughts expressed here are original, but I think they are interesting enough to find a mention in the blog. It also shows that most things in Computer Science are Common Sense...unlike transistors (whose working amazes me every time I read about how it works :) )

The way Wireless Networks (at least the kind we come in contact with, after all satellite communications is wireless too, but then how many of us set that up in our home? ) work is like the action of speaking/hearing for people. Just like air is a broadcast medium for sound, so it is for radio frequency as well.

If one person in a group speaks, any other (polite) person should shut up to allow the first person's voice to be heard. Of course, if the second person is far enough from the first person, they can speak concurrently without affecting each other. One of the most interesting problems in wireless is to figure out how far is far enough for nodes to be able to talk concurrently.

Clearly, how far is far enough depends a lot on how loud the speakers are. Ditto in wireless: it depends on the transmit power of nodes. Also, imagine a person speaking near heavy machinery: He'll have to be much louder than a person who is speaking in a quiet room, to be heard. So noise and interference also affect how far far enough is..In wireless, unfortunately, because many instruments apart from wireless talk at the same frequency ranges (because they are the ones that are freely available), and interference is a major problem. Microwave Ovens slow down the Internet in many a homes :).

Thats about the similarities, but there are some aspects of wireless which make it harder than hearing/speaking.. Imagine being in a noisy room and listening to a person. After every sentence being uttered, the speaker has some clue about whether the listener has heard what he said; these are because of the out-of-band signals that you get in form of change of expression of the listener, nodding etc. Imagine how annoying it would be for the listener and the speaker if the listener was forced to acknowledge that he heard the speaker right after every sentence..but thats precisely state-of-the-art in wireless these days. One good intuition looks to be that if we can exploit other out-of-band ways of acknowledging what we hear, we'll communicate better. This is difficult given the rigid capabilities of what our nodes can or cannot do, but I would have to think that when designing specific networks where you know the effect of what you communicate should be,significant gains can be made by looking out for such out of band actions..

Also, it would help a lot, if we all know what volume to talk at rather than shouting at the top of our voices or in a constant monotone (which is precisely what wireless does now, though they are moving towards changing that..). We're still primordial as far as this evolution is concerned -- its an exciting time for an interesting field!