knowledge

Lecture 4

Sharing a Medium

Several LAN hosts can share one physical medium.The Medium Access Control (MAC) layer controls their access to it.The medium is a cable, as in coaxial Ethernet or Powerline, or a radio link, as in 4G/5G, WiFi or Bluetooth.The shared medium is also called the channel.

BusABCDRingABCDStarABCD
BusABCDRingABCDStarABCD
Four hosts on one shared medium (thick line).

Collision. A collision is the overlap of two frames on one medium.Their signals interfere, so the receivers cannot decode them.

Joint decoding. Under joint decoding, all hosts transmit freely.The receiver separates and decodes the overlapping signals together.Cellular networks use it (e.g. CDMA, Code Division Multiple Access).

Mutual exclusion. Under mutual exclusion, hosts take turns.Only one host transmits at a time.Ideally, the hosts enforce the turns with a distributed protocol.

Deterministic protocol. A deterministic protocol prevents collisions.It enforces mutual exclusion by arbitrating access to the medium.

TDMA and FDMA are Time and Frequency Division Multiple Access.CAN is the Controller Area Network, and FDDI is the Fiber Distributed Data Interface.

ProtocolHow the hosts share the medium
TDMAeach host gets a dedicated time slot
FDMAeach host gets a dedicated frequency band
CAN busthe highest-priority transmission dominates the others
Token ring, FDDIthe token holder transmits, then passes the token on

Token passing is more flexible than TDMA and FDMA, and it may achieve a higher throughput.

Deterministic protocols need synchronization and pre-configuration.They therefore work only with few users.If a host goes down or a new one appears, the network must be reconfigured.

Random-access protocol. A random-access protocol allows collisions.It enforces mutual exclusion by reacting to each collision.Each host decides alone when to transmit, and it transmits at full rate.If a host detects a collision, it retransmits after a random time.This random time is the backoff.

Random access runs on WiFi, Zigbee, early Ethernet, Ethernet over Powerline and the signaling channel of cellular networks.Random-access protocols are also called stochastic protocols.

Random Access

ALOHA

ALOHA. ALOHA is a random-access protocol without listening.In ALOHA, remotes transmit frames to a center.

The remotes share one uplink channel, and they cannot hear each other's transmissions.The center returns ACKs on a separate downlink that never interferes.

centerremoteremoteremoteremoteACKshared uplinkseparate downlinkdata
ALOHA: remotes around a center.
  1. A remote sends a frame.
  2. It waits for an ACK on the downlink, or for a timeout.
  3. If the ACK arrives, the transmission succeeded.
  4. On a timeout, the remote waits a random time and returns to step 1.
  5. After the maximum number of attempts, the remote gives up.

ALOHA leaves the choice of the random waiting time open.It comes from the University of Hawaii, where it linked islands by radio channels at low bit rates.It is the basis of all non-deterministic access methods.

ALOHA also runs on a cable bus.It suits systems where simplicity matters more than performance, such as a machine bus.

Pure ALOHA. In pure ALOHA, a remote starts at any moment.Its maximum utilization is 18% of the channel capacity.This value assumes independent, exponential inter-arrival times of frames and retransmissions.Today, the long-range IoT network LoRaWAN uses pure ALOHA.

Slotted ALOHA. In slotted ALOHA, time is cut into slots.A remote starts only at the beginning of a slot.This rule doubles the maximum utilization, to 36%.A 4G/5G phone uses slotted ALOHA on the signaling channel each time it attaches or hands over to a base station.

CSMA

Carrier Sense Multiple Access (CSMA). CSMA is ALOHA with listening.A host senses the channel and transmits only if the channel is free.This listening is called carrier sensing.If no ACK returns, the host retransmits.

CSMA is more efficient than ALOHA, but every host must hear the transmissions of the others.

Example 1. A collision despite carrier sensing.

The propagation delay between A and B is 2 ms.All hosts are silent until A starts transmitting at t=0t = 0.

AtimeBtimestarts at senses an idle channel,starts at msA's first bit arrives:collision at msA's frameB's frame2 ms
Propagation delay 2 ms between A and B. The gap between 1.9 ms and 2 ms is stretched.

An idle channel at B does not mean that A is silent.A's signal needs 2 ms to reach B.

Carrier sensing therefore avoids many collisions, but not all.Collisions occur even when the transmission delays are very small.

Let DD be the maximum propagation delay between two hosts.After DD, every host hears A and stays silent.Other hosts can therefore start only within DD after A starts.If no collision occurs in this window, A has transmitted successfully.CSMA works better when the propagation delay is small.

