D121 of 14
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D12 · Lesson 1 · What a modem does

The job of a modem, turning bits into a signal a channel can carry and back again, the stages of a modern digital radio from framing to decoding, the audio-frequency FSK modem this course builds, and the first step of all: turning text into bits

A modem (modulator–demodulator) is the bridge between bits and a physical channel. Dial-up modems made that bridge audible: the screech of a connecting modem was two machines negotiating a scheme to push bits through a telephone line built for voice. The same stages are inside every Wi-Fi chip and phone: frame the data, map bits to symbols, shape them into a signal, survive noise and echoes and frequency errors, and undo all of it at the other end. This course builds one, stage by stage, in Python, ending with a modem that sends text through a simulated speaker-to-microphone channel.

  • The sound of an audio frequency-shift-keyed (FSK) modem sending alternating bits at 1200 baud: one tone (space, default 2200 Hz) for a 0 and another (mark, 1200 Hz) for a 1, switching without phase jumps.
  • The spectrum shows the energy clustered around the two tones. Listen to it.
  • This is the modulation used by caller-ID, early telephone modems (Bell 202) and amateur packet radio, and it's where this course starts.

Predict

How long does a 1200 baud FSK modem take to send "Hello, world", eight bits per character with no framing?

Name it

The stages

  1. Source: text or data as bits (this lesson).
  2. Framing: a preamble to wake the receiver, a sync word to mark where data begins, a length, the payload and a check (lesson 2, lesson 12).
  3. Modulation: bits become symbols and symbols become a waveform: FSK (lesson 3), then BPSK, QPSK and QAM (lessons 7 and 9), then OFDM (lesson 13), with pulse shaping to limit bandwidth (lesson 6).
  4. Channel: noise, echoes and frequency offset (lesson 10).
  5. Demodulation: filter or correlate (lesson 4), recover the bit clock (lesson 5) and the carrier (lesson 8), equalize echoes (lesson 11), decide symbols.
  6. Decoding: find the frame, check and correct errors, deliver the bits.

This course's modem

Audio frequencies, so you can hear it: 9600 samples per second, 1200 baud (8 samples per bit), mark at 1200 Hz and space at 2200 Hz. Text becomes bits as 8-bit ASCII, most significant bit first. The time to send N bits at a symbol rate R with b bits per symbol is N/(bR).

Worked example

What bits represent "Hi"? How long do 1000 characters take at 1200 baud, and at 9600 bit/s?

Show the solution
  1. Bits for 'H'. Its ASCII code is 72: 72=01001000
  2. Bits for 'i'. Its ASCII code is 105: 105=01101001
  3. Count the bits. Each character is 8 bits: 1000×8=8000bits
  4. Time at 1200 bit/s. t=80001200s=6.67s
  5. Time at 9600 bit/s. t=80009600s=0.83s

Answer "Hi" is 01001000 01101001, and 1000 characters take 6.67 s at 1200 baud and 0.83 s at 9600 bit/s.

Worked example

The 1000 characters are sent with a start and a stop bit around each byte at 1200 baud. How long do they take now?

Show the solution
  1. Bits on the wire. With a start and a stop bit, each character is 10 bits on the wire: 1000×10=10000bits
  2. Time at 1200 baud. t=100001200s=8.33s That's a quarter longer than the bare 8000 bits.
  3. What the framing buys. Framing always costs something; the question is what it buys, and here it buys resynchronization on every byte.

Answer 8.33 s, a quarter longer than the bare 8000 bits would take.

Worked example

A telephone channel passes 3 kHz with a 30 dB SNR. What is the most any modem could send through it?

Show the solution
  1. Shannon's limit. A 30 dB SNR is a power ratio of 1000: C=3000log2⁡(1+1000)=29.9kb/s
  2. Compare with real modems. Real analog modems reached 33.6 kb/s by using a little more bandwidth and better SNR than this textbook figure, and stopped there.

Answer about 29.9 kb/s.

Check

Turn text into bits and back, and time the transmission.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

How long does it take to send 100 8-bit characters at 300 bits per second, with no framing?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

Check

What 8-bit pattern (most significant bit first) encodes the character whose ASCII code is 72?

Check

1000 characters are sent at 300 baud with a start and stop bit around each byte.

(a)

How long do they take?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

(b)

What fraction of the bits carry data?

Check

A channel passes 4 kHz with 20 dB SNR.

(a)

What is its Shannon capacity?

Write units the way you normally would: 1.5 kb/s, 1500 b/s and 0.0015 Mb/s are the same answer.

(b)

How many bits per second per hertz?

Check

A modem sends 2400 symbols per second, each one of 4 possible symbols.

(a)

What is its bit rate?

Write units the way you normally would: 1.5 b/s and 0.0015 kb/s are the same answer.

(b)

How many bits does each symbol carry?

Explain why

Why does a modem need to turn bits into a waveform at all, instead of sending the bits directly as voltages?

Practice

Keep practicing

7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.