Modems


Modems

Modem is a contraction of modulator/demodulator-and is a device that converts digital signals (string of 1s and 0s) into continuously varying analog signals that can be transmitted over telephone lines and radio waves. Thus, the modem is the intermediary between the digital world of the PC and the analog world of telephones. Figure E-1 illustrates the concept of a modem.

Click To expand
Figure E-1: A Modem Bridges the Digital World of PCs and the Analog World of Telephones.

Inside the PC, 1s and 0s are represented with voltage levels, but signals carried over telephone lines are usually tones of different frequencies. The modem sits between the PC and the telephone line and makes data communication possible over the phone lines. The modem converts information back and forth between the voltage/no voltage representation of digital circuits and different frequency tones that are appropriate for transmission over phone lines.

Caution 

A quick word of caution about Winmodems that come with many new PCs and laptops. These are largely software-based internal modems and totally different from the traditional hardware modems. Winmodems work only with special software, so they are often called software modems. See the 'Winmodems and Linux' section for more on Linux support for Winmodems.

The communication between the PC and the modem follows the RS-232C standard (often stated as RS-232, without the C). The communications protocol established between two modems also follows one of several international modem standards. The next few sections briefly describe these standards.

RS-232C Standard

The RS-232C standard, set forth by the Electronic Industries Association (EIA), specifies a prescribed method of information interchange between the modem and the PC's serial-communication hardware.

Note 

In EIA terminology, the modem is data communications equipment (DCE), and the PC is data terminal equipment (DTE). You'll see references to DCE and DTE in discussions of the RS-232C standard.

A modem can communicate in one of two modes:

  • Half-duplex mode-Data transmission can occur in only one direction at a time

  • Full-duplex mode-Enables independent two-way communications

Most modems communicate in full-duplex mode.

RS-232C Cables

The RS-232C standard also provides control signals, such as Request to Send (RTS) and Clear to Send (CTS), that can be used to coordinate the transmission and reception of data between the PC and the modem. Handshaking refers to the coordination of the data exchange.

Handshaking signals, as well as data transmission and reception, occur through wires in the cable that connects the PC to the modem. The RS-232C specifies a 25-pin connector, with a specific function assigned to each pin.

A typical modem has a female 25-pin, D-shell connector (called the DB-25 connector), whereas the PC's serial port provides a male nine-pin, D-shell (DB-9) connector. Thus, to connect a PC's serial port to a modem, you need a cable with a female DB-9 connector at one end and a male DB-25 connector at the other end. The typical PC-to-modem cable is often sold in computer stores as an AT Modem Cable.

Some PCs have a DB-25 connector for the serial port. For these machines, you need a cable that has DB-25 connectors on both ends.

Of the 25 pins available in a DB-25 connector, only nine are used in the PC's serial port. In the Serial/Parallel Adapter card for the PC-AT, IBM decided to save space by introducing a DB-9 connector.

Using Modem Cables (DTE to DCE)

When you connect a PC (DTE) to a modem (DCE), the cable should connect the like signals at both ends. A cable that has such connections is often called a straight-through cable, as it connects like signals to each other.

Using Null Modem Cables (DTE to DTE)

If you want to connect two PCs through the serial port, you cannot use a straight-through cable like the one that connects the PC to a modem. The reason is that each PC expects to send data on the TD line and receive data on the RD line. If both PCs send data on the same line, neither PC can hear the other. A solution is to create a cable that connects one PC's output (TD) to the other one's input (RD), and vice versa. Such a cable is known as a null modem cable.

Choosing Serial Cables

When you connect two devices that support RS-232C serial communications, the choice of cable depends on the type of each device: DTE or DCE. As I mention previously, the PC is a DTE, and a modem is a DCE. Many printers and terminals are DTEs.

Use a straight-through modem cable to connect a DTE to a DCE. To connect a DTE to a DTE, you need a null modem cable. Many computer stores sell null modem adapters. You can connect two DTE devices by using a modem cable with a null modem adapter.

Insider Insight 

Notice that the serial interface on the Hewlett-Packard LaserJet family of printers is configured as a DTE. Thus, you need a null modem-style cable to connect a PC's serial port to a LaserJet printer. Unfortunately, serial printer cables (for connecting a printer to the serial port) introduce a further complication. Printer manufacturers interpret some of the RS-232C signals in a printer-specific way. Thus, you may have to connect various signals in a specific way to use a printer with a serial interface.

