[ Wednesday, 11 June 2008, michuk ]
I have recently bought a Huawei E220 HSDPA access device (or a so-called “3G modem”) from Three UK. In this article I’ll share with you my experiences of using it in Ubuntu Linux distribution. And don’t worry, it works just fine
Little note for the beginning. I bought the modem at Carphone Warehouse in Coventry. The seller told me — answering my question about operating system support — that the modem only works in Windows XP or Vista. No Mac support. No Linux (in fact has never heard the word ‘Linux’ in his life). Used to not trusting the sellers (the one in T-Mobile told me before that their modem works flawlessly in all operating systems, including Linux — even though he also heard this name for the first time from my mouth) I bought the modem and started testing (you have three days to give it back and claim your money back for no reason).
I was kindly surprised Ubuntu comes with the drivers to Huawei E220 modem. They’ve been bundled into the Linux kernel since version 2.6.20. Running the modem was then only a matter of installing a proper dial-in program (the default one could be used as well, but it sucks a big one) and configuring it, which proved to be effort-less as well. So here it goes.
Installing the software
I have decided to install wvdial, a PPP dial-in command line software, and a GNOME frontend to it — gnome-ppp:
sudo apt-get install wvdial gnome-ppp
The latter is part of the
universe repository so you need to have it enabled in order to install it. That’s it about the installation, believe it or not.
Setting up wvdial to support Three UK 3G modem
Wvdial is not just ta plain-stupid dialer. It has some built-in intelligence. It can autodetect modems of all kind and auto-configure them. That’s why there is really not so much configuration, either.
wvdialconf utility to detect and configure your modem. I did it as root. If you want to dial-in as user, you need proper permissions for this. Here is the output of the command:
# wvdialconf Editing `/etc/wvdial.conf'. Scanning your serial ports for a modem. Modem Port Scan< *1>: S0 S1 S2 S3 ttyUSB0
: Device or resource busy Modem Port Scan< *1>: USB0 WvModem< *1>: Cannot get information for serial port. ttyUSB1< *1>: ATQ0 V1 E1 -- OK ttyUSB1< *1>: ATQ0 V1 E1 Z -- OK ttyUSB1< *1>: ATQ0 V1 E1 S0=0 -- OK ttyUSB1< *1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyUSB1< *1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyUSB1< *1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB1< *1>: Modem Identifier: ATI -- Manufacturer: huawei ttyUSB1< *1>: Speed 9600: AT -- OK ttyUSB1< *1>: Max speed is 9600; that should be safe. ttyUSB1< *1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK Found a modem on /dev/ttyUSB1. Modem configuration written to /etc/wvdial.conf. ttyUSB1 : Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
As you can see, it wrote the configuration to
/etc/wvdial.conf file. We’ll need to fix it only a bit. Here is my conf after the fixes:
# cat /etc/wvdial.conf [Dialer Defaults] Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Stupid Mode = 1 Modem Type = Analog Modem ISDN = 0 Phone = *99# Username = three Password = three Modem = /dev/ttyUSB1 Dial Command = ATDT Baud = 9600 [Dialer three] Init2 = ATZ Init3 = ATE0 V1 &D2 &C1 S0=0 +IFC=2,2 Init5 = AT+CGDCONT=1,"IP","3internet" ISDN = 0 Modem = /dev/ttyUSB0 Modem Type = Analog Modem Baud = 460800
Yes, you see it right. The only changes you need to make is the phone number (if not set correctly to this weird value), user name and password (which are simply “three”). That’s all, really. Now try dialing in:
# wvdial --> WvDial: Internet dialer version 1.60 --> Cannot get information for serial port. --> Initializing modem. --> Sending: ATZ ATZ OK --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 OK --> Modem initialized. --> Sending: ATDT*99# --> Waiting for carrier. ATDT*99# CONNECT --> Carrier detected. Starting PPP immediately. --> Starting pppd at Tue Jun 10 08:26:25 2008 --> Pid of pppd: 25359 --> Using interface ppp0 --> pppd: ��@� --> pppd: ��@� --> pppd: ��@� --> pppd: ��@� --> pppd: ��@� --> pppd: ��@� --> local IP address 10.231.99.246 --> pppd: ��@� --> remote IP address 10.64.64.64 --> pppd: ��@� --> primary DNS address 172.31.76.69 --> pppd: ��@� --> secondary DNS address 172.31.140.69 --> pppd: ��@� --> pppd: ��@� --> Connect time 0.6 minutes.
Yuppi! We got connected! It really works! And it’s that simple. Amazing
If you are scared of the fact of connecting to network using the command line tools, gnome-ppp may be of some help. It’s a simple frontend to wvdial program, doing basically all the same, but with the ability to hide itself in the notification area.
Gnome-ppp uses the same configuration as wvdial. By default, it looks for the config file in
~/.wvdial.conf. I symlinked this file with the wvdial configuration, so that when I run
wvdialconf it updates the gnome-ppp config as well:
# ln -s /etc/wvdial.conf ~/.wvdial.conf
Now you can simply run gnome-ppp. I do it as root. You can do it either as root or as user (with the proper permissions set).
Connecting, it takes some 10 second if the signal is fine
Waiting for prompt…
Yes, it can automatically reconnect, as well.
So, as you can see, using the gnome-ppp app is fairly simple as well. I prefer
wvdial anyway, since it seems more reliable. Gnome-ppp once in a while refused to connect even though the signal was good and wvdial didn’t protest. It may have been some specific issue though, your mileage may vary.
Gnome-ppp configuration dialog
Issues with 3G modem in Ubuntu Linux
The only issue I have noticed so far is that once every few times, the system refuses to detect the modem. It’s being noticed in
dmesg like that:
[ 50.914987] airprime 3-1:1.0: GSM modem (1-port) converter detected [ 50.915110] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB0 [ 50.929802] usb-storage: probe of 3-1:1.1 failed with error -5 [ 50.929822] airprime 3-1:1.1: GSM modem (1-port) converter detected [ 50.929937] usb 3-1: GSM modem (1-port) converter now attached to ttyUSB1
But it still fails to detect the modem when I run
wvdial. Seems like an Ubuntu-specific issue. After reboot it always worked again. It’s one of the many reboot-and-work issues I have with Ubuntu 8.04, others being GTK-apps freezing, network freezing and so on. Anyway, it’s not the time to complain about Canonical, I did it in my Ubuntu 8.04 review anyway.
Huawei E220: Linux vs Windows support
Amazingly, I found the Linux support more reliable than the one in Windows. It does better in reconnecting automatically after losing the signal. In the default Windows app from Three, I had to manually close the connection and press “Connect” again, in order to reconnect. This is a very awkward solution, especially when I connect in trains when the network isn’t always perfect, to put it nicely.
The Windows client has a nice feature, however, of counting all the data we transferred using the 3G modem. This is especially handy in my case, since I went for the Pay-As-You-Go Three plan which gives me 1GB of transfer per month for 10 pounds.
Probably there is some way to achieve the same thing on Ubuntu, but I did not feel like searching, since this is not that important for me anyway. If you have a ready-to-use solution though, please share it in the comments section.
After a while of using Three modem on Linux I noticed that sometimes the modem fails to connect for strange reasons. Usually rebooting Linux did the job but that was not good for me. Thus, I created this small script that I’m running in case modem refuses to connect. It works in 95% cases:
# cat /usr/bin/connect killall -9 wvdial rmmod airprime ifdown wlan0 iwl4965 modprobe airprime sleep 3 nohup wvdial three & tail -f nohup.out
Basically what it does is: first kills any previous connection, then removes the Three modem driver, then disables the WiFi connection (if any is set up), finally loads the modem driver, waits 3 seconds for it to load and then dials up again in nohup mode — you’ll see all messages by tailing the nohup.out file.
If your connection seems very slow, it may be the slowish Three DNS servers. Try OpenDNS in such case. I do it by replacing the
/etc/resolv.conf file with the following:
nameserver 18.104.22.168 nameserver 22.214.171.124 search home
Usually it speeds up the connection a lot. Learn more about OpenDNS on their website.
Pricing and availability
The modem costs currently 50 pounds in Pay-As-You-Go at Three. You can get either 1GB for 10 pounds or 3GB for 15 pounds. One pop-up works for a month only so if you don’t use your allowance, it is lost.
Remember to frequently check if you still have any credit on Three account and do not top up by more than it’s needed. Three plays a dirty trick on their customers. When the token is used (a month passes or you use up the whole bandwidth), it starts charging you on a drakonian rate of 1 pound per 1 MB (assuming that there is any money left on the Three account). Thus, it’s always better to top up the Three account after the token is used and choose a new token (10/15/20 pounds). You do it by first topping up and then choosing your modem on the list of devices and selecting the right token. It took me a while to find this out and I believe Three made it intentiously unintuitive to get some extra cash from the unaware customers (very bad practice). Anyway, when you know what to do, you’re gonna be good.
The same modem is being currently sold by many other UK vendors like T-Mobile or Vodafone. They should work exactly the same, although the user details and password may differ.
I use the Three 3G modem in Ubuntu on my every-day travels between Coventry and London Euston. It proves to work fine (although I expected the signal to be a bit better in Virgin Trains, but it’s another story). As I use the Internet during travel mostly to check e-mail, get some RSS feeds and post some news-stories or articles on one of the websites, the random signal is not a nightmare for me. For a person who would like to do some serious work it might be an issue, though. In all other places except for the trains, I was very satisfied with my 3G modem. It just works and the connection speed it pretty good for mobile access, so I cannot complain. It’s good to know that for the mobile Linux users, there is a quite cheap solution to get the Internet connection nearly everywhere.