Highlights

Contents

Part II
02

Data link and Ethernet switching

A link must deliver a bounded frame before a router can inspect its packet. Missing boundaries, damaged bits and mistaken interface identities can each break delivery before the application participates. We will construct a frame, distinguish local addresses, compute an error check and follow Ethernet forwarding through a switch.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Network models andphysical signals2Data link and Ethernetswitching3VLANs and IP addressing4IP forwarding and routing5Transport and TCP6Flow and congestioncontrol7DNS and HTTP8QUIC, TLS and websessions9Proxies, tunnels andfirewalls10Socket programming andI/O11CDN, P2P and cloudnetworking12The complete browserrequest

#Section 5Data link framing and medium access

The data link layer frames a bounded transfer between neighboring interfaces. Its local wrapper carries delivery and error-detection information around a network packet.

Framing, headers and payload

An Ethernet frame names destination and source interfaces, identifies the carried protocol and ends with a frame check sequence. The preamble helps receivers synchronize before the frame itself. Length fields, delimiter patterns or fixed formats let other link protocols find boundaries. If a delimiter can appear inside data, the format needs an escaping or coding rule so payload bytes cannot masquerade as a boundary.

AN ETHERNET FRAME IS A TRAIN: 1518 BYTES FROM HEADER TO CHECKSUMAN ETHERNET FRAME IS A TRAIN: 1518 BYTES FROM HEADER TO CHECKSUMpreamble8 Bheader14 Bpayload: IP packet≤ 1500 BFCS4 Bclock syncdst + src MAC, typethe next router unloads this car and builds a new trainCRC14 + 1500 + 4 = 1518 bytes counted as the frame
Figure 2.9A local frame surrounds its packet with synchronization, addressing and checking information. Orange marks the packet payload, which the next router extracts before building another frame.

The declared untagged Ethernet layout uses 14 header bytes, a 1,500-byte IP packet and four frame-check bytes:

F=14+1500+4=1518 bytes.F=14+1500+4=1518\text{ bytes}.

Read F as the frame count under this convention, excluding preamble and the gap between transmissions. The 1,500-byte IP allowance is the link MTU, not the entire frame count. The Ethernet IP encapsulation specification defines that distinction with its published errata.

Flow control and medium access control

Link flow control can stop a neighbour from overwhelming its receiver. Medium access control decides who may transmit when several stations share a channel. Neither function is the same as TCP's end-to-end control. Ethernet pause signalling, where configured, can spread waiting to unrelated traffic sharing the paused link; a successful local pause does not prove an application made progress.

The failure case is a receiver that accepts the frame boundary but rejects its check. It discards the damaged frame rather than supplying partial payload to IP. Higher layers may recover the lost data, but a link cannot assume that every carried protocol has a retransmission mechanism. Specify which layer repairs loss when explaining the complete request.

#Section 6MAC addresses, unicast and broadcast

A MAC address identifies an interface in local link forwarding. The campus client needs its gateway's MAC, not the remote portal's. A MAC is not trustworthy user identity.

Unicast names one interface. Multicast names a selected group under the link's delivery rules. Broadcast addresses all eligible interfaces in the broadcast domain. A router normally ends that local broadcast reach, while switches extend it within the selected VLAN. A switch receiving an unknown unicast can also flood it, but that forwarding action does not change the frame's destination into a broadcast address.

A 48-BIT MAC NAMES ONE INTERFACE; BROADCAST REACHES EVERY HOST BUT STOPS AT THE ROUTERA 48-BIT MAC NAMES ONE INTERFACE; BROADCAST REACHES EVERY HOST BUT STOPS AT THE ROUTER3c22fb9a4107vendor (OUI)interfaceunicastmulticastbroadcast ff:ff:ff:ff:ff:ff
Figure 2.10Delivery can name one interface, a group or every local listener. Orange marks broadcast, whose reach stays inside the local broadcast domain.

For the running request, source MAC belongs to Finch and destination MAC belongs to the gateway. The IP destination still names 203.0.113.20. At the next routed link, the gateway supplies different local MAC fields. This is why a captured frame can name a nearby interface while carrying a packet destined for a distant machine.