Flow Control

The RS-232C standard includes the RTS/CTS signals for hardware handshaking between the communicating devices (such as the PC and the modem). In addition to this hardware flow control, special ASCII control characters (Ctrl-Q/Ctrl-S, or XON/XOFF) are typically used to implement flow control in software. Flow control is necessary because sometimes the receiver may not be able to keep up with the rate of data arrival and should be able to inform the sender to stop data transmission while it catches up.

Suppose that a receiver has a buffer to store incoming characters. As the buffer gets full, the receiver can send the XOFF character (Ctrl-S) to the transmitter, indicating that transmission should stop. If the transmitter understands the meaning of the XOFF character, it can stop sending data.

Then, when the receiver empties the buffer, it can send an XON character (Ctrl-Q) to indicate that transmission can resume. This scheme of flow control is used in many communications programs because it is simple. This is unfortunate; when the XON/XOFF protocol is used, the XON and XOFF characters cannot be part of the data because of their special meaning.

Note 

The software-based XON/XOFF flow control is not used with modem speeds faster than 9,600 bps because it slows down data transfers. Most high-speed modem connections use hardware flow control only.

Modem Standards

As the Internet and online services have grown in popularity, the demand for modems that offer high data-transfer rates has grown accordingly. Early modems transferred data at the rate of 300 bits per second (bps), whereas the latest modems can transfer at rates of up to 56,000 bps-which represents an increase of more than a hundredfold in modem performance. To achieve these high data-transfer rates, modems use many tricks, including compressing the data before sending it. As you might expect, two modems can communicate successfully only if both modems understand how to interpret the signal being exchanged between the two. This is where the standard modem protocols come into play.

Note 

The International Telecommunications Union (ITU) has ratified several modem standards in use today. These standards have names that start with V. The latest standard is V.90, which supports data-transfer rates of 56,000 bps (more precisely, 56,000 bps downstream and up to 33,600 bps upstream). The V.90 standard is also called V.PCM because it uses a technique known as pulse code modulation (PCM). Table E-3 lists some of the common modem standards used today.

If you need the exact text of the ITU Series V recommendations, as these data communication standards are called, you can purchase copies from ITU's website at http://www.itu.ch/itudoc/itu-t/rec/v/. The site offers the files in English, French, and Spanish, and in a number of file formats, including Microsoft Word for Windows, Adobe's Portable Document Format (PDF), and PostScript.

Table E-3: Modem Standards

Standard Name

Maximum Data-Transfer Rate (bps)

Bell 103

300

Bell 212A

1,200

V.17 (Group III Fax)

14,400

V.21

300

V.22

1,200

V.22bis

2,400

V.23

1,200

V.27ter (Group III Fax)

4,800

V.29 (Group III Fax)

9,600

V.32

9,600

V.32bis

14,400

V.34

28,800

V.90

56,000 downstream and up to 33,600 bps upstream

V.91

Up to 64,000 bps for use on a 4-wire circuit-switched connection and on leased point-to-point 4-wire digital circuits

When you buy a modem, make sure that it conforms to these international standards. Currently, the ITU V.90-compliant 56K modems are the norm.

Modem Commands (AT Commands)

The now-famous AT command set first appeared in the 300-baud Hayes Smartmodem, a name coined and trademarked by Hayes Microcomputer Products, Inc. The Smartmodem worked in two distinct modes:

  • Command mode-Characters sent from the PC (DTE) are interpreted as commands for the modem.

  • Online mode-After receiving a dial command and establishing a connection, the modem sends all received data out on the phone lines.

The Hayes Smartmodem commands start with the characters AT (for attention). The initial command set included those to dial a number, turn the modem's speaker on or off, and set the modem to answer an incoming call.

Modern manufacturers have widely copied the AT command system, making it a de facto standard. Although virtually all modems use a core command set, each modem manufacturer has its own proprietary commands that control some of the exotic and advanced features of the modem.

The AT Command Line

I have found it very helpful to know at least a few of the AT commands for controlling a modem. Although many communications programs hide the details of the AT commands, you can end up in a situation in which the communications software is primitive-all the software does is send the other modem whatever you type. In such situations, you can enter AT commands to set up the modem, dial out, and establish a connection. The following sections briefly cover the AT command set.

