Get Your Modem Up and Running

You have mastered the intricacies of the X Window System, your sound card is finally working, Linux is installed successfully, and everything seems fine -- everything except that one final, nagging question: How do you get that darned modem to work?

You have mastered the intricacies of the X Window System, your sound card is finally working, Linux is installed successfully, and everything seems fine — everything except that one final, nagging question: How do you get that darned modem to work?

Judging from the mail I’ve received on the subject, getting your modem up and running is one of the last great hurdles between Linux misery and Linux happiness, so this month we’re going to cover the basics of modem configuration.

I don’t have space to cover all types of modems here, so I’m going to focus on connecting with telephone modems. If you have ISDN, you should find documentation in your distribution (/usr/src/linux/Documentation/isdn). In any case, there is a lot more documentation on the Web.

As usual, start with the Web site for your particular distribution. At http://alumni.caltech.edu/~dank,there is some good information on ISPN configuration, as well as several pointers to more information on DSL, ADSL, and cable modems.

Ports and Modems

A computer has a number of connections between the inside of the box and the outside world. Many are specific in nature; the keyboard connector will talk only to your keyboard and to absolutely nothing else, not even to your mouse.

General-purpose connections to the outside world are called “ports.” Most PCs come with two serial ports and one parallel port. Serial ports transmit data over one wire in a serial fashion, one bit at a time, and then reassemble it into bytes. Parallel ports use eight wires to send eight bits in parallel at one time. Most printers for home use connect to the PC’s parallel port.

A modem is a device that lets you send digital information over a telephone line. This is common these days, but remember that the telephone system as we know it was originally designed to carry voice only. The modem was a breakthrough technology that modulates the digital data, converting it into an analog signal that can be sent over a telephone line. At the receiving end, the analog signal is converted back into digital information (demodulated, in techspeak). Modem is short for modulator-demodulator.

Modems were invented when everyone used serial ports. They were separate boxes that sat outside of the computer and connected to the serial port with a cable. You can still get these external modems today, though most are now cards that plug into the computer motherboard. These are internal modems. Since most PCs already come equipped with two serial ports, internal modems usually add a third port.

Your Linux system should certainly be able to talk to the existing built-in serial ports, so setting up an external modem is generally a pretty simple affair. Just connect a cable from the serial port to the modem, connect the modem to the phone line, plug in the modem, and turn on the power. Most external modems will simply work. If you have difficulty, look at the Modem-HOWTO.

When connecting to your ISP, your Linux box will need to use the Point-to-Point Protocol (PPP) software in order to transmit the Internet’s TCP/ IP protocol over your modem. PPP is part of most Linux distributions, and a number of graphical programs, including Kppp (see the Dialing up the Easy Way with Kppp sidebar, below), will get it up and running on your computer. Once your modem is plugged into your computer, you can launch Kppp and use its setup options to completely configure your modem.

Get the Right Modem

When internal modems were first introduced, the board that you inserted into your computer had all the circuitry it needed, and the board had jumpers or switches on it to set the address.

Hardware manufacturers are always looking for ways to reduce costs. As PCs have become more powerful, modem makers have removed circuitry and replaced that functionality with software. These Winmodems are cheaper, and the device driver that comes with the Winmodem performs some of what used to be done in hardware that was on the modem card.

The problem is that Winmodem drivers are written for Windows, not Linux. There’s no reason why such a driver can’t be written for Linux; however, this is up to the modem manufacturer, and so far none have chosen to do this. This means that they don’t work with Linux. Period. If your computer has a Winmodem in it, it won’t work under Linux. If you buy a modem for your Linux box, make sure it’s not a Winmodem.

When you set off to buy a modem, it’s best to go to your computer store armed with a Linux modem compatibility list. That way you can be sure to buy a modem that is proven to work with Linux. You can find this list at http://www.o2.net/~gromitkc/winmodem.html. As a rule of thumb, if the modem says “HCF,” “HSP,” “Winmodem,” or “soft modem” on the box, it probably won’t work. If the modem is “controller based,” then it will almost certainly work with Linux.

Which Bus Are You On?

Most of the guts of your PC are on the large board with the processor (CPU) and memory known as the motherboard. This board has several connectors on it that you plug expansion cards into — things like the video card and the modem. Many of the newer motherboards include all of these functions already, so you don’t need to plug in any expansion cards. I haven’t tried one of these yet, but I understand that in many cases the built-in modem works fine with Linux.

