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?
12 characters × 8 bits = 96 bits, and 96/1200 = 0.08 s. Real links add framing (lesson 2), error checking (lesson 12) and start-up preambles, so the airtime grows, but the bit rate sets the pace.
Name it
The stages
- Source: text or data as bits (this lesson).
- 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).
- 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).
- Channel: noise, echoes and frequency offset (lesson 10).
- Demodulation: filter or correlate (lesson 4), recover the bit clock (lesson 5) and the carrier (lesson 8), equalize echoes (lesson 11), decide symbols.
- 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 with b bits per symbol is .
Worked example
What bits represent "Hi"? How long do 1000 characters take at 1200 baud, and at 9600 bit/s?
Show the solution
- Bits for 'H'. Its ASCII code is 72:
- Bits for 'i'. Its ASCII code is 105:
- Count the bits. Each character is 8 bits:
- Time at 1200 bit/s.
- Time at 9600 bit/s.
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
- Bits on the wire. With a start and a stop bit, each character is 10 bits on the wire:
- Time at 1200 baud. That's a quarter longer than the bare 8000 bits.
- 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
- Shannon's limit. A 30 dB SNR is a power ratio of 1000:
- 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?
A channel such as a telephone line, a radio band or the air between a speaker and a microphone only passes a certain range of frequencies, and may block DC and very low frequencies entirely. Raw bits sent as voltage levels would have much of their energy at low frequencies and in sharp edges that the channel can't carry, so they'd arrive distorted or not at all. A modem maps the bits onto signals designed to fit the channel, such as tones within the audio band or a carrier in an assigned radio band, so the information survives the trip, and the receiver then reverses the mapping to recover the bits.
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.