As the name implies, each command in the AT command set starts with the letters AT. Following these letters, you can enter one or more valid commands and end the command line with a carriage return (press Enter on the PC's keyboard). Thus, the command line has the following format:

AT[command1][command2]...<CR>

[command1] and [command2] denote optional commands, each of which has appropriate arguments. The ending <CR> is a required carriage return (the Enter key).

Suppose that you want to use the following commands:

  • The E command with an argument of 1 to force the modem to echo the commands

  • The V command with 1 as the argument to make the modem provide verbose result codes (instead of numeric codes)

You can send these commands to the modem with the following AT command line:

ATE1V1

As with any AT command line, of course, you have to end this command by pressing Enter. If you enter this command through a communications software package, you see that the modem replies with the string OK.

Note 

All modems accept at least 40 characters per command line, in which the character count includes the AT and the final carriage return. Many modems, however, can accept up to 255 characters on an AT command line.

If an internal modem stops responding to the AT commands, you may have to shut down the system and power it off to reset the modem.

The A/ Command

The A/ command is an exception to the AT command syntax. If you enter A/ as the only command on a line by itself (no need to press Enter), the modem immediately repeats the last command line it has received.

Configuration Commands

These commands specify how the modem should operate and how it responds to commands. Following are some useful configuration commands:

  • Echo commands-ATE1 causes the modem to display a command as you type it; ATE0 disables the display of the command.

  • Speaker volume-The ATLn (n being a number between 0 and 3) command sets the volume of the modem's built-in speaker. ATL0 and ATL1 set the volume to low, ATL2 sets it to medium, and ATL3 sets it to high.

  • Speaker control-ATMn (n being a number between 0 and 2) controls whether and when the modem's speaker is turned on. ATM0 turns the speaker off, ATM1 turns it on until a call is established, and ATM2 turns it on always.

  • Quiet mode-When quiet mode is enabled, the modem does not acknowledge commands or report call status. ATQ0 disables quiet mode and causes the modem to respond to commands and show call status. ATQ1 enables quiet mode.

  • Verbose mode-When verbose mode is enabled, the modem acknowledges commands and reports call status with words. Otherwise, it responds with numeric codes (which may be more suitable for communications software than for humans). The ATV1 command turns on verbose mode; ATV0 turns it off. A typical modem generates the nine responses listed in Table E-4.

    Table E-4: Responses* from a Typical Modem

    Numeric Response

    Word Response

    0

    OK

    1

    CONNECT

    2

    RING

    3

    NO CARRIER

    4

    ERROR

    5

    CONNECT 1200

    6

    NO DIALTONE

    7

    BUSY

    8

    NO ANSWER

* Most modems include several other responses for reporting successful connections at higher data rates.

  • Result code selection-The ATXn command selects the type of reports the modem should send back. The argument n can be one of the following:

    0 CONNECT

    1 CONNECT bits-per-sec

    2 CONNECT bits-per-sec, NO DIALTONE

    3 CONNECT bits-per-sec, BUSY

    4 CONNECT bits-per-sec, NO DIALTONE, BUSY

  • View stored profiles-The AT&V command causes the modem to display the current values of a selected set of configuration parameters and the values of internal registers. Some modems have nonvolatile memory to store groups of settings, known as profiles. On such modems, AT&V displays the stored profiles.

Action Commands

Each action command causes the modem to perform some action immediately. The most important action command is the dial command: ATDTnumber. Two other useful action commands are ATZn and AT&Fn, which reset the modem's configuration. Following are some of the important action commands:

  • Pulse dial-The ATDPnumber command causes the modem to use the pulse- dialing system to dial a specified phone number. The pulse-dialing system was used by rotary telephones. Nowadays, you typically use the ATDT command to dial a number by using the tone-dialing system.

  • Tone dial-Use the ATDTnumber command to dial a specified phone number by using the tone-dialing system. To dial the number 555-1234, for example, use the command ATDT555-1234. You should enter whatever other digits you may need to dial the number you want to reach. If you need to dial 9 for an outside line, simply use ATDT9,555-1234. The comma introduces a slight pause (typically, two seconds), which may be necessary to get an outside line.

  • Dial last number-The ATDL command causes the modem to execute the last dial command.

  • Hook control-The ATH command simulates lifting or putting down the handset of a regular telephone. ATH0 hangs up the phone; ATH1 makes the modem go online (as though you have picked up the handset).

  • Answer call-Use the ATA command to make the modem answer the phone. You can put the modem in answer mode (by setting register S0-a storage area in the modem-to a nonzero value), so that it answers the phone when someone calls. With the ATA command, you can force the modem to answer the phone even if register S0 is set to 0 (which means the modem won't answer the phone).

  • Return to online-The ATO command returns the modem to online mode. Use this command after you press +++ (rapidly enter three plus signs in sequence with some pause before and after the sequence) to take the modem offline.

  • Software reset-If the modem stores configuration profiles in nonvolatile memory, you can recall one of the configuration profiles with the ATZn command (n being the number of the configuration profile). If you enter ATZ without any argument, the modem is reset. The ATZ command terminates any existing connection.

  • Factory-default setting-The AT&F command causes the modem to restore the factory-default settings. Some modems take a numeric argument with AT&F; consult your modem's documentation for more information on the meaning of the numeric arguments.

The ATSr=n Commands

In addition to the AT command set, Hayes Smartmodem pioneered the use of internal modem registers to configure the modem. All current modems have registers, called the S registers, that control many aspects of the modem (including features that may be unique to a specific brand of modem).

Note 

A typical modem has anywhere from 30 to 60 S registers, denoted by S0, S1, S2, and so on. The ATSr=n command sets the S register numbered r to the value n. To view the current contents of the S register numbered r, use the ATSr? command.

Register S0, for example, contains the number of rings after which the modem answers the phone. When S0 is 0, the modem does not answer the phone at all. The following listing shows how you might query and set the S0 register with the ATS command:

ATS0?
000
OK
ATS0=1
OK
ATS0?
001

The exact set of S registers varies from one brand of modem to another, but most modems seem to provide and interpret the following 13 S registers consistently, as follows:

  • S0, ring to answer on-The number of rings after which the modem answers the phone. When S0 is 0, the modem does not answer the phone.

  • S1, counts number of rings-The count of incoming rings. When S1 equals S0, the modem answers the phone (assuming that S0 is nonzero). The modem resets S1 to 0 a few seconds after the last ring.

  • S2, escape code character-The character used as the escape sequence to switch the modem from online mode to command mode. The default value is 43, which is the ASCII code for the plus (+) character. To go from online mode to command mode, enter this escape character three times in rapid succession.

  • S3, carriage-return character-The ASCII code of the character used as the carriage return (this character terminates the AT command lines). The default value is 13.

  • S4, line-feed character-The ASCII code of the character used as the line-feed character when the modem generates word responses to commands. The default value is 10.

  • S5, backspace character-The ASCII code of the character used as the backspace. The modem echoes this character to implement the 'erase preceding character' function. The default value is 8.

  • S6, wait time for dial tone (seconds)-The number of seconds to wait before dialing the first digit in a dial command. The default value is 2.

  • S7, wait time for carrier (seconds)-The number of seconds the modem waits for a carrier. If the modem does not detect a carrier after waiting for this many seconds, it displays the NO CARRIER message. The default value depends on the modem. Typically it will be anywhere from 30 to 60.

  • S8, comma time (seconds)-The number of seconds to pause when the modem finds a comma in the phone number to dial. The default value is 2.

  • S9, carrier detect time (tenths of a second)-The amount of time, in tenths of a second, that the carrier must be present before the modem declares that a carrier has been detected. The default value is 6, which means the carrier must be present for 0.6 seconds before the modem detects it.

  • S10, carrier loss time (tenths of a second)-The amount of time, in tenths of a second, that the carrier must be lost before the modem disconnects. The default value is anywhere from 7 to 15, which means the carrier must be lost for 0.7 to 1.5 seconds before the modem disconnects.

  • S11, dial-tone spacing (milliseconds)-The duration of each dial tone and the spacing between adjacent tones. The default value is typically somewhere between 50 and 100 milliseconds (50 is considered the minimum necessary for dial tones to be recognized by the phone system).

  • S12, escape sequence guard time (fiftieths of a second)-The amount of guard time, in fiftieths of a second, that must occur before and after the escape-code sequence (the default sequence is +++) that switches the modem from online mode to command mode. The default value is 50, which means the guard time is one second.

Online Help

In response to the AT$ command, U.S. Robotics modems display online help information on the basic modem command sets. You'll find the help information instructive because it shows you the breadth of commands that a typical modem accepts. You can enter the command in a serial communication program such as Minicom, which I describe briefly later in the 'Dialing out with a Communication Program' section of this chapter.