These connectors on the motherboard connect to the system bus. There are several bus designs around. Older PCs use the ISA (Industry Standard Architecture) bus, while newer PCs use the PCI (Peripheral Component Interconnect) bus. There are other buses around, but you probably won’t run into them. These buses are physically and electrically incompatible. You physically can’t put an ISA card into a PCI slot, so know which bus you have. Unless your PC is several years old it’s likely to be PCI.

Interrupts, Addresses, and PnP

Before your computer can talk to a new card it must know the I/O (Input/Output) address and the interrupt request line for that card.

When the computer wants to talk to a card plugged into the system bus, it selects which card it wants by sending an I/O address. A card will respond only to its own address, and each card must respond to a different address. Two cards can’t use the same address.

Interrupts are a little more complicated. When you select a URL with your browser, the Web site is contacted and data begins coming in to your modem. Meanwhile your computer is busy doing other things: watching the mouse, printing, stuff like that. You don’t want the computer to focus exclusively on one thing, so the modem needs a way to electrically tap the computer on the shoulder to say, “Excuse me, here’s some more data for you.” This is an interrupt.

Each interrupt is a separate wire inside the computer (called an IRQ, which stands for Interrupt ReQuest). There are several, and their assignments must be known. When an interrupt comes in from the modem you would not want to go check the mouse instead.

Older expansion cards had switches or jumpers with which you would set the I/O address and the IRQ. This made it very easy to mistakenly set two cards at the same address or IRQ. To improve on this, computer and software makers have agreed on a standard that allows the computer to query each card independently and then to assign the I/O address and IRQ. Not only does this make the process automatic, but it means that conflicts can be avoided. This standard is known as “Plug and Play” (PnP).

When you turn on your computer the first software to start up is the BIOS (Basic Input Output System). This wakes up all of the pieces of your computer, does a quick check to see what’s installed, and then loads the operating system. Much of the configuring of the PnP devices is done by the BIOS, though some of it may be done by the operating system. PnP support in Linux is not yet complete. While many PnP devices are configured and will work, some will not.

Don’t despair if Linux doesn’t initialize your PnP device. It may be possible to fix this. Look for the documentation on the isapnp tools. The Modem-HOWTO can also help. If you’ve chosen a modem that is listed in the compatibility list, whether it is PnP or not, it will probably work without any extra effort.

The three most common problems in installing a modem are conflicts with I/O address or IRQ settings, the use of a Winmodem, or incomplete PnP support, which causes your modem to be misconfigured.

Which Port?

Once you have your modem connected, how can you find it?

If your modem is external, then you know whether you’ve connected to COM1 or COM2. If your modem is internal then it may be on COM3. These are the names of the serial ports in the Microsoft world. In Linux, COM1 is called /dev/ttyS0, COM2 is /dev/ ttyS1, and COM3 is /dev/ttyS2. If your Linux distribution is slightly older, the COM ports may be called /dev/cua0, /dev/cua1, and /dev/cua2, respectively. If your modem is configured during Linux installation then there will be an entry in your /dev directory named /dev/modem.

This should be a link to the correct port for your modem. To find out where /dev/modem is pointing, enter the command file /dev/modem in an X terminal. It should return something like this:

/dev/modem: symbolic link
to ttyS2

Newbies Modem LS 1
Figure One: Checking permissions for /dev/modem.

This means that the modem is configured for COM3. If /dev/modem exists and does not point to your modem’s port, then remove the link. Some Linux distributions come with a utility named modemtool with which you can create the correct link.

Make sure that all users have permission to access /dev/modem and the corresponding serial port (Figure One).

As always, the Linux HOWTOs are a great place to continue your quest for answers. You may find the HOWTOs in your /usr/doc/ HOWTO directory on your system. If they’re not there, check out http://www.linuxdocs.org. Start by looking at the Modem-HOWTO if the answer to your question is not covered in this column.

Dialing up the Easy Way with Kppp

Newbies kppp 1 Newbies kppp 2
Figure One Figure Two
Newbies kppp 3 Newbies kppp 4
Figure Three Figure Four
Newbies kppp 5 Newbies kppp 6
Figure Five Figure Six

If you use KDE, then Kppp is an excellent tool that can help you set up and manage your connection to your ISP. It’s available with most Linux distributions. You’ll need to collect some information like your user name, password, dial-up number, and DNS addresses from your ISP in order to get things up and running, but here’s how it works:

Step 1. Configure Kppp to work with your modem.

First, start up Kppp (if you can’t find it in your KDE menu, try the command /usr/bin/kppp).

