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.
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.
| Protocol | How the hosts share the medium |
|---|---|
| TDMA | each host gets a dedicated time slot |
| FDMA | each host gets a dedicated frequency band |
| CAN bus | the highest-priority transmission dominates the others |
| Token ring, FDDI | the 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.
- A remote sends a frame.
- It waits for an ACK on the downlink, or for a timeout.
- If the ACK arrives, the transmission succeeded.
- On a timeout, the remote waits a random time and returns to step 1.
- 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 .
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 be the maximum propagation delay between two hosts.After , every host hears A and stays silent.Other hosts can therefore start only within 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 CSMA | waits until the channel is free, then transmits at once |
| Non-persistent CSMA | waits 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:
- The hosts pick their random delays independently.
- 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, .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 -th collision, a host waits slot times:
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.
- The host waits until the channel is free.
- It sends the frame and senses the channel until the frame ends or it detects a collision.
- If no collision occurs, the transmission succeeded.The host waits the inter-frame gap before its next frame.
- On a collision, the host stops the frame and sends a jam signal.It then waits its backoff and returns to step 1.
- After the maximum number of attempts, the host gives up.
B starts shortly before , so its first bit reaches A only near .Detecting a collision can therefore take a full slot time.
A waits a random backoff , and B waits .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.
A frame of bits at bit rate has a transmission delay of .If this delay exceeds the slot time, the sender detects every collision:
Minimum frame size. The minimum frame size is the lower bound on .It equals the bandwidth-delay product, .
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:
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.
RTS/CTS. RTS/CTS is a handshake that mitigates hidden stations.
- A sends an RTS (Request To Send) to the base station B.
- B answers with a CTS (Clear To Send).The CTS declares how long the exchange lasts.
- The hidden station C hears the CTS and stays silent for the declared time.
- A sends the data, and B returns an ACK.
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.
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.
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.
Each full-duplex link carries two frames at once:
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.
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 address | The switch |
|---|---|
| known, on another port | forwards the frame to that port |
| known, on the incoming port | discards it: no forwarding is needed |
| unknown | floods 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.
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 MAC | Port at S3 |
|---|---|
| MAC of A | 1, then 3, then 1 again |
| MAC of B | 1 |
| MAC of C | 3 |
| MAC of D | 3 |
| MAC of E | 2 |
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.
- The switches elect a root: the switch with the smallest ID.The ID is configurable.
- Each switch activates only the links on its shortest path to the root.The spanning tree is the set of these shortest paths.
- 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.
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.
S4 reaches S1 through S3 at cost , and through S5 at cost .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).