Tuesday, November 18, 2014

Alfa wifi: the power you need

Boosting wifi power

By Matthew Barnard

As there seems to be a lack of articles and reviews on Alfa wifi cards (and wifi in general), i'll write one.

The first and most important step when choosing which wifi card out of the various varieties sold of Amazon and elsewhere, is to check its compatibility with your setup. I found this out the hard way when I bought a card that did not support monitor mode. Some of the cards to not have proper driver software. Some just simply don't work on Linux. Luckily, they all work on Windows in the event that you are past your return period. The one model that I found to work was AWUS036NH. It was simply plug-and-play for both Linux and Windows. It supported all forms of wireless hacking. The card is rated at 2000mw, but obviously that is a joke. Here in the US, we are limited to 100mw total output power. Even if the card does have more power, you are will need to modify it to properly work. Make sure that whatever antenna you purchase, that it has a removable antenna. Internal antennas are simply the worst.

How to Unlock Alfa wifi adapter (and most other adapters)

Open a terminal and type ifconfig

You should see a list of networks cards. It is usually starts with wlan followed by a number. In my case it was wlan0.

Now to check the current power output of the wifi card.

iwconfig wlan0

Replace wlan0 with whatever your wireless cards name is.

The standard power output is usually around 20dbm in the US (100mw).

Now lets assume the Alfa wifi cards output really is somewhere around 500mw. I want to be able to access that power for extra long range communication. I convert watts to dbm and get 27dbm. That is the number required to achieve 500mw of output power.
Here is a quick reference chart for common RF numbers.

15dbm = 31mw
16dbm = 39mw
17dbm = 50mw
18dbm = 63mw
19dbm = 79mw
20dbm = 100mw
21dbm = 120mw
22dbm = 158mw
23dbm = 190mw
24dbm = 250mw
25dbm = 316mw
26dbm = 398mw
27dbm = 501mw
28dbm = 630mw
29dbm = 794mw
30dbm = 1000mw
31dbm = 1250mw (1.25w)
32dbm = 1580mw (1.58w)
33dbm = 2000mw (2w)
34dbm = 2500mw (2.5w)
25dbm = 3160mw (3.6w)

The power of the wifi card is generally limited by it's ability to cool itself. Without a proper heat sink, even very powerful cards cannot output much power without emitting magic smoke. You could install a heat sink, but that is outside the scope of this site.

A side note on radios in general.....

The antenna matters as much or more than the output power of your radio. You want to hear as well as talk right? Then you need an antenna to pick it up as well as transmit your "speach", too.With a decent antenna, you can achieve much greater range than with the horrible dipole antennas that are so common. A common dipole antenna is also known as a "rubber duck" antenna. It is basically a little black plastic stick poking out the back of your wifi card, router, or a number of other things. You want a better quality antenna than a dipole. A dipole emits power in a full circle, 360 pattern. The only place it does not emit power is on top and bottom. Pointing your antenna with the tip will drastically weaken the signal quality. For excellent range, you want an antenna that has a 180 degree or smaller radiation pattern. The only reason you would want a 360 antenna is if your wifi router is in the middle of your house. You almost never want an omni (360 signal) antenna for your wifi card, as you only need to receive a signal from one place, the router.
An antenna like this is much better. I won't get into antenna mechanics, but generally an antenna with a higher gain is a better antenna. You will need to aim the antenna to "lock on" to the access point. To find an access point, you will need to move the antenna around to get the best signal.

This is exactly the antenna I am using currently to write this article

You can purchase this antenna here (or buy it in the combo pack I have linked to earlier)
Costs about $10

or even better,
A yagi antenna
(costs about $25)

I use a 15 dbi yagi antenna often. The downside is size (30" long), but I can communicate at la good mile with this antenna.

This is one of my antennas (buy it here) You also need the correct connector cable (buy it here) to make it compatible with the Alfa wifi card

You can buy it for $25 with free shipping. Make sure that the connector type is compatible. SMA means there is no little pin sticking out the end. RP SMA means there is a small pin in the plug.

You will need a N female to RP SMA if you want the Yagi to be compatible with most wifi cards (note, some wifi cards do not have a detachable antenna).
Buy the adapter here

For the ultimate in antennas, pick up a dish antenna. This is very similar to dishes used for satellite TV. The downside is that they are big (5 pounds). The upside is that you can be very far away (2-3 miles) and still have a strong signal.
You can buy an excellent dish antenna here. (costs about $45)
(you will need an adapter to fit the Alfa wifi card) Buy that here.

A very important note on antennas.

NEVER use a radio without an antenna. You will burn the card in a matter of minutes if not seconds because the antenna does not have a proper "load".

So back to adjusting wifi output power

I want my card to output 500mw of power, or 27dbm. Unless you card has a decent heat sink (Alfa wifi cards generally do not), then don't go over 500mw. On a side note, it is illegal put out this much power, so if the police come knocking at your door (which is extremely unlikely), don't blame me.

To adjust the power, first I must shut the wifi card down.
To do so

ifconfig wlan0 down

(replace wlan0 with whatever your number is)

Now we change our country to Bolivia, which allows up to 1000mw of output
(there are several other countries which allow similar power output)

iw reg set BO

Then turn your card back on

ifconfig wlan0 up
(again, replace wlan0 with whatever you card is)

Now I can change the output power up to 30dbm

iwconfig wlan0 txpower 27
(change wlan0 again, set txpower to whatever you want)

Be careful not to set the txpower to high. If you feel your wifi card getting exceptionally hotter than normal, lower the number. By emitting more power than it can handle, you may shorten the life of your card.

How easy is it to follow this tutorial?