If the channel is busy, the host
Persistent CSMAwaits until the channel is free, then transmits at once
Non-persistent CSMAwaits a random time, then senses the channel again

Persistent CSMA synchronizes the waiting hosts.If several hosts wait for a busy channel, they all transmit when it frees, and they collide.Non-persistent CSMA avoids this synchronization.

Two conditions make one host seize the channel with high probability:

  1. The hosts pick their random delays independently.
  2. The delays are longer than the maximum propagation delay.

Example 1 shows why the second condition matters:two hosts that start less than one propagation delay apart can collide.Non-persistent CSMA thus beats persistent CSMA in utilization, but collisions still occur under both.

CSMA with Collision Detection (CSMA/CD)

CSMA/CD. CSMA/CD is CSMA in which a host senses while it transmits.CSMA/CD performs better than ALOHA and CSMA.

Jam signal. The jam signal is a 32-bit pattern that announces a collision.It makes every host recognize the collision.

Slot time. The slot time is the round-trip propagation delay, 2D2D.A sender hears any collision at most one slot time after it starts.

Common mistake. The slot time is not a slot of slotted ALOHA.It is a delay that bounds collision detection, not a turn to transmit.

Binary exponential backoff. Each collision doubles the backoff range.The range stops growing after the tenth collision.After its NN-th collision, a host waits rr slot times:

k=min⁡(10,N),r∈{0,1,…,2k−1} chosen uniformly.k = \min(10, N), \qquad r \in \{0, 1, \ldots, 2^k - 1\} \text{ chosen uniformly}.

This backoff is one choice of the random wait that ALOHA leaves open.Under congestion, the growing backoff slows down channel access.

Inter-frame gap. The inter-frame gap is a pause after each frame.It lasts 0.96 µs at 100 Mb/s and 96 ns at 1 Gb/s.Both values equal 96 bit times.The gap avoids blind times, when adapters filter the typical noise at transmission ends.

  1. The host waits until the channel is free.
  2. It sends the frame and senses the channel until the frame ends or it detects a collision.
  3. If no collision occurs, the transmission succeeded.The host waits the inter-frame gap before its next frame.
  4. On a collision, the host stops the frame and sends a jam signal.It then waits its backoff and returns to step 1.
  5. After the maximum number of attempts, the host gives up.
AtimeBtimestartsdetects the collision,sends a jam signalsenses B's frame,defers to Bstarts shortly before detects the collision,sends a jam signalsenses an idle channel,retransmitsA's frameB's framejam signal (32 bits)
A collision under CSMA/CD.

B starts shortly before DD, so its first bit reaches A only near 2D2D.Detecting a collision can therefore take a full slot time.

A waits a random backoff Δt1\Delta t_1, and B waits Δt2\Delta t_2.B's backoff ends first, so B retransmits and A defers to B.

A host detects a collision only while it is still transmitting.A frame that is too short ends before the collision returns to its sender.

Frame too short:A misses the collisionAtimeCtimeBtimeFrame long enough:A sees the collisionAtimeCtimeBtimeA's frameB's framecollision seenslot timeslot time
Frame too short:A misses the collisionAtimeCtimeBtimeFrame long enough:A sees the collisionAtimeCtimeBtimeA's frameB's framecollision seenslot timeslot time
B starts shortly before A's first bit reaches it.

A frame of LL bits at bit rate bb has a transmission delay of L/bL/b.If this delay exceeds the slot time, the sender detects every collision:

slot time<Lb  ⟹  L>b⋅slot time.\text{slot time} < \frac{L}{b} \quad\implies\quad L > b \cdot \text{slot time}.

Minimum frame size. The minimum frame size is the lower bound on LL.It equals the bandwidth-delay product, b⋅slot time=2Dbb \cdot \text{slot time} = 2Db.

If a long enough frame ends without a collision, the frame has been transmitted correctly.CSMA/CD therefore needs no ACKs.

CSMA/CD in early Ethernet

Early Ethernet used coaxial cables with T-connectors, or hubs.

Hub. A hub, or concentrator, is a box of repeaters.It repeats every incoming bit on all its other links, so the hosts of a hub share one medium.Hosts connect to a hub by twisted-pair copper wires.

Half-duplex link. A half-duplex link sends one way at a time.

The links of early Ethernet are half-duplex, so early Ethernet is also called half-duplex Ethernet.It handles collisions with CSMA/CD and a fixed slot time.The slot time fixes the minimum frame size.

Example 2. The 64-byte Ethernet frame.

Half-duplex Ethernet at 10 Mb/s has a slot time of 51.2 µs.Its minimum frame size follows from the slot time:

