Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 79 ยท Routing

Multicast, Broadcast and Quality of Service

Learn unicast, broadcast, multicast and anycast, how IGMP manages groups, and how QoS tools such as token buckets, queues and DiffServ protect traffic.

So far, almost every packet in this track had one sender and one receiver. That is unicast. It is not the only way to deliver data. Sometimes a packet needs to reach everyone on a network (a host looking for a DHCP server), a chosen group (a stock-price feed, an IPTV channel) or whichever server is closest (a DNS resolver). And once a link is crowded, the network must decide whose packets go first. This lesson covers both topics: the four delivery models, and Quality of Service (QoS), the set of tools that control delay, loss and bandwidth for different kinds of traffic.

Four ways to address a packet

Model Receivers Example
Unicast Exactly one Loading a web page
Broadcast Every host on the local network ARP request, DHCP discover
Multicast Every host that joined a group Live video distribution, routing protocols (OSPF)
Anycast The nearest of several hosts sharing one address DNS root servers, CDNs
flowchart LR
    subgraph U["Unicast"]
      u1["Sender"] --> u2["One receiver"]
    end
    subgraph B["Broadcast"]
      b1["Sender"] --> b2["Everyone on the LAN"]
    end
    subgraph M["Multicast"]
      m1["Sender"] --> m2["Group members only"]
    end

Unicast reaches one host, broadcast reaches everyone on the segment, and multicast reaches only the hosts that asked for the traffic.

Broadcast

IPv4 has two kinds of broadcast address. The limited broadcast, 255.255.255.255, goes to every host on the local link and is never forwarded by a router. A directed broadcast uses the last address of a subnet (for 192.168.1.0/24 that is 192.168.1.255) and reaches all hosts of that subnet; routers normally block directed broadcasts because they can be abused for amplification attacks (see the subnetting lesson for how the broadcast address is calculated). At layer 2 the broadcast MAC address is ff:ff:ff:ff:ff:ff.

Broadcast is cheap to understand but expensive to run: every host on the segment must receive and inspect the frame, even if it does not care. That is why broadcast domains are kept small, and why IPv6 has no broadcast at all. It uses multicast groups instead, such as ff02::1 (all nodes on the link).

Multicast

If a video server must send the same stream to a thousand viewers, unicast makes it send a thousand copies, and a link near the server carries them all. With multicast the sender transmits one packet to a group address. Routers copy the packet only where the paths to receivers split, so each link carries at most one copy.

IPv4 multicast addresses are in 224.0.0.0/4 (from 224.0.0.0 to 239.255.255.255). A few ranges matter:

  • 224.0.0.0/24: link-local control groups, never forwarded by routers. Examples: 224.0.0.1 (all hosts), 224.0.0.2 (all routers), 224.0.0.5 and 224.0.0.6 (OSPF).
  • 239.0.0.0/8: administratively scoped groups for use inside one organization, similar to private unicast addresses.

On Ethernet, a multicast IP address maps to a multicast MAC address that begins with 01:00:5e, followed by the low 23 bits of the group address. Because 28 bits of the address vary and only 23 are copied, 32 different IP groups share every MAC address, and hosts must still check the IP address.

Anycast

Anycast was introduced in the BGP lesson: several servers announce the same address, and routing delivers each packet to the nearest one. In IPv6, anycast is a formal address type that uses the unicast address space.

Joining a group: IGMP

How does a router know whether anybody on a segment wants a multicast group? Hosts tell it with the Internet Group Management Protocol (IGMP), which runs between hosts and their first-hop router. (IPv6 uses MLD, Multicast Listener Discovery, which does the same job over ICMPv6.)

  1. A host that wants group 239.1.1.1 sends a membership report for it.
  2. The router periodically sends a general membership query to 224.0.0.1. Hosts that still want any group answer with a report (with randomized delays so that one report per group is usually enough).
  3. When the last member leaves, the router stops forwarding the group after the query times out. In IGMPv2 and v3 a host can send an explicit leave message so that the router quickly asks "is anyone still here?".

IGMPv3 adds source-specific multicast (SSM): a host can say "I want group G, but only from source S", which avoids unwanted senders and simplifies routing.

Inside a LAN, a switch does not understand IP by default and floods multicast frames like broadcasts. IGMP snooping lets the switch listen to IGMP reports and send the group's traffic only to the ports where members live.

Between routers, multicast trees are built by multicast routing protocols, the main one being PIM (Protocol Independent Multicast). PIM uses the ordinary unicast routing table to find the way back to the source, and builds a tree of forwarding state along which each packet is copied only where branches split.