Press the “Setup” button. The first thing to do is to let Kppp know where your modem is. In the configuration window that pops up, select the “Device” tab (Figure One).

Left-click on the arrow next to the “Modem Device:” window to see a pulldown list of possible modem ports. Select the port that you think your modem is attached to (in mine it’s /dev/modem). Similarly, set your “Connection Speed:” to 115200 (or higher if you know that your computer is capable of it).

Step 2. Test your modem.

To test your modem, select the “Modem” tab (Figure Two). Press the “Query Modem” button, and a window will pop up to show you the progress as your modem is probed. Make sure that the “Modem Volume” setting is set to around the middle of the bar, so you can hear if your modem is working. If successful, then the window will show information like Figure Three.

If your modem is not found, then you can go back to Step 1 and try another port (or modem speed).

Step 3. Set up a new account.

You’re ready now to set up the account. Return to the “Accounts” tab and choose “New” to set up a new account (Figure Four).

Now, under the “Dial” tab, pick a name that will help you remember who it is you are dialing (I recommend that you use the name of your ISP) and enter it in the “Connection Name” field. Then make sure to add the dial-up number of your ISP in the “Phone Number field.”

Now choose the “IP” tab and check the “Dynamic IP Address” box. (Keep this box unchecked if your ISP has assigned you a fixed IP address). Under the “DNS” tab, enter the IP addresses of the name servers that have been provided by your ISP (Figure Five).

Next, choose the “DNS” tab and enter the domain name and DNS IP addresses given you by your ISP (Figure Six).

Click “OK” to save your new account. Then click “OK” again to exit the “Configuration” window.”

Newbies kppp 7
Figure Seven

Step 4. Connect.

You should now see the original Kppp window. Enter your user name and password, and then click the “Connect” button (Figure Seven).

If your computer can talk to your modem it will now try to dial out to your ISP. You should hear the dial tone and the dialing.

Testing the Modem with Minicom

Newbies Minicom 2
Figure One: The minicom setupmenu.
Newbies Minicom Serial 2
Figure Two: The minicom serial port setup menu.

One of the first things you should do after connecting your modem is to test to see if it works. You can do this with the Kppp dialer (Step 2 in the Dialing up the Easy Way with Kppp sidebar on pg. 34), but if that doesn’t work for you, you can try a little Linux utility called minicom to test your modem.

The very first time you run minicom, you’ll need to run the setup mode to tell it which port you are using. Typing the command minicom -s in an X terminal will bring up a menu like the one in Figure One (you may need to log in as “root” to do this). The only field you need to be concerned with is “Serial port setup” (Figure Two).

Be certain that the serial device is set to the correct port. For an internal modem the maximum speed (“Bps”) should be just fine. Make sure you are no longer logged in as root after you have set things up. You can type exit to get out of root.

Newbies Minicom Sample 3
Figure Three: Modem response.

With minicom configured, you should now be able to type commands directly to your modem. Most modems understand the “Hayes Protocol” (see the Hayes Protocol sidebar on pg. 98). Try the command, AT. If your modem is working, you should get the response OK (Figure Three). If you don’t get this response, then you may be talking to the wrong port, the modem may be broken, or the modem might not be able to handle the speed or settings you entered.

Another possibility is that the modem may be programmed to be in a “silent” mode. Try the command ATE1Q0V1. This tells the modem (if it’s listening to you) to echo back your commands and acknowledge them.

Hayes Protocol

Like so many other things in the computer world, standards are often set by the first company to succeed in a particular market. One of the first truly successful modem manufacturers was a company named Hayes. Hayes created a very terse language that could be used to control its modems, which became known as the “Hayes Protocol.” It is recognized today by almost all modems. All Hayes-protocol commands start with the letters AT. Commands may be strung together on a line after this first single AT. While the protocol is pretty much universal, some modems do not support all its features. For the complete command set for your modem, check your owner’s manual or the Web site of the manufacturer.

The basic commands that most modems support and with which you should be familiar are:

Z (re)initialize / reset

H hang up

Ln speaker volume (L0 = lowest, L1 = low, L2 = medium, L3 = high)

Mn speaker control (M0 = off, M1 = off after connect, M2 = always on)

Vn result format (V0 = short results, V1 = long results)

En command echo (E0 = no echo, E1 = commands are echoed)

Hal Moroff has been developing Unix systems and applications for 20+ years. He’s new enough to Linux that he’s finding new things every day. He can be reached at halm@ieee.org.

Comments are closed.