b⋅slot time=10 Mb/s×51.2 μs=512 bits=64 bytes.b \cdot \text{slot time} = 10\ \text{Mb/s} \times 51.2\ \mu\text{s} = 512\ \text{bits} = 64\ \text{bytes}.

CSMA with Collision Avoidance (CSMA/CA) in WiFi

CSMA/CA. CSMA/CA is CSMA with three rules that avoid collisions.The rules are RTS/CTS, a conservative backoff and the NAV.

WiFi uses CSMA/CA and calls its hosts stations.As in ALOHA, a station infers a collision when no ACK returns.

Hidden station. A hidden station reaches the receiver but not the sender.The sender cannot sense its frames, so the frames of both stations can collide at the receiver.

A's rangeC's rangeAsenderBreceiverChidden station
B is in both radio ranges, but A and C cannot hear each other.

RTS/CTS. RTS/CTS is a handshake that mitigates hidden stations.

  1. A sends an RTS (Request To Send) to the base station B.
  2. B answers with a CTS (Clear To Send).The CTS declares how long the exchange lasts.
  3. The hidden station C hears the CTS and stays silent for the declared time.
  4. A sends the data, and B returns an ACK.
AtimeBtimeCtimeC stays silent forthe time declaredin the CTSRTSCTSCTSdataACK
C cannot hear A's RTS, but it hears B's CTS.

Conservative backoff. A WiFi station always backs off before sending.It waits a random time even when the channel is idle.

Network Allocation Vector (NAV). The NAV is the time a frame reserves.The frame announces this time in its MAC header.Every station that hears the frame stays silent for that time.The NAV is thus a virtual form of carrier sensing.

Example 3. Concurrent frames in classic WiFi.

A classic WiFi network has one channel and one base station.Its MAC controls every sender's access through CTS signals.The network therefore carries at most one data frame at a time, counting both directions.

The contention mechanism sets this limit, not physics.Since WiFi 6 (802.11ax), one base station can serve several stations in the same transmission opportunity, with OFDMA and MU-MIMO.OFDMA is Orthogonal Frequency-Division Multiple Access, and MU-MIMO is Multi-User Multiple-Input Multiple-Output.

Switched Ethernet

Today, Ethernet runs on switches and full-duplex cables.A switch is also called a bridge.A switch is a middlebox of the MAC layer and a queueing system.

Port. A port is a physical interface of a switch.A switch's port number identifies an interface.A transport-layer port number identifies a process.

Frame buffer. A frame buffer is a queue of frames inside a switch.Frames wait there until their outgoing port is free.

ABswitchport 1port 2forwardingBAframe bufferport 3Cnext to transmit
A and B both send a frame to C through a switch.

Full-duplex link. A full-duplex link sends both ways at once.

UTP (unshielded twisted pair) cables are full-duplex, with separate wires for the uplink and the downlink.Frames flow in both directions without collisions, so full-duplex Ethernet is also called collision-less Ethernet.

Switched Ethernet. Switched Ethernet links each host to a switch.Each host has its own full-duplex link.

Switches are transparent.End systems run the same protocol on a coaxial cable, a hub or a switch.A switched LAN has no collisions, so CSMA/CD is disabled by default.

Coaxial cableABCHubABCSwitchABCEthernet frameBdestinationAsourcedata
Coaxial cableABCHubABCSwitchABCEthernet frameBdestinationAsourcedata
The same Ethernet frame from A to B on three networks. The thick line is a shared medium.

Example 4. Concurrent frames in a switched LAN.

The LAN has four switches, six hosts and nine full-duplex links.Each switch has one LAN adapter per port, so it transmits on all its ports in parallel.

Sw1Sw0Sw3Sw2ABCDEFone frame ineach direction
Switches are boxes and hosts are circles. Each arrow is one frame.

Each full-duplex link carries two frames at once:

9 links×2 directions=18 simultaneous transmissions.9 \text{ links} \times 2 \text{ directions} = 18 \text{ simultaneous transmissions}.

On shared-medium, half-duplex Ethernet, the whole LAN is one medium.It carries one frame at a time.

Forwarding and Self-Learning

A switch's forwarding table maps destination MAC addresses to ports.The lookup is an exact match, not a longest prefix match.

SABC123Destination MACPortMAC of A1MAC of B2MAC of C3
A switch and its forwarding table.

Flooding. Flooding broadcasts a frame on all ports but the incoming one.

The switch observes all traffic on all its ports.For each incoming frame, it looks up the destination MAC address.

Destination MAC addressThe switch
known, on another portforwards the frame to that port
known, on the incoming portdiscards it: no forwarding is needed
unknownfloods the frame