A virtual interface can acquire a new address when recreated, and an administrative configuration can override an address. Duplicate addresses on the same learning domain make the switch's location change between ports. A MAC therefore does not prove the owner's identity, durability or permission. Authorization belongs to a higher-layer contract.

The interview distinction is between a MAC table, a route table and an application session. The MAC table finds a local forwarding port; the route table finds a next hop for an IP prefix; the session supplies the caller's application state. Changing one does not necessarily invalidate the others, though their operational state must agree well enough for the request to reach its destination.

#Section 7Error detection, checksum and CRC

Error detection identifies specified corruption patterns; error correction can reconstruct some damaged messages. Rejecting a bad frame is different from recovering its payload.

Parity makes the number of set bits even or odd; it detects an odd number of flips but can miss an even number. A checksum combines words under its declared arithmetic. A CRC, or cyclic redundancy check, divides a binary polynomial by a chosen generator using XOR instead of ordinary subtraction. The receiver repeats the check under the same generator.

A TWO-BIT BURST: PARITY MISSES IT, A CRC CATCHES ITA TWO-BIT BURST: PARITY MISSES IT, A CRC CATCHES ITsent1101001received1011001noise flips bits 1 and 2parityones: 4 sent, 4 received; both evenmissedchecksumadds 16-bit words; reordered words cancel outweakCRCdivide by 1011: remainder non-zerocaughtnone of these stops an attacker: anyone can recompute them
Figure 2.11Parity, checksum and CRC retain different check information. Orange marks polynomial division; none of these public checks supplies sender authentication.

Worked polynomial division

The declared data is 1101, the generator is 1011, and the generator's degree requires three appended zeroes. Divide 1101000 using XOR. The successive working strings are 0110000, 0011100, 0001010 and 0000001. The last three positions give remainder 001, so the transmitted codeword is 1101001.

CRC: DIVIDE 1101000 BY 1011, SEND REMAINDER 001, RECEIVER GETS ZEROCRC: DIVIDE 1101000 BY 1011, SEND REMAINDER 001, RECEIVER GETS ZERO101111010001011110010111110101110101011001XOR, no carriesremainder 0011101001codeword 1101001 goes on the wireremainder 001: accept
Figure 2.12Illustrative data 1101 uses generator 1011 and remainder 001. Orange marks the receiver's zero remainder after dividing the transmitted codeword 1101001.

Read polynomial remainder as the part left after cancelling every permitted leading generator term. Dividing the transmitted codeword produces 000, which is the expected remainder for this teaching code. These steps are asserted in scripts/fundamentals/cn-early-numbers.py; swapping the data and generator changes the problem.

A valid remainder is not proof that the frame is the intended message. Some altered patterns share the check, and an attacker can recompute a public CRC after changing data. A link check protects an accidental-corruption boundary, while TLS authentication protects a different adversarial boundary. The actual Ethernet check uses its standardized generator rather than this small teaching polynomial.

#Section 8Ethernet, CSMA/CD and duplex

Ethernet is the IEEE 802.3 link family. Finch's switched full-duplex link can send and receive simultaneously; historical shared-medium collision rules describe another setup.

Ethernet frame structure

Destination MAC, source MAC, EtherType, payload and frame check sequence give the receiver local delivery and integrity information. The declared 1,518-byte count includes the frame check but excludes synchronization and idle-gap costs. Adding the declared VLAN tag makes 1518+4=15221518+4=1522 bytes. Real frame budgets must also consider configured encapsulation and link capability.

Broadcast and collision domains

A broadcast domain describes which interfaces receive a local broadcast. A collision domain describes stations sharing a medium on which simultaneous transmissions interfere. Those sets need not match. Separate full-duplex switch ports can belong to the same VLAN broadcast domain without competing for one shared host-to-switch wire.

A SWITCH GIVES EVERY HOST ITS OWN FULL-DUPLEX LINK, BUT BROADCASTS STILL REACH THEM ALLA SWITCH GIVES EVERY HOST ITS OWN FULL-DUPLEX LINK, BUT BROADCASTS STILL REACH THEM ALLone broadcast domainswitchfull duplex: send and receive at once, no collisionsdotted circles: one collision domain per port
Figure 2.13Broadcast reach and collision behaviour are separate boundaries. Orange marks full duplex, which supports simultaneous directions on the switched host link.

CSMA/CD and full-duplex Ethernet

