2 · Packet vs circuit switching ★
HW1 P1, P8 · Sample midterm P3
Circuit switching (the old phone network)
- Before any data moves, resources are reserved end-to-end for the whole "call."
- + Guaranteed rate, so performance is predictable.
- − Reserved bandwidth is wasted while you're idle. Nobody else can use it.
- Two ways to split a link into circuits:
- FDM (frequency division): each user gets their own frequency band, all the time.
- TDM (time division): each user gets the whole band, but only in their time slot.
Packet switching (the Internet)
- Messages are split into packets. Each packet goes at the full link rate. Nothing is reserved.
- Store-and-forward: a router must receive the entire packet before it sends it on.
- Packets arriving faster than the link can send them queue. If the buffer fills, packets are dropped.
- + Great for bursty traffic, more efficient sharing, simpler, no call setup.
- − Congestion is possible (delay and loss), so protocols for reliability and congestion control are needed.
When is circuit switching the better choice? (HW1 P1)
For a steady, predictable rate over a long session. You reserve exactly what you need with no waste, and the setup cost is spread over the long session.
If the sum of all app rates is less than every link's capacity, you don't need congestion control, because queues never build up.
The formulas
Setup: link rate \(C\), each user needs \(r\) when active, each user is active with probability \(p\), \(N\) users total.
Circuit switching users:
$$\text{users} = \frac{C}{r}$$Packet switching, probability that exactly \(k\) users are active:
$$P(k) = \binom{N}{k}\, p^k\, (1-p)^{N-k}$$Probability of overflow (more than \(C/r\) active at once):
$$P(\text{overflow}) = 1 - \sum_{k=0}^{C/r} \binom{N}{k}\, p^k\, (1-p)^{N-k}$$\(\binom{N}{k} = \dfrac{N!}{k!\,(N-k)!}\) is the number of ways to pick which \(k\) users are active (written C(N,k) or nCr).
Worked example 1: circuit switching timing
Q: How long does it take to send a 640,000-bit file from A to B over a circuit-switched network? Every link is 1.536 Mbps, each link uses TDM with 24 slots, and setting up the circuit takes 500 ms.
- Your circuit's rate. TDM gives you 1 of 24 slots, so you get 1/24 of the link: $$\frac{1{,}536{,}000}{24} = 64{,}000 \text{ bps} = 64 \text{ kbps}$$
- Time to push the file through. $$\frac{640{,}000 \text{ bits}}{64{,}000 \text{ bps}} = 10 \text{ s}$$
- Add setup. $$10 \text{ s} + 0.5 \text{ s} = \mathbf{10.5 \text{ s}}$$
Worked example 2: small enough to do by hand
Q: 1 Mbps link. Each user needs 250 kbps when active and is active 20% of the time.
(a) How many users with circuit switching?
$$\frac{1000 \text{ kbps}}{250 \text{ kbps}} = \mathbf{4 \text{ users}}$$(b) Packet switching with N = 5 users. P(exactly 2 active)?
\(N = 5,\ k = 2,\ p = 0.2,\ 1-p = 0.8\)
$$\binom{5}{2} = \frac{5!}{2!\,3!} = \frac{120}{2 \cdot 6} = 10$$ $$0.2^2 = 0.04 \qquad 0.8^{3} = 0.512 \quad (N-k = 5-2 = 3)$$ $$P(2) = 10 \times 0.04 \times 0.512 = \mathbf{0.2048} \quad (\text{about } 20\%)$$(c) P(capacity is exceeded)?
Capacity is 4 users, so "exceeded" means more than 4 active. With 5 users that's only \(k = 5\):
$$P(5) = \binom{5}{5}\, 0.2^5\, 0.8^0 = 1 \times 0.00032 \times 1 = \mathbf{0.00032}$$Same answer with the complement formula:
| \(k\) | \(\binom{5}{k}\) | \(0.2^k \cdot 0.8^{5-k}\) | \(P(k)\) |
|---|---|---|---|
| 0 | 1 | 1 × 0.32768 | 0.32768 |
| 1 | 5 | 0.2 × 0.4096 | 0.4096 |
| 2 | 10 | 0.04 × 0.512 | 0.2048 |
| 3 | 10 | 0.008 × 0.64 | 0.0512 |
| 4 | 5 | 0.0016 × 0.8 | 0.0064 |
| \(\sum_{k=0}^{4}\) | 0.99968 | ||
Worked example 3: your homework-size problem
Q: 10 Mbps link. Each user needs 500 kbps when active, active 20% of the time.
- Circuit (convert units first: 10 Mbps = 10,000 kbps): $$\frac{10{,}000}{500} = \mathbf{20 \text{ users}}$$
- Packet, \(N = 50\), P(exactly \(k\)): $$P(k) = \binom{50}{k}\, 0.2^k\, 0.8^{50-k}$$ Example, \(k = 10\): $$\binom{50}{10}\, 0.2^{10}\, 0.8^{40} \approx 10{,}272{,}278{,}170 \times 1.024{\times}10^{-7} \times 1.329{\times}10^{-4} \approx \mathbf{0.140}$$
- P(capacity exceeded) = P(more than 20 active): $$1 - \sum_{k=0}^{20} \binom{50}{k}\, 0.2^k\, 0.8^{50-k} \approx 0.00032$$
Slide example (memorize the punchline)
1 Gbps link, 100 Mbps per user, active 10% of the time.
- Circuit: 1000 / 100 = 10 users
- Packet: with 35 users, P(more than 10 active) ≈ 0.0004
- Packet switching supports 3.5× more users with almost no overflow.