Section 10 · Revision
Computer Networks formula sheet
Delays, sliding window, MAC, error codes, routing, IPv4 addressing and fragmentation, TCP control and HTTP timing on one page.
Layering, switching and performance
Units: 1 Mbps = bps (rates are always decimal). File sizes: read the question; 1 KB may be 1000 or 1024 bytes.
| Layer (TCP/IP) | PDU | Address | Device |
|---|---|---|---|
| Application | message | names, URLs | host |
| Transport | segment (TCP), datagram (UDP) | port | host |
| Network | packet / datagram | IP | router |
| Link | frame | MAC | switch, bridge |
| Physical | bits | none | hub, repeater |
OSI adds session and presentation between transport and application (7 layers).
| Quantity | Formula |
|---|---|
| Transmission delay | |
| Propagation delay | ( m/s in cable) |
| Bandwidth-delay product | bits in flight one way |
| Bit length on wire | metres |
| Traffic intensity | ; queue grows without bound if |
| Throughput over links in series | |
| One packet, store-and-forward links | |
| packets, links, back to back | |
| Circuit switching | (no per-hop store) |
| TDM circuit with slots | rate per circuit |
- Smaller packets pipeline better but add header overhead; the best size balances the two. Try each option.
- Packet switching wins for bursty users (statistical multiplexing: binomial count of active users).
- Virtual circuit: setup phase, per-hop VC number swapped at each switch, packets in order on one path. Datagram: each packet routed alone, may reorder.
Data link layer
Error detection and correction
| Fact | Value |
|---|---|
| Hamming distance : detect | errors |
| Hamming distance : correct | errors |
| Detect and correct | with |
| Single-error-correcting check bits for data bits | smallest with |
| Hamming (7,4) | parity at positions 1, 2, 4; syndrome = position of bad bit |
| Single parity bit | detects any odd number of bit errors |
| 2D parity, data | parity bits; corrects 1, detects 1, 2, 3; misses some 4 (rectangle) |
| CRC with generator of degree | append zeros, divide mod 2, send remainder ( bits) |
| Internet checksum | one's complement sum of 16-bit words, carry wrapped back, then complement |
CRC guarantees: all single-bit errors if has 2 or more terms; all odd-count errors if divides ; all bursts of length .
Hamming check bits: , , , , .
Flow control (, ACK time ignored unless given)
| Protocol | Utilisation | Window limits with -bit sequence numbers |
|---|---|---|
| Stop-and-wait | 1 bit enough | |
| Go-Back-N | , | |
| Selective Repeat | , so |
- With an ACK of time : cycle (plus processing if given).
- Window for 100 percent use: , then pick from the limits above.
- GBN loss: resend the lost frame and everything sent after it. SR loss: resend only the lost frame.
- Throughput .
Medium access
| Scheme | Result |
|---|---|
| Pure ALOHA | , max at |
| Slotted ALOHA | , max at |
| Slotted, stations, prob | P(success) , best |
| CSMA/CD minimum frame | (transmission round-trip propagation) |
| CSMA/CD efficiency (Kurose) | ; use the formula the question gives |
| Token ring, early release, | |
| Binary exponential backoff | after -th collision pick , give up after 16 attempts |
- Two stations after collision : P(same ) .
- Classic Ethernet: 10 Mbps, slot 512 bit times s, frame 64 to 1518 bytes (header and CRC, no preamble), payload 46 to 1500, 6-byte MAC, 8-byte preamble with SFD.
- Token passing: no collisions, bounded wait, only the token holder sends.
- Switch: learns source MAC per port, floods unknown destinations and broadcasts, each port is its own collision domain, one broadcast domain. Hub: one collision domain.
- Bit stuffing (HDLC): insert 0 after five 1s; flag 01111110.
Routing
| Distance vector | Link state | |
|---|---|---|
| Knows | neighbours' vectors | full topology |
| Algorithm | Bellman-Ford: | Dijkstra |
| Messages | to neighbours only | flooded to all |
| Problems | count to infinity, slow on bad news | more memory and CPU |
| Example | RIP (hop count, 16 = infinity, 30 s updates) | OSPF, IS-IS |
- BGP: path vector between autonomous systems.
- Dijkstra time: with an array, with a heap.
- Synchronous DV: after round , every best path with at most links is known.
- Good news spreads fast, bad news slowly. Split horizon: do not advertise a route back to the neighbour it came from. Poisoned reverse: advertise it as infinity.
- Two-level hierarchy, routers in regions: own region entries .
- Shortest path tree ties: follow the question's tie rule, otherwise list all.
IPv4
| Fact | Value |
|---|---|
| Usable hosts in | (/31 point-to-point and /32 host routes are special) |
| Network address | IP AND mask |
| Broadcast | network OR inverted mask |
| Subnets from borrowed bits | |
| Aggregate aligned blocks of | one , only if the first block is aligned to |
| Forwarding | longest prefix match, default route last |
Private (RFC 1918): 10.0.0.0/8, 172.16.0.0/12 (172.16 to 172.31), 192.168.0.0/16. Not private: 100.64.0.0/10 (carrier NAT), 169.254.0.0/16 (link-local), 127.0.0.0/8 (loopback).
VLSM: sort needs largest first, give each the smallest block with hosts, place at the next aligned address.
Header
| Field | Note |
|---|---|
| HLEN | 4 bits, in 4-byte words: 5 to 15, header 20 to 60 bytes |
| Total length | 16 bits, header plus data, max 65535 |
| Identification | same in all fragments |
| Flags | DF, MF |
| Fragment offset | 13 bits, units of 8 bytes |
| TTL | decremented by each router; 0 means drop and send ICMP Time Exceeded |
| Checksum | header only, recomputed at every hop (TTL changes) |
Fragmentation (header , MTU )
- Data per fragment .
- Fragments , offset of fragment (from 0) .
- Last byte of a fragment .
- MF = 1 on all but the last. Reassembly only at the destination.
- DF = 1 and too big: drop, ICMP type 3 code 4 (fragmentation needed).
- Extra bytes sent .
NAT (NAPT): rewrites source IP and port outbound, keeps a table of (inside IP, inside port) to public port, rewrites destination on replies. About 64K connections per public IP per protocol. Breaks unsolicited inbound connections.
TCP and sockets
| Fact | Value |
|---|---|
| Header | 20 to 60 bytes; data offset in 4-byte words |
| Sequence number | 32 bits, counts bytes; SYN and FIN use one number each |
| ACK number | next byte expected (cumulative) |
| Window field | 16 bits, max 65535; scale shift multiplies by (max shift 14) |
| Max throughput | |
| Wrap-around time | seconds |
| rwnd | RcvBuffer (LastByteRcvd LastByteRead) |
| Can still send | rwnd (LastByteSent LastByteAcked) |
| Sawtooth average |
- Handshake: SYN(), SYN-ACK(, ack ), ACK(, ack ). First data byte is ISN .
- Close: FIN, ACK, FIN, ACK. Active closer waits in TIME_WAIT for 2 MSL. FIN closes one direction only.
RTT estimation (RFC 6298, , )
- (uses old EstRTT)
- ; double RTO on each timeout.
- Karn: ignore samples from retransmitted segments.
Congestion control
| Event | ssthresh | cwnd next |
|---|---|---|
| Slow start (cwnd < ssthresh) | same | doubles per RTT (+1 MSS per ACK) |
| Congestion avoidance | same | +1 MSS per RTT |
| 3 duplicate ACKs, Reno | cwnd/2 | ssthresh (fast recovery) |
| 3 duplicate ACKs, Tahoe | cwnd/2 | 1 MSS |
| Timeout (both) | cwnd/2 | 1 MSS, slow start again |
- Exam traces: list cwnd round by round; cap slow start at ssthresh unless told otherwise.
- AIMD converges to a fair share between flows with the same RTT.
- Duplicate ACKs come from out-of-order arrivals; fast retransmit resends after the third duplicate.
Socket call order
| Side | Calls |
|---|---|
| TCP server | socket, bind, listen, accept (blocks, returns new socket), recv/send, close |
| TCP client | socket, connect (does the handshake), send/recv, close |
| UDP server | socket, bind, recvfrom, sendto |
| UDP client | socket, sendto, recvfrom |
DNS and HTTP
DNS
| Fact | Value |
|---|---|
| Transport | UDP port 53; TCP 53 for zone transfers and large replies |
| A / AAAA | name to IPv4 / IPv6 |
| NS | zone to its name server |
| CNAME | alias to canonical name |
| MX | mail server for a domain |
| PTR | reverse lookup (in-addr.arpa) |
| SOA | start of zone authority |
- Iterative, nothing cached: local server queries root, TLD, authoritative: 3 queries, client to local 1 exchange.
- Recursive: each server asks the next on the requester's behalf.
- Cached NS or answer skips those steps until the TTL expires. Count only servers not yet cached.
- Answers from a cache are non-authoritative.
HTTP timing (page = base file + objects, transmission ignored unless given)
| Mode | Time |
|---|---|
| Non-persistent, serial | RTT |
| Non-persistent, parallel | RTT |
| Persistent, no pipelining | RTT |
| Persistent, pipelining | RTT |
- Add DNS time first if the name is not cached; add per object if transmission time is given.
- HTTP/1.0 closes after each response by default; HTTP/1.1 is persistent by default and needs a Host header.
- HTTP is stateless; cookies carry state.
- GET, HEAD, PUT, DELETE are idempotent; POST is not.
| Code | Meaning |
|---|---|
| 200 | OK |
| 301 / 302 | moved permanently / temporarily (Location header) |
| 304 | not modified (conditional GET) |
| 400 / 403 / 404 | bad request / forbidden / not found |
| 500 / 503 | server error / unavailable |