Smart switches handle multicast frames differently.

Self-learning. A switch fills its table from source MAC addresses.A frame from A that arrives on port 1 creates the entry "MAC of A, port 1".

Self-learning needs no configuration, so the switch is plug-and-play.

Ageing time. The ageing time is the lifetime of a learned entry.The entry expires unless the switch relearns it in time.

IP routers differ: they fill their tables with routing algorithms.

Loops and the Spanning Tree Protocol

Example 5. Self-learning on a loop.

Three switches form a loop.A sends a frame to an unknown destination.

S3S1S2EABCD12341234123
Small numbers are ports. Blue arrows are copies of A's frame flooded by S1 and S2.

S3 receives a copy from S1 on port 1 and a copy from S2 on port 3.Switches are queueing systems with non-deterministic delays, so either copy can arrive last.

S3 learned the entries for B, C, D and E from earlier frames.

Destination MACPort at S3
MAC of A1, then 3, then 1 again
MAC of B1
MAC of C3
MAC of D3
MAC of E2

S3 cannot know whether A is behind port 1 or port 3.The entries of the table can change forever.Flooded frames also stay trapped in the loop, because Ethernet frames have no TTL to discard them.Self-learning therefore works only on a loop-free topology.

Spanning Tree Protocol

Spanning tree. A spanning tree joins all switches without a loop.

Spanning Tree Protocol (STP). STP makes the active topology a tree.It deactivates some links so that a spanning tree remains, and it adapts the tree to link failures and additions.

Each link between switches has a configurable cost.The cost is typically a decreasing function of the bit rate.A shortest path is a path of smallest total cost.

  1. The switches elect a root: the switch with the smallest ID.The ID is configurable.
  2. Each switch activates only the links on its shortest path to the root.The spanning tree is the set of these shortest paths.
  3. The switches monitor whether the root is reachable.If it is not, they trigger the computation of a new spanning tree.

STP is a distributed algorithm with no central control, and it is plug-and-play.The switches learn each other's IDs with a gossip protocol.They compute the shortest paths with a variant of the Bellman-Ford (distance-vector) algorithm.Radia Perlman invented STP.

An ID may be built from a MAC address.Managed switches therefore have MAC addresses, used for management and STP, not for forwarding.

These rules assume point-to-point links between switches.Shared-medium links between switches need more care.

Example 6. A link fails.

Four switches form a square with S1 as the root.Links S1–S2, S1–S3, S1–S4 and S2–S3 cost 1, and link S3–S4 costs 2.Link S1–S3 fails.

BeforeS1rootS4S2S3After S1-S3 failsS1rootS4S2S3111121failed112
BeforeS1rootS4S2S3After S1-S3 failsS1rootS4S2S3111121failed112
Thick links form the spanning tree. Dashed links are inactive or failed.

Before the failure, S2, S3 and S4 each reach S1 directly at cost 1.After it, S3 no longer reaches the root directly, so the switches recompute the tree.S3 reaches S1 through S2 at cost 2, and through S4 at cost 3.Link S2–S3 joins the tree, and link S3–S4 stays inactive.

Classic STP (IEEE 802.1D) takes 30 to 50 seconds to reconverge after a failure.Rapid STP (RSTP, IEEE 802.1w) takes about one second.

Tree paths and shortest paths

Example 7. A spanning tree from link costs.

S1 has the smallest ID, so S1 is the root.S4 chooses between its paths to S1 through S3 and through S5.

S1rootS2S5S3S4S6AB1001001001001001100
Labels are link costs. Thick links form the spanning tree; dashed links are inactive. Blue arrows carry a frame from A to B.

S4 reaches S1 through S3 at cost 100+1=101100 + 1 = 101, and through S5 at cost 100+100=200100 + 100 = 200.S4 therefore uses S4–S3, not S4–S5.S5 reaches S1 directly at cost 100.Neither end uses S4–S5, so STP deactivates it.

S2 reaches S1 directly at cost 100, while the route through S3 costs 101.S3 reaches S1 directly at cost 1.Neither end uses S2–S3, so STP deactivates it.

Every frame travels on the spanning tree, even when a shorter path exists.Frames from A to B follow S5–S1–S3–S4 at cost 201, while the inactive direct link S5–S4 costs only 100.STP is therefore less efficient than shortest-path forwarding.

Shortest Path Bridging (SPB). SPB replaces the tree with shortest paths.It computes loop-free shortest paths between every pair of switches, with link-state routing.More sophisticated switches implement SPB (IEEE 802.1aq).