Connecting to the Internet with UMTS on NetBSD

All you need is a laptop with cardbus slot (PCMCIA) and a datacard which is supported by NetBSD. The card will appear as an USB modem to the kernel. In my example I am using an Option N.V. MC3G (Vodafone Mobile Connect Card).

First of all you have to make sure the datacard is recognized by the kernel:

ohci0 at cardbus0 function 0: vendor 0x1045 product 0xc861 (rev. 0x10)
ohci0: OHCI version 1.0, legacy support
usb5 at ohci0: USB revision 1.0
uhub5 at usb5: vendor 0x1045 OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub5: 2 ports with 2 removable, self powered
ubsa0 at uhub5 port 1
ubsa0: Vodafone Vodafone Mobile Connect Card - 3G, rev 2.00/0.00, addr 2
ucom0 at ubsa0 portno 0

ucom0 means we have successfully attached a serial adapter. ugen0 would mean the card is not yet supported. The device can be accessed through /dev/ttyU0. For a test, we add the following line to /etc/remote to communicate with the modem:

ucom0:dv=/dev/ttyU0:br#460800:pa=none:dc:

Then connect to the modem as root and try some AT commands:

# tip ucom0
connected
at
OK
atz
OK
ati
Manufacturer: Option Wireless Technology
Model: 129
Revision: 3.1.2  (Date: Mar 08 2004, Time: 11:54:30)

OK
at&v

&C: 1; &D: 2; &F: 0; E: 1; I: 0; L: 0; M: 0; Q: 0; V: 1; X: 4; Z: 0;
S0: 0; S3: 13; S4: 10; S5: 8; S6: 2; S7: 50; S8: 2; S9: 6; S10: 14;
S11: 95; +ICF: 3,3; +IFC: 2,2; +IPR: 115200; +DR: 0; +DS: 0,0,2048,6;
+CBST: 7,0,1; +CHSN: 0,0,0,0; +CSCS: "IRA"; +CSTA: 129; +CR: 0; +CRC: 0;
+CMEE: 0; +CGDCONT: (1,"IP","web.vodafone.de",,0,0)
,(2,"IP","web.vodafone.de",,1,0),(3,"IP","web.vodafone.de",,1,0);
+CGEQREQ: (1,4,0,0,0,0,1,1500,"0E0","0E0",3,0,0); +CGEQMIN: ; +CGQREQ: ;
+CGQMIN: ; +CGEREP: 0,0; +CGCLASS: "A"; +CGSMS: 3; +CSMS: 0; +CMGF: 0;
+CSCA: "",; +CSMP: ,,0,0; +CSDH: 0; +FCLASS: 0; +FDD: 0; +FAR: 0;
+FCL: 0; +FIT: 0,0; +ES: ,,; +ESA: 0,,,,0,0,255,; +CRLP: 61,61,48,6;
+CPIN: ,; +CGATT: 1; +CGACT: (1,0),(2,0),(3,0); +CPBS: "SM";
+CPMS: "SM","SM","SM"; +CNMI: 0,0,0,0,0; +FTS: 0; +FRS: 0; +FTH: 3;
+FRH: 3; +FTM: 96; +FRM: 96; +CCUG: 0,0,0;  +CUSD: 0; +CFUN: 1; +CREG: 0;
+CGREG: 0; +COPS: 0,0,"",3; +COLP: 0; +CLIP: 0; +CLIR: 0; +CLVL: 2;
+CHLD: ; +CTFR: "",; +CCWA: 0,3,7; +CPOL: 0,2,"",0,0,0; +STPD: 0,;
+STGC: 0; +STCR: 0,"","",""; +STMS: 0,0; +STTONE: 0,1,500; +STRT: 0;
_OPOS: 0,0; _OPSYS: 0,0; _OSBM: 4; _OSQI: 0; _OGCVI: 0; _OSSYS: 0;
_OSEC: 0; _OLT: 0; _OLOOP: 0,0

OK

When you can talk to the modem as shown above you are nearly done. The card is fully supported and only some configuration is standing between you and a wireless internet connection. While at it you may want to disable the PIN on your SIM card. Otherwise you have to enter it every time the card is inserted or the system is rebooted. This can be a problem, because you can set the PIN only once. Afterwards this will produce an error. Type the following line while connected with the modem and replace "1234" with your valid PIN:

at+clck="sc",0,"1234"

If you do not want to disable the PIN, you have to enter it with the command at+cpin="1234" now. In both cases it should take only a few seconds before the blinking of both LEDs changes into a blinking of either the green (GPRS) or the blue one (UMTS) alone. The signal quality can be checked with at+csq:

at+csq
+CSQ: 15,0

OK

15 is a quite good value for UMTS. Possible levels are between 0 and 31. Now you should choose if you prefer UMTS or GPRS connections:

AT_OPSYS=0,2 GPRS only
AT_OPSYS=1,2 UMTS only
AT_OPSYS=2,2 Prefer GPRS
AT_OPSYS=3,2 Prefer UMTS

The provider is set with AT+CGDCONT, but it should already be preconfigured when receiving your SIM card. When missing, the configuration for Vodafone would be:

AT+CGDCONT=1,"IP","web.vodafone.de"

All the settings done above will be stored onto the SIM card, so we never have to bother about it again. Next step is the configuration of the internet access via PPP (point to point protocol)!

For the pppd daemon to work we have to provide a configuration and a chat script for our provider (Vodafone in this case). After activating pppd in /etc/rc.conf

ppp_peers="vodafone"
the daemon will read its options from /etc/ppp/peers/vodafone. The directories /etc/ppp and /etc/ppp/peers probably have to be created first. Then I am using a config file like this:
noauth
connect "/usr/sbin/chat -v -f /etc/ppp/peers/vodafone.chat"
/dev/ttyU0
460800
local
defaultroute
noipdefault
usepeerdns
novj
user "vodafone"
password "vodafone"
persist
maxfail 0
noauth
The provider doesn't have to authenticate itself.
connect
Specifies the chat-script to use when connecting (see below).
/dev/ttyU0
The modem device to use.
460800
Usual bps rate for UMTS.
local
Don't use modem control lines. Not required for UMTS.
defaultroute
Set the default route to this PPP connection, after it has been successfully established.
noipdefault
The provider supplies us with a local IP address during IPCP negotiation.
usepeerdns
Query the provider for DNS addresses and create /etc/ppp/resolv.conf with it.
novj
Diable Van Jacobsen header compression (Vodafone doesn't support it?).
user "vodafone"
User name for authentication.
password "vodafone"
Password for authentication.
persist
Always try to reconnect, when the connection fails or is lost.
maxfail 0
Never give up after failed connection attempts.

The chat-script (/etc/ppp/peers/vodafone.chat) is not much more than a simple dialing of *99***1#:

TIMEOUT 3
ECHO ON
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE'
ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED
'' '\rAT'
'' ATZ
TIMEOUT 6
OK 'ATDT*99***1#'

As soon as a connection to the provider was established successfully, we have a valid default route and a recent resolv.conf in /etc/ppp/. Now you could either use /etc/ppp/ip-up to copy resolv.conf or just create a link:

# cd /etc
# ln -s /etc/ppp/resolv.conf resolv.conf

That's all. Every time the system is booted you will be connected to the internet via UMTS, provided it is available. Now some fine tuning could be done. For example to delay pppd until /dev/ttyU0 is ready, or to allow LAN connections via DHCP, when you returned to your office.


Frank Wille, September 2008