Multicast works well inside one organization, in data centers and in managed IPTV networks. Across the public Internet it is rarely available, because every network on the way would need to support it. Streaming across the Internet therefore usually uses unicast with CDNs instead.

IGMP versions and message types

IGMP has three versions, and a router and its hosts negotiate down to the oldest version present on the segment.

Version Year What it adds
IGMPv1 1989 Membership query from the router and report from hosts. There is no leave message: a router learns that nobody is left only when reports stop arriving
IGMPv2 1997 An explicit leave group message and a faster, group-specific query, so traffic stops quickly
IGMPv3 2002 Source filtering (include or exclude lists of senders), which enables source-specific multicast

The messages are: the general membership query (the router asks "which groups are in use?", sent to 224.0.0.1, the "all hosts" group), the group-specific query, the membership report (a host says which group it wants; to avoid a flood of identical reports, each host waits a random delay and cancels its report if it hears someone else's) and the leave. Reports go to the group address itself, and IGMPv3 reports go to 224.0.0.22. IGMP is a network-layer protocol carried directly in IP (protocol number 2), not in UDP or TCP.

IGMP and ICMP look alike, since both ride directly on IP and carry control messages, but they do different jobs: ICMP reports errors and answers diagnostic queries for any host, while IGMP only manages multicast group membership between hosts and their local router. ICMP can be abused for floods and reconnaissance, and IGMP can be abused by a host that joins many groups to exhaust a router's state, so both are filtered at network borders.

Quality of Service

A network link can carry only so much. When bursts of traffic exceed the capacity, packets wait in queues, and when the queue is full, packets are dropped. Without QoS every packet is treated alike ("best effort"), so a big download can add delay to a voice call. Different applications need different things:

Traffic Delay Jitter Loss Bandwidth
Voice call Very sensitive (under about 150 ms one way) Very sensitive Little tolerance Low
Live video Sensitive Sensitive Some tolerance High
Web browsing Moderate Low Retransmitted by TCP Medium
Backups and downloads Insensitive Insensitive Retransmitted High, but can wait

QoS tools give each class what it needs. The main pieces are classification and marking, queueing, rate control and congestion avoidance.

Traffic shaping and policing: the token bucket

To limit the rate of a flow while still allowing short bursts, networks use the token bucket. Imagine a bucket that gets new tokens at a steady rate (say, 5,000 per second) and holds at most a fixed number (the burst size). To send a packet, you must remove as many tokens as the packet has bytes. If the bucket does not hold enough tokens, the packet does not conform.

What happens to a non-conforming packet depends on the policy:

  • Policing drops (or re-marks) it at once. It is simple and needs no buffer, but loss makes TCP slow down abruptly.
  • Shaping holds it in a queue until enough tokens have accumulated. The output is smooth, but packets are delayed and the buffer takes memory.

The simulation sends ten 1000-byte packets, 0.1 seconds apart, through a bucket that refills at 5,000 bytes per second and holds 3,000 bytes. The sender's rate is 10,000 bytes per second, twice the allowed rate.

Python A token bucket: policing and shaping

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first five packets pass because the full bucket (3,000 bytes) plus the tokens that arrive meanwhile cover the burst. After that, the sender uses twice the allowed rate and the bucket stays empty: the policer drops every second packet, and the shaper delays each packet a little more than the last. A long, steady overload would fill any buffer, so shapers need a queue limit as well. The "leaky bucket" is a close relative that forces a perfectly constant output rate without allowing bursts.

Queueing disciplines

The queueing discipline decides which waiting packet the interface sends next:

  • FIFO (first in, first out) is the default: simple, but one heavy flow delays everyone.
  • Priority queueing always serves the highest class first. Voice stays fast, but low classes can starve if the high class never pauses.
  • Round robin and weighted fair queueing (WFQ) visit the classes in turn, in proportion to their weights, so no class starves.
  • Active queue management such as RED, CoDel or fq_codel drops or marks packets early, before the queue is full, so TCP senders slow down in time and delay stays small. Overly large buffers filled by a download are the cause of "bufferbloat", the lag you feel on a busy home connection.
Python Strict priority versus round robin

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Strict priority sends all voice and video before the first bulk packet. Round robin gives bulk traffic its fair turn, at the cost of making voice wait behind a video and a bulk packet. Real routers combine both: a small strict-priority queue for voice, and weighted fair sharing among the rest.

Marking traffic: DiffServ

For queues to treat traffic differently, packets must carry a label. Differentiated Services (DiffServ) uses the 6-bit DSCP field in the IP header (the upper six bits of the old Type of Service byte; the lower two are used for ECN). Each router maps a DSCP value to a per-hop behavior (PHB): a local rule for queueing and dropping. Common values:

  • EF (Expedited Forwarding, 46): low delay and loss, typically used for voice.
  • AF (Assured Forwarding) classes such as AF41 (34): a guaranteed share with a drop precedence that decides which packets go first when congested.
  • CS (class selector) values 0-7 times 8, compatible with the old IP precedence; CS0 or 0 is best effort.

DiffServ scales well because routers keep no per-flow state: they look at one field. Its limit is that markings are only trusted inside one administrative domain. Networks usually re-mark or ignore DSCP values arriving from outside, so a marking on your home traffic often does not survive the public Internet. The older IntServ model with RSVP reserved resources for each flow end to end; it gives strong guarantees but needs state in every router and is rarely used outside special networks.

The cheapest QoS is more capacity. QoS matters where bandwidth is scarce or expensive: WAN links, wireless networks and shared uplinks. On a link that is never congested, queues are empty and priorities change nothing.

Integrated Services, admission control and RED

Quality of service can be approached in two ways. Stateless solutions (DiffServ, above) keep no per-flow state in routers: packets carry a class mark and each router treats the whole class alike, so it scales to the core of the Internet. Stateful solutions keep information for each flow. The classic stateful design is Integrated Services (IntServ), which uses the RSVP signaling protocol to reserve resources along a path before the flow starts.

A sender describes its traffic with a T-spec (traffic specification): the token bucket rate and bucket size, the peak rate and the packet sizes. The receiver answers with an R-spec (reservation specification): the service it wants, for example a guaranteed rate and a delay bound. Each router on the path checks whether it can honor the reservation. This check is call admission control: if the resources are available, the flow is accepted and they are set aside, otherwise the request is refused. The benefit is firm guarantees (supporting service-level agreements, SLAs), and the disadvantage is that every router must store state and do work for every flow, which does not scale to millions of flows. That is why IntServ is mainly used at the edge or inside a company, and DiffServ in large networks.

Other ways to implement QoS include QoS-aware scheduling (priority queues and weighted fair queueing, shown earlier), QoS-aware routing (choosing paths that meet delay or bandwidth constraints), overprovisioning (simply having much more capacity than needed), and active queue management.

RED (Random Early Detection) is active queue management. Instead of waiting for the buffer to fill and then dropping every new packet ("tail drop"), a router starts dropping a growing fraction of packets at random once the average queue passes a minimum threshold. TCP senders see the early losses and slow down before the buffer overflows, which keeps queues short and avoids all flows backing off at once. WRED (Weighted RED) uses different thresholds for different classes, so low-priority traffic is dropped sooner than high-priority traffic.

Python Admission control and WRED drop probability

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At a queue of 35 packets, bulk traffic already sees a 15 percent drop probability and web 2.5 percent, while voice sees none, which is exactly the point of weighting: congestion hurts the least important class first.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why did IPv6 drop broadcast?

    IPv6 replaces broadcast with multicast. Only hosts that listen to a group process its packets, so unrelated hosts are not disturbed.
  2. 2. What does IGMP do?

    IGMP runs between hosts and their router. Multicast routing between routers is the job of PIM, and the MAC mapping is a fixed rule.
  3. 3. A token bucket refills at 5,000 bytes per second and holds 3,000 bytes. What is the main difference between policing and shaping a flow that exceeds the rate?

    Both use a token bucket to measure conformance. A policer drops or re-marks excess packets immediately. A shaper buffers them, which smooths the output but adds delay.
  4. 4. What is a risk of strict priority queueing?

    A strict-priority scheduler always serves higher classes first. If they have a constant supply of packets, lower classes never get a turn. That is why the priority queue is kept small or rate-limited.
  5. 5. Which header field does DiffServ use for marking?

    DSCP occupies the upper six bits of the former IPv4 TOS byte (and of the IPv6 Traffic Class). Routers map each value to a per-hop behavior.

Summary

  • Packets can be unicast, broadcast (everyone on the link), multicast (a group) or anycast (the nearest of several servers); IPv6 has no broadcast.
  • IPv4 multicast uses 224.0.0.0/4; IGMP (MLD in IPv6) lets hosts join groups, switches use IGMP snooping and routers use PIM to build trees.
  • QoS gives different traffic different treatment when links are congested.
  • A token bucket measures conformance to a rate with a burst allowance; policing drops excess, shaping delays it.
  • Queueing disciplines (FIFO, priority, fair queueing, active queue management) decide what is sent next.
  • DiffServ marks packets with DSCP values and each router applies a per-hop behavior, usually only inside one network.

Next, move up a layer to deliver data between programs in The Transport Layer and Ports.