Chapter 06 of 22Part II: Networks and Communication
The Secret Life of a SIM Card
Each project below is tailored to a specific algorithm and scientific question from Chapter 06, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.
Project 1 of 3 · v1-c06-p01Foundational · ~25 min
Miniature Mobile Operator Registry
Lab activity: Lab A. Build a miniature mobile operator · Related code: block-01.js · Pioneer: View profile
Real-World Problem: A cellular carrier must track millions of SIM cards, roaming statuses, and base stations without mixing up calls.
Scientific Question: How do IMSI, temporary identities (TMSI), and operator databases separate subscriber identity from radio traffic?
Objective: Model an operator Home Location Register (HLR) mapping fictional SIM cards to active cells and call routing.
Hypothesis to Test: Routing every call through BTS -> BSC -> MSC/Core allows two phones in different cells to connect without direct radio range.
Step-by-Step Implementation
Register fictional subscribers with IMSI, temporary TMSI, and current serving base station.
Look up the callee's serving tower in the operator registry when a call is placed.
Trace every hop from caller handset to BTS, core switch, and destination BTS.
Deactivate a SIM and verify the operator rejects registration cleanly.
Concrete Input: 3 fictional SIMs registered across Tower North and Tower South; initiate call from SIM-1 to SIM-3.
Hint: Review the worked example and equation in Chapter 06 before testing the boundary case: If a handset is in airplane mode (no tower), the core routes directly to voicemail/unreachable.
Extension Challenge: Add TMSI rotation so the permanent IMSI is not broadcast on every paging request.
Reflection Question: Why did cellular networks introduce temporary identities (TMSI/GUTI) instead of sending IMSI in the clear?
Lab activity: Lab B. Challenge-response experiment · Related code: block-02.js · Pioneer: View profile
Real-World Problem: Radio waves can be overheard by anyone nearby, so a phone must prove its identity without broadcasting its secret key.
Scientific Question: How does a fresh random challenge (RAND) stop an eavesdropper from replaying a recorded login?
Objective: Simulate a SIM card and carrier Authentication Center exchanging RAND and RES, and test replay attacks.
Hypothesis to Test: Replaying a previously captured RES against a new RAND will fail authentication.
Step-by-Step Implementation
Store fictional secret key Ki privately inside both the simulated SIM and operator AuC.
Generate a fresh random challenge RAND and compute RES = f(Ki, RAND) on both sides.
Verify the login succeeds without Ki ever appearing in the radio log.
Capture RES from session 1 and attempt to replay it in session 2 with a new RAND.
Concrete Input: Shared key Ki = "SIM_SECRET_01", RAND_1 = 48291 -> RES_1; replay RES_1 for RAND_2 = 91034.
Expected Output: Login 1: PASS (RES matches); Replay on Login 2: REJECTED (expected different RES).
Test Cases: Matching Ki + fresh RAND -> PASS; Replayed RES -> FAIL; Wrong Ki -> FAIL.
Boundary Condition: Reusing a static RAND completely breaks replay protection.
Common Mistake to Avoid: Assuming 2G GSM authenticated the tower to the phone (mutual authentication arrived in 3G/4G/5G AKA).
Interpreting Results: Challenge-response proves possession of a secret without exposing it, and mutual AKA protects against rogue towers.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 06 before testing the boundary case: Reusing a static RAND completely breaks replay protection.
Extension Challenge: Add an operator authentication token (AUTN) so the SIM also rejects a fake base station.
Reflection Question: How did Hedy Lamarr and George Antheil's frequency-hopping concept influence later wireless resilience?
Lab activity: Lab C. Move the phone · Related code: block-03.js · Pioneer: View profile
Real-World Problem: A phone moving along the boundary between two towers would waste battery rapidly switching back and forth ("ping-ponging").
Scientific Question: How does a signal-strength hysteresis margin stabilize handoffs between neighboring cells?
Objective: Simulate a moving phone measuring signal power from multiple towers and compare naive switching vs. hysteresis.
Hypothesis to Test: Requiring the new tower to exceed the current tower by a 3 dB margin eliminates rapid ping-pong handoffs.
Step-by-Step Implementation
Model received signal strength falling with distance plus small random fading noise.
Run a sweep from Tower A to Tower B switching immediately whenever Tower B > Tower A.
Add a 3 dB hysteresis threshold and re-run the identical path.
Compare total handoff count and minimum signal quality.
Concrete Input: Phone moving from x=0 to x=100 between Tower A (x=20) and Tower B (x=80) with ±2 dB noise.
Expected Output: 0 dB margin -> 5+ rapid handoffs near x=50; 3 dB hysteresis -> 1 clean handoff.
Test Cases: No hysteresis -> multiple boundary oscillations; 3 dB hysteresis -> single clean transfer.
Boundary Condition: Excessively high hysteresis (e.g., 20 dB) causes dropped calls before switching.
Common Mistake to Avoid: Ignoring radio fading noise when modeling cell boundaries.
Interpreting Results: Hysteresis is a classic control-engineering trade-off between stability and responsiveness.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 06 before testing the boundary case: Excessively high hysteresis (e.g., 20 dB) causes dropped calls before switching.
Extension Challenge: Add a third tower in 2D and log the full handoff trajectory.
Reflection Question: Where else (thermostats, Wi-Fi roaming) does hysteresis prevent rapid oscillation?