Historical shared Ethernet used carrier-sense multiple access with collision detection, or CSMA/CD. A sender listened, transmitted on an apparently idle medium, detected a collision and retried after randomized backoff. Detecting a collision required a shared-medium timing model. A full-duplex point-to-point link does not run that collision procedure.

The remaining failure modes include damaged frames, exhausted buffers and incorrect link configuration. Full duplex removes shared-medium collisions, not every source of loss or waiting. The switch may receive traffic faster than an egress link can drain it even when every cable is healthy. In an interview, distinguish the medium’s access rule from the switch’s queueing and the higher layer’s recovery rule before claiming that Ethernet cannot lose packets.

#Section 9Hubs, bridges, switches and routers

A switch forwards local frames; a router chooses an IP next hop. A hub repeats signals, while a bridge learns locations across link segments.

The distinction is easiest to see in the running request. Finch’s switch sees the gateway MAC and chooses its port. The gateway removes the Ethernet frame, sees remote IP 203.0.113.20, selects a route and forwards through another interface. It does not forward globally by that remote server’s MAC, because the server is outside the local link.

EACH BOX READS A DIFFERENT PART OF THE FRAME BEFORE DECIDING WHERE IT GOESEACH BOX READS A DIFFERENT PART OF THE FRAME BEFORE DECIDING WHERE IT GOESlayer 1hubreads: bits onlyrepeats out every portlayer 2bridge / switchreads: MAC addressforwards to one portlayer 3routerreads: IP addresspicks the next hoplayer 7gatewayreads: whole messagetranslates or terminatesdeeper inside the envelope = more state and more choice
Figure 2.14The devices interpret different evidence. Orange marks the router’s IP decision, which connects Finch’s local link to the remote path.

A gateway is a boundary role rather than one universal device type. The same appliance can include an Ethernet switch, IP router, address translator, firewall, DHCP service and radio access point. A product advertised as a switch can also route. Asking which feature is active avoids arguing about the label on the chassis.

Repeating a signal can expose traffic and extend shared-medium contention. Learning a MAC location narrows known-unicast delivery but requires changing local state. Routing introduces prefix selection, hop limits and a new broadcast boundary. None of those operations establishes that the destination application authorized Finch or produced a correct response.

The failure trace follows the interpreted table. If the switch has the wrong port, inspect MAC learning and VLAN membership. If the router lacks a route, inspect the destination prefix and next hop. If forwarding succeeds but the server refuses the request, continue upward to transport and application evidence. This division connects the layer model from Part I to actual devices instead of treating layers as a memorized list.

#Section 10Switching, learning and flooding

A MAC table maps source address and VLAN to a learned port. Learn from where a frame arrived; its destination does not prove that destination’s location.

If destination B is known on port 2, the switch forwards through that eligible port. If B is unknown, the switch floods through eligible ports in the same VLAN, excluding port 1 where the frame arrived. When B replies, its source supplies the missing location. Subsequent known-unicast frames can then take the narrower path.

THE SWITCH LEARNS THE SOURCE PORT BEFORE CHOOSING AN EXITTHE SWITCH LEARNS THE SOURCE PORT BEFORE CHOOSING AN EXITswitchABCsource AA → port 1B → port 2known B: forward only on port 2
Figure 2.15Source learning updates local state before destination lookup. Orange marks the lookup that chooses known-unicast forwarding or eligible-port flooding.

Filtering, forwarding and ageing

Filtering prevents a frame from leaving through a port that should not carry it. Forwarding chooses a known destination path. Flooding distributes an unknown destination within its permitted domain. Entries age out because silent interfaces can move or disappear; observing another source frame refreshes the evidence.

When Finch moves from port 1 to port 3, the next source frame updates its location. Before that update, a cached entry can direct traffic to the old port. Duplicate source addresses can repeatedly replace one another, producing intermittent failures that resemble packet loss elsewhere. Look for the changing local mapping before changing the server.

Learning alone also cannot make an arbitrary looped topology safe. A broadcast can circulate through redundant links without reaching an IP router that would decrement TTL, because switches are forwarding frames inside one link domain. Loop prevention or a deliberately controlled fabric supplies that missing rule. A switch table reduces routine fan-out, but it does not prove a safe physical topology or a correct remote route.