Linux Wireless Networking
By Sreekrishnan Venkateswaran2005-05-04
Linux GPRS and Data over GSM
GPRS is a packet service for carrying data over GSM, the prominent digital cellular standard. While data over GSM is circuit-switched and occupies a channel irrespective of usage, data over GPRS is an always-on, packet-switched data stream where users pay according to usage. GSM speeds are typically 9.6 kbps, while GPRS can run at speeds of 56 kbps to 170 kbps.
GPRS and GSM chips usually have a UART interface to the system. For a board with built-in GSM/GPRS support (for example, a board with a Siemen's MC-45 module wired to a UART channel), the legacy serial driver can drive the link. For a PCMCIA/CF form factor (an Options GPRS card, for example), serial_cs, the generic card service driver to access PCMCIA serial devices, allows the rest of the operating system see the card as a serial device. The first unused serial device (/dev/ttySx) gets allotted to the card, which can then be accessed as if it where a serial device. serial_cs can also emulate serial ports over Global Positioning System (GPS) PCMCIA and CF cards. For USB GPRS modems, a USB-to-serial converter typically converts the USB port into a virtual serial port so the rest of the system sees it as a serial device.
The GPRS network connects to an external network (like the Internet) using a GGSN (Gateway GPRS Support Node). A GPRS device, which resembles a modem with an extended AT command set, must define a context using an AT command before it enters data mode. The context string looks like the example shown in Listing 3.
Listing 3. Context string
'AT+CGDCONT=1,"IP","internet.voicestream.com","0.0.0.0",0,0'In this example, 1 stands for a context number, IP is the packet type, internet.voicestream.com is an Access Point Name (APN) string, 0.0.0.0 means that the service provider chooses the IP address, and the rest of the parameters relate to data and header compression. The APN string depends on the service provider. A user name and password are usually not needed.
PPP allows networking protocols such as TCP/IP run over a serial link. In the context of wireless networks, PPP can get TCP/IP running over GPRS, data over GSM, Bluetooth RFCOMM, and IrDa IrCOMM. Listing 4 shows a common syntax for invoking the PPP daemon, pppd.
Listing 4. Common syntax for invoking the PPP daemon, pppd
pppd ttySx call connection-scriptIn this example, ttySx is the physical or virtual serial device over which PPP runs, and connection-script is a file in the /etc/ppp/peers/ directory that contains the AT command sequences exchanged between pppd and the service provider to establish a link. After establishing a link connection and completing authentication, PPP starts a Network Control Protocol (NCP). IPCP (Internet Protocol Control Protocol) is the NCP for running IP. Once IPCP successfully negotiates IP addresses, PPP starts talking with the TCP/IP stack.
Listing 5 shows an example PPP connection script for connecting to a GPRS service provider, while Listing 6 shows a connection script for data connection to a GSM service provider.
Listing 5. A sample pppd connection script for GPRS (/etc/ppp/peer/gprs-script)
115200From an operating system's perspective, data over GSM resembles sending and receiving data over a dial-up modem connection. The Internet Service Provider's (ISP) phone number is dialed using GSM and a dial-up connection is established. Authentication occurs with a user name and password.
connect "/usr/sbin/chat -s -v "" AT+CGDCONT=1,"IP",
"internet2.voicestream.com","0.0.0.0",0,0 OK AT+CGDATA="PPP",1"
crtscts
noipdefault
modem
usepeerdns
defaultroute
connect-delay 5000
Once PPP establishes an IP connection to the service provider, TCP applications such as Web browsers can run unchanged over the GSM/GPRS device.
The gsmlib project provides utilities for voice and SMS (Short Messaging Service) messaging over GSM (see Resources for more on gsmlib). It contains utilities to access the phone book in the Subscriber Identity Module (SIM) card, send and receive SMS messages, and so on.
Listing 6. A sample pppd connection script for data over GSM (/etc/ppp/peer/gsm-script)
115200
connect '/usr/sbin/chat -s -v ABORT "NO CARRIER" ABORT "NO DIALTONE" ABORT "BUSY" "" AT OK
ATDT<phone_number> CONNECT'
crtscts
noipdefault
modem
user "linux"
usepeerdns
defaultroute
connect-delay 5000
Tutorial Pages:
» A Look at WLAN, Bluetooth, GPRS, GSM, and Infrared Data on Linux
» Linux 802.11 WLAN
» Linux Bluetooth
» Linux GPRS and Data over GSM
» Linux Infrared Data
» Performance Issues
» Conclusion
» Resources
First published by IBM DeveloperWorks
