Mobile Network Services with Linux
GSM (Global System of Mobile Communications) short messages have become tremendously popular in just a few years. Popularity of Short Message Services (SMS) was not foreseen and surprised telecommunication companies, but its popularity had an effect. For wireless phones it meant larger displays for easier reading, predictive language input software and external keyboards. For telecommunication companies this meant improvements to message centers, new services and huge revenues. Such a large set of users sending messages to each other spurred operators to bring a huge set of SMS services to the markets, such as weather forecasts, timetables, sports results, stock information, etc. Of course all events do not have to be initiated by the user. You can also get positive notification by e-mail, network alarms, news, etc., on your wireless phone.
Nowadays close to 500 GSM operators exist in 158 countries. Most of the operators provide the ability to send SMS messages. SMS services also function abroad where the GSM operators have voice roaming agreements and SMS service is available.
SMS usage is still growing strongly. In October 1999, two billion SMS messages were sent. Three billion messages were sent in December 1999. Naturally, the millennium celebrations contributed to the increase, but still the growth was tremendous. In May 2000, about eight billion SMS messages were delivered, and ten billion messages per month were sent by December 2000. The price per message is something like $.25 US per message, so it is a cheap way to communicate.
Among youngsters, ring tones, logos and picture messages have achieved great popularity. These are also based on SMS technology, and there are lots of service providers who offer this kind of service, such as http://www.jippii.fi/. It is easy to come up with plenty of applications such as e-mail notification, burglar alarm, calendar events and network alarm.
SMS messages also have their weaknesses. The length of each message is limited to 160 characters. This forces users to send more messages to transfer larger amounts of data. For example, if you want to read an e-mail from a friend, she may have to send several SMS messages before you get the whole message. On the other hand, if you want to send an e-mail from your phone, you'd better use short expressions.
The major threat for SMS services is new technology. General Packet Radio Service (GPRS) is based on GSM technology and will complement existing services. It will also facilitate new applications that haven't been available over GSM networks. Compared to GSM, it is clearly faster, and unlike SMS, it doesn't have a 160 characters per message limitation. GPRS may decrease SMS traffic, but it will take a while for the mass of users to shift their mobile phones to GPRS-compatible models.
In North America, there were only 7.4 million GSM customers in June 2000, while in Western Europe the number was as high as 215.4 million. There would be huge markets in the US if GSM became more popular, but forecasts assume there will be only 21 million customers by the end of 2004. It is possible that by then the number of short messages won't increase further, but this is all speculation. Europe, especially Finland, seems to be full of SMS service providers, but there is still room for new services and new ideas. Using SMS can still be a hit anywhere in the world.
There are multiple ways to send a message to your wireless phone: another wireless phone, gateways for modem and Internet-based connections, internet sites or wireless modem.
Wireless phone companies offer gateways to their networks through which messages can be sent. Companies usually charge quite a bit for service initiation, monthly charges and per message charges. These charges are often too high for just occasional message sending and receiving. Internet sites, which allow people to send free short messages, are usually not very reliable. Their operation is usually based on temporary free SMS message-sending provided by some telecommunications company.
Our solution is to use a wireless modem. Connect a wireless modem to your computer and use it almost like a regular modem. Wireless PCMCIA (Personal Computer Memory Card International Association) versions are widely available, and many wireless phones can be connected via serial or infrared connection to your PC. There are specific AT commands (standardized command set for modems) for sending and receiving SMS messages and managing SIM-cards from terminal programs.
SMS messages are sent to message centers and from there they are forwarded to the receiver. GSM allows users to roam from one network to another. The receiver does not have to be reachable at all times as messages are stored temporally at a message center. This is great news for people who do not have access to a network all the time. A traveler can send a message to a spouse from an airport in Great Britain, switch off the phone before flying to South Africa and receive reply messages upon switching the phone back on at arrival time. Note that SMS messages are not guaranteed to be reliable, and message centers purge them at some point. Expiration time is usually three days, but it is known to decrease to even one hour during extremely heavy traffic.
This example of an SMS gateway is based on a Nokia Communicator phone. It is connected to a Linux machine with a serial cable. Other phones have their own way to establish the connection, but the AT commands we use should be universal. We wrote a small program to communicate with a serial port. This could also be done with any terminal program. Before you start using it, make sure that you have access permission for the communication port. You may have to change /dev/ttySx where x is the port where Communicator is connected. If you have connected your device to COM1, x is 0; while using COM2, x is 1. To proceed you must set Communicator so it will take commands from the serial cable. Select ``Fax modem'' from ``System'' menu and enter the ``Settings'' area. This is Communicator-specific. You probably have to do something similar with other GSM phones. With PCMCIA card phones and GSM modems you can skip this. Remember to set communication parameters correctly. Our software works with data bits set to eight, stop bits set to one and parity set to none. After that you have to activate Communicator by selecting ``Activate'' in the Fax modem folder. Before sending or receiving any short messages, make sure that the message center number is set. You can query if message center is set by giving this command:
You can see from the reply below that the message center is not set. As there is no phone number between quotation marks, it may be preset by your wireless phone company.
+CSCA: ""129 OKMessage center number is set by saying:
AT+CSCA="center_number",145 OKParameter 145 indicates that the message center address is given in international format. This allows international access. Be aware that the number contains the ``+'' character. Remember to use your service provider's message center; others might not accept your messages for delivery.
Now the message center query will return the given number. We also have a little program to do this called smscenter. But before you can run it, you have to modify the configuration file sms.cfg. You have to tell the program which port your device is using.
After the phone has been connected to the computer successfully and required configuration is done, it is possible to send a message. You can try sending a short message to a friend's GSM:
AT+CMGS="phone_number" >This is my first message with Linux PC.^Z
This AT command sends a message to the network. The phone number should be written in international format. After typing the command you can type your short message. You can cancel sending by using the Esc key. When you have typed the message body you must press Ctrl+z. Then the message will be sent.
We wrote a program called smssend that allows users to send a short message from a command line. It requires two arguments: the receiver's phone number and the message body. Listing 1 should give you an idea of how the program functions.
Receiving messages is a bit more complicated than sending messages. To do this, Communicator is set so that messages are given directly to our program and not stored on the phone. This could also be called ``on-line data mode''. You can set the device to this state by saying:
Our program, called smsreceive, sets this state automatically so you don't have to pay attention to it. After that, just listen to the serial port, and read the arriving messages from there. Listing 2 demonstrates the idea of receiving short messages.
With the capability of sending and receiving messages, interactive systems can be built. By combining these two features you can build up huge amounts of services. It is easy to come up with corporate systems that can take advantage of SMS messages.
A few possibilities for interactive systems:
Request previous e-mail subjects or 160 characters from a specific e-mail.
Request next five buses to downtown after 9 o'clock.
Get stock quotes and buy selected shares.
Update calendar remotely.
Short messages can be forwarded to e-mail by sending them to a SMTP (simple mail transfer protocol) mail transfer agent (MTA). You can easily test this by connecting to port 25 of the SMTP server in your domain. Remember that lines must end with a carriage return and a new line pair. Acceptance of the command can be seen from the reply sent by the MTA for each command. First, MTA is greeted with the HELLO command. After this, origin is sent by the MAIL command and the recipient by the RCPT command. The message itself comes after the DATA command. The ``From:'', ``To:'' and ``Subject:'' fields are for the mail reading program. Writing the body of mail is terminated by single line with only one period on it. The transaction with MTA is ended with QUIT, after which mail should be on the way. After each of these commands the server responds with numeric reply codes and understandable strings from which we can conclude that the transmission was successful.
We also built up a little service by combining two separate sending and receiving features. The idea was that we were listening for incoming short messages. When we got one, we first solved where it was coming from, and then we examined the content of the short message. If text ``events'' existed we collected them for three months from a database and sent them back to the phone from where the request was coming.
It is easy to build up different services or make some limitations. If, for example you want to limit access to your service, it can easily be done by comparing the phone number where requests come from to the list of allowed/prohibited users. Naturally, this doesn't prevent them from sending messages to your phone, but at least you don't have to answer and pay the bill for sending. In some countries you may be charged for receiving a short message. Check with your service provider.
While our example is based on the Nokia Communicator, there are other programs available for different kinds of phones and data cards. Data cards would probably be the best and simplest choice for creating this kind of service, and our programs can easily be modified to these kind of devices.
The gnokii Project has developed tools and drivers for particular models of Nokia phones. It provides a graphical interface to use phones from your computer. Another project is SMS Client, a UNIX command line-based utility that is coded for sending short messages but does not receive messages. For receiving short messages you can use SMS Link instead.
We would like to thank Nokia for loaning the Nokia Communicator 9000i, which was used in the testing.
Jouni Ikonen is currently working as a research engineer at Lappeenranta University of Technology. His interests include distributed simulation, wireless networks and data communications. He is currently leading a project to deploy a city-wide wireless IP network for home and mobile users (hey, does anybody have an open-source ``access point'' for Linux?). Jari Porras is the head of the telecommunications laboratory at Lappeenranta University of Technology. His interests include wireless networks, Bluetooth and distributed computing/simulation. Harri Hämäläinen is a third-year student of information technology at Lappeenranta University of Technology. His interests include wireless networks and data communications. He is currently developing SMS applications.