Computer Networks

Physical And Data Link Layers

Signals, Media and Bandwidth

It has no idea what the bits MEAN. That is the

JrCodex·8 min read

Jr Codex Computer Networks Notes

Level: Beginner Prerequisites: Module 1, Chapter 5: Measuring a Network Time to complete: ~15 minutes


Table of Contents

  1. Turning Bits Into Signals
  2. Line Coding
  3. Guided Media
  4. Wireless
  5. What Actually Limits Capacity
  6. Duplex and Multiplexing
  7. Summary & Next Steps

1. Turning Bits Into Signals

The Physical Layer's One Job
─────────────────────────────────────────
  Take a 1 or a 0 and make it a physical
  phenomenon the other end can detect:

    copper    a voltage
    fibre     a pulse of light
    wireless  a modulated radio wave

  And do the reverse at the other end.

  It has no idea what the bits MEAN. That is the
  data link layer's problem (Chapter 2).
─────────────────────────────────────────
Analogue and Digital
─────────────────────────────────────────
  All physical signals are ANALOGUE — continuous
  voltages, continuous light intensity.

  DIGITAL transmission means agreeing on
  THRESHOLDS: "above 2.5V is a 1, below is a 0".

  That thresholding is what makes digital robust.
  A signal degraded by noise still crosses the
  right side of the threshold, and can be
  REGENERATED perfectly — where an analogue signal
  accumulates every distortion along the way.
─────────────────────────────────────────

2. Line Coding

The Problem With the Obvious Encoding
─────────────────────────────────────────
  NRZ (Non-Return to Zero): high = 1, low = 0.

    1 0 1 1 0 0 0 0 0 0 0 0 1
    ▔▔__▔▔▔▔________________▔▔

  Sending twelve zeros means a long flat line. The
  receiver's clock DRIFTS, and it loses count of
  how many zeros passed.

  A CLOCK SYNCHRONISATION problem, caused by the
  encoding itself.
─────────────────────────────────────────
The Fixes
─────────────────────────────────────────
  MANCHESTER ENCODING
    Every bit is a TRANSITION in the middle:
      1 = low-to-high, 0 = high-to-low.
    Guarantees a transition per bit, so the clock
    always resynchronises.
    COST: twice the signal rate for the same data
    rate. Used by classic 10 Mbps Ethernet.

  4B/5B
    Encode every 4 data bits as 5 transmitted
    bits, choosing codes that never contain long
    runs of zeros.
    COST: 25% overhead — much better than 100%.
    Used by 100 Mbps Ethernet.

  8B/10B, 64B/66B
    The same idea, more efficient. 64B/66B is only
    3% overhead, and is what gigabit and faster
    links use.
─────────────────────────────────────────
The Trade-off, Stated Once
─────────────────────────────────────────
  Encoding schemes trade OVERHEAD for
  SELF-CLOCKING and DC balance.

  Faster standards use lower-overhead codes because
  their clocks are better and their transceivers
  more sophisticated. The progression from 100%
  overhead to 3% is most of the story of how
  Ethernet got a thousand times faster.
─────────────────────────────────────────

3. Guided Media

TWISTED PAIR (Cat5e, Cat6, Cat6a)
─────────────────────────────────────────
  Pairs of copper wires twisted together.

  WHY TWISTED: the two wires carry the same signal
  in opposite polarity. Interference hits both
  equally, and subtracting them CANCELS the noise.
  Tighter twists cancel better — which is the whole
  difference between the categories.

  Cat5e   1 Gbps, 100 m
  Cat6    10 Gbps, 55 m
  Cat6a   10 Gbps, 100 m

  + cheap, flexible, ubiquitous
  - distance-limited, susceptible to interference
COAXIAL
─────────────────────────────────────────
  A central conductor inside a shield.
  + better shielding than twisted pair
  - bulky
  Now mostly cable television and cable internet.
FIBRE OPTIC
─────────────────────────────────────────
  Light through glass. Total internal reflection.

  SINGLE-MODE   a very narrow core; one light path
                Tens of kilometres. Long haul.
  MULTI-MODE    a wider core; many paths, which
                spread the pulse over distance
                Hundreds of metres. Within
                buildings.

  + enormous bandwidth, very low loss, IMMUNE to
    electromagnetic interference, no signal leakage
    (harder to tap)
  - more expensive to terminate; fragile if bent
─────────────────────────────────────────
Why Long Distance Is Always Fibre
─────────────────────────────────────────
  Copper attenuates rapidly — a signal is
  unusable after ~100 m.

  Fibre attenuates so little that transatlantic
  cables need repeaters only every ~50-100 km.

  There is no copper alternative at that scale.
  Every intercontinental link is fibre.
─────────────────────────────────────────

4. Wireless

The Fundamental Difference
─────────────────────────────────────────
  A cable is a PRIVATE medium. Radio is a SHARED
  one.

  Consequences that shape everything above it:
    - anyone in range receives your signal, so
      encryption is not optional (Module 6)
    - two devices transmitting at once INTERFERE
    - signal strength falls with distance, so the
      data rate falls too
    - obstacles absorb and reflect
    - you cannot detect a collision while
      transmitting, because your own signal drowns
      everything ── which is why wifi uses
      collision AVOIDANCE, not detection
      (Chapter 3)
─────────────────────────────────────────
The Bands
─────────────────────────────────────────
  2.4 GHz   travels further, penetrates walls
            better; CROWDED (microwaves, Bluetooth,
            baby monitors); only 3 non-overlapping
            channels

  5 GHz     more channels, less interference,
            higher rates; shorter range, worse
            through walls

  6 GHz     Wi-Fi 6E and 7; very wide clean
            channels; shortest range

  The trade is always the same: HIGHER FREQUENCY
  means more bandwidth and less range.
─────────────────────────────────────────
Reading a Wifi Speed Claim
─────────────────────────────────────────
  "Wi-Fi 6, up to 9.6 Gbps" describes ideal
  conditions, all streams, all channels, one
  device, no walls.

  Real single-device throughput is typically a
  small fraction of it — and it is SHARED among
  everyone on the access point, because the medium
  is shared.

  Advertised wireless rates are a ceiling nobody
  reaches, not a speed you get.
─────────────────────────────────────────

5. What Actually Limits Capacity

NYQUIST — the noiseless limit
─────────────────────────────────────────
  max rate = 2 × B × log₂(L)   bits per second

  B = bandwidth in Hz
  L = number of distinguishable signal levels

  More levels means more bits per symbol — so a
  modem sending 16 distinguishable levels carries
  4 bits per symbol instead of 1.
SHANNON — the real limit, with noise
─────────────────────────────────────────
  capacity = B × log₂(1 + S/N)   bits per second

  S/N = signal-to-noise ratio.

  This one is a HARD PHYSICAL LIMIT. No encoding,
  no cleverness, no amount of engineering exceeds
  it.
─────────────────────────────────────────
import math
 
def shannon_bps(bandwidth_hz, snr_db):
    snr = 10 ** (snr_db / 10)                     # dB is logarithmic
    return bandwidth_hz * math.log2(1 + snr)
 
print(f"{shannon_bps(20e6, 25)/1e6:>7.1f} Mbps")   # good wifi:  166.1
print(f"{shannon_bps(20e6, 10)/1e6:>7.1f} Mbps")   # weak wifi:   69.2
print(f"{shannon_bps(20e6,  3)/1e6:>7.1f} Mbps")   # very weak:   30.0
What Shannon Explains
─────────────────────────────────────────
  Why wifi gets SLOWER as you walk away from the
  access point, without ever disconnecting.

  Distance lowers the signal-to-noise ratio, which
  lowers capacity, so the devices negotiate a lower
  data rate. Nothing is broken; you have moved to a
  different point on Shannon's curve.

  It also tells you the two ways to get more
  capacity: MORE BANDWIDTH (wider channels, higher
  frequencies) or BETTER SNR (closer, more power,
  less noise). There is no third way.
─────────────────────────────────────────

6. Duplex and Multiplexing

Duplex Modes
─────────────────────────────────────────
  SIMPLEX        one direction only (broadcast TV)
  HALF-DUPLEX    both directions, one at a time
                 (walkie-talkie, wifi, old
                  Ethernet hubs)
  FULL-DUPLEX    both directions simultaneously
                 (switched Ethernet, phone calls)

  Full duplex on a switched Ethernet port is what
  ELIMINATED collisions entirely — Chapter 3.
Multiplexing — sharing one medium
─────────────────────────────────────────
  FDM   Frequency Division — different frequency
        bands. Radio stations, wifi channels.

  TDM   Time Division — different time slots.
        Traditional telephone trunks.

  WDM   Wavelength Division — different colours of
        light down ONE fibre. The reason a single
        fibre strand carries terabits: 80+
        wavelengths, each at 100+ Gbps.

  CDM   Code Division — different codes, all at
        once. Mobile networks.

  STATISTICAL — allocate on demand rather than by
        fixed slot. This is PACKET SWITCHING
        (Module 1, Chapter 4), and it is why the
        internet uses capacity so much more
        efficiently.
─────────────────────────────────────────

7. Summary & Next Steps

Key Takeaways

  • Digital transmission is analogue signals plus agreed thresholds, and that thresholding is what allows perfect regeneration where analogue accumulates distortion.
  • Line coding trades overhead for self-clocking; the progression from Manchester's 100% overhead to 64B/66B's 3% is much of how Ethernet got faster.
  • Radio is a shared medium, which forces encryption, causes interference, and makes collision detection impossible — hence wifi's collision avoidance.
  • Shannon's limit is a hard physical bound, and it explains why wifi slows with distance: lower signal-to-noise means lower capacity, with only two ways to raise it.

Concept Check

  1. Why does twisting a pair of copper wires reduce interference?
  2. What problem does Manchester encoding solve, and what does it cost?
  3. Using Shannon's formula, explain why your wifi gets slower as you move away without disconnecting.

Next Chapter

Chapter 2: Framing and Error Detection


Jr Codex — 1-on-1 Personalized Coaching | Back to Module Index | Back to Computer Networks Index