Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1189 / 25 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 19:

Serial communications

< Лекция 18 || Лекция 19: 1234 || Лекция 20 >

Data compression

In addition, you usually have a choice of data compression: V 42bis or MNP-5. The choice depends on what the modem at the other end of the line does. You can set most modems to negotiate either protocol. These protocols include related error correction standards, called V 42 or MNP2-4 respectively. If you believe the sales claims, these compression protocols will give you up to 100% increase in data throughput. Consider this the upper limit; a lot of data is binary, and when ftp'ing a typical gzipped tar archive, you will probably get almost no speed improvement.

Data compression has one negative side: it increases the data rate, but it also increases latency, the time it takes for data to get from the local DTE to the remote DTE. The data doesn't take as long on the line, but it spends more time in the modems being compressed and uncompressed. If you're running a protocol like PPP that supplies optional compression in the software, you may find it advantageous to turn off compression. We’ll look at that again in Chapter 20, Configuring PPP.

Таблица 19.2. Modem protocols and speeds
Protocol Speed (bps)
Bell 203 300
V 21 300
Bell 212 1200
V 22 1200
V 22bis 2400
V 32 9600
V 32bis 14400
V 34 28800
V 34bis 33600
V 90 56000

The link speed

The standard PC serial hardware can run at speeds that are a fraction of 115,200 bps (in other words, 115200 divided by a small integer). This gives the following combinations:

Таблица 19.3. Serial line speeds
Divisor Speed (bps)
1 115200
2 57600
3 38400
4 28800
5 23 040
6 19 200

You'll notice that it can’t run at 33600 or 56000 bps. Also, looking at the example above, you'll note that all three links run at different speeds. How can that work? Only afew years ago, it wouldn't, but modern modems can buffer data. For example, the ISP can send data to the modem far faster than the modem can send it to the other modem. It stores the data in internal memory until it can be transmitted. This can also happen at the other end. If you misconfigure your line so that the local link runs at 9600 bps, things will still work, but of course the total speed is the speed of the slowest link, in this case

9600 bps.

This flexibility brings a problem with it: the modem can't know inadvance how fast the connection to the computer is. It needs a way to find out. The modem solves the question of local line speed by a trick: all commands start with AT or at (you're not allowed to mix cases, like aT or At). It can recognize these characters even if they arrive at the wrong speed, and thus it can establish the speed of the connection.

Dialing out

Nowadays, all modems are capable of dialing. That wasn’t always the case, and in some old documentation you may find references to an Auto-Call Unit or ACU, which is simply the dialler part of a modem connected via a separate port. Typically, one ACU could serve multiple modems.

Nearly every modern modem uses a command set designed by Hayes Corporation, which is thus called the Hayes Command Set. We'll look at it in the following section. It is also sometimes called the AT command set, because nearly all the commands start with the sequence AT. The CCITT also created an autodial recommendation, K25, which was occasionally implemented, but now appears to be dead.

Modem commands

Modern modems store their state in a number of registers, called S registers. The register use varies somewhat from manufacturer to manufacturer, but most modems have a number in common. They each store a one-byte value, ranging between 0 and 255. Here's a list of the more important ones for a Rockwell V 34 chip set. The name of the chip set is not the same as the name of the modem. You'll note that one of the commands enables you to find out the chip set version, as we'll see in the example that follows.

Таблица 19.4. Selected S registers
Register number Purpose
so Number of rings until auto-answer 0 disables auto-answer. Set to 0 for no automatic answer, or 1 for auto-answer
s2 The escape character, which lets you return from online mode to command mode. Normally, this character is a + To return to command mode, wait a second after any previous input, enter +++, and wait a second, after which the modem should reply with OK
s6 The time, in seconds, to wait before blind dialing. If you have set your modem to not wait for a dial tone (maybe because it doesn't understand the dial tone), it will wait this long and then try to dial anyway
S7 The number of seconds to wait after dialing before DCD must be asserted (before a connection is established). If this is set too short, you will not be able to establish a connection. If it’s too long, you will waste time when there is no answer or the line is busy
S11 The duration of DTMF (dialing) tones. If these are set incorrectly, the telephone exchange may not understand the number you dial

The AT command set tells the modem to do something specific. Here are some of the more important ones.

Таблица 19.5. Selected AT commands
Command Meaning
A/ Redial the last number
ATA Answer an incoming call manually This is an alternative to auto-answer by setting S0
ATDnumber Dial number This command has a large number of options, but if your modem is set up correctly, you probably won’t need any of them
ATEnumber Enable command echo if number is 1, disable it if number is 0. The setting of this parameter can be important for some chat scripts, which may not respond correctly otherwise
ATH0 Disconnect the line
ATInumber Display modem identification. The values of number vary from one modem to the next. See the examples below
ATLnumber Set the speaker volume number ranges from 0 to 3. 0 means "speaker off," 3 is the loudest
ATMnumber Determine when the speaker is on.
  • 0 means "always off,"
  • 1 means "speaker on until connect,"
  • 2 means "speaker always on,"
  • 3 means "speaker off during dialing and receiving "
ATO0 Go back online from command mode. You don’t need this command when dialing: the modem automatically goes online when the connection is established
ATP Select pulse dial. If your exchange doesn’t understand DTMF (tone) dialing, you should set this mode. Never use it if your exchange understands DTMF: pulse dialing (also known as steam dialing) is much slower
ATQnumber If number is 0, suppress result codes (like OK after every command) If number is 1, enable them. This value can be of importance for chat scripts
ATSr=n Set the value of S register r to n
ATSnumber? Display the contents of an S register. See the example below
ATT Set tone (DTMF) dialing
ATVnumber If number is 0, return result codes in numeric form. If it’s 1, return text. Don’t rely on either form to be consistent from one modem to the next
ATXnumber Determine the form of the result codes. This depends a lot on the manufacturer, but it’s important for chat scripts. If you run into trouble, with chat scripts, check your modem documentation
ATZ Reset modem configuration to default values
AT&Knumber Select flow control method. Normally, 3 enables RTS/CTS flow control, which is what you want
AT&Rnumber If number is 0, CTS is only asserted if the DTE asserts RTS, even if the modem is able to receive data If it’s set to 1, it behaves normally Make sure this value is set to 1
AT&Tnumber Perform modem-specific test number. This command is the origin of the statement: "UNIX is a trademark of AT&T in the USA and other countries. AT&T is a modem test command "
AT&V View the current configuration. See the example below
AT&Wnumber Store the current configuration as profile number. Most external modems can store two profiles, or configurations. If number is not specified, write the profile specified in a previous AT&Y command. See the example below
AT&Ynumber Decide which profile (0 or 1) will be loaded when the modem is reset, and which will be written by the command AT&W
< Лекция 18 || Лекция 19: 1234 || Лекция 20 >
Михаил Трифонов
Михаил Трифонов
Россия, Ленинград, ЛГМИ Ленинградский Гидрометеорологический Институт, 1986