The idea: one packet, many receivers

A video source wants to reach many viewers on the same LAN. With unicast it would send one copy per viewer. With IP multicast it sends one packet to a group address, here 239.1.1.1, and the network makes the copies. Two things must then be solved. The router must learn whether anyone on the LAN wants the group: that is IGMP, the Internet Group Management Protocol. And the switch must decide which ports get the copies: a plain switch sends them everywhere, a switch with IGMP snooping sends them only where they are wanted.

Left: a switch without snooping copies the video from S to all five other ports, so the non-members H2 and H4 get it too. Right: a switch with IGMP snooping sends it only to the members H1 and H3 and to the router port.
Without snooping the switch floods the stream to every port; with snooping only members and the router port get it.

Group addresses and MAC addresses

Multicast groups use the IPv4 range 224.0.0.0/4. Addresses in 224.0.0.0/24 are for the local link only: 224.0.0.1 means all systems, 224.0.0.2 all routers. 239.0.0.0/8 is for groups used inside one organisation, like the video group on this page. On Ethernet, a group maps to a MAC address: the prefix 01:00:5e, one zero bit, then the low 23 bits of the IP address. So 239.1.1.1 becomes 01:00:5e:01:01:01. Five bits of the IP address are lost, so 32 groups share each MAC address.

239.1.1.1 in binary; its low 23 bits are copied after the fixed 25 bits 01:00:5e plus a zero bit, which gives the MAC address 01:00:5e:01:01:01. The 5 bits in between are dropped.
The group MAC keeps only the low 23 bits of the group address.

Joining: the Membership Report

When an app on a host joins a group (the socket option IP_ADD_MEMBERSHIP), the kernel sends a Membership Report (IGMPv2 type 0x16) to the group address itself. All IGMP messages have IP TTL 1 and the Router Alert option: they never leave the LAN. The router R1 marks the group as Members Present and starts a group timer of 260 s, the Group Membership Interval (2 × 125 s + 10 s). RFC 2236 also asks the host to repeat the report once after up to 10 s in case it was lost; the page does not draw that repeat (Demo: two hosts join, video goes only to them).

Queries and report suppression

A host may vanish without saying goodbye, so the router asks again. One router per LAN is the querier (the one with the lowest IP address). Every 125 s (the Query Interval) it sends a General Query, type 0x11 with group 0.0.0.0, to 224.0.0.1. The query carries a Max Resp Time of 10 s. Each member starts a timer with a random delay up to that time and becomes a Delaying Member. The first timer to fire sends a report. The router only needs to know that some member exists, so in IGMPv2 every other member that hears that report cancels its own timer: report suppression. One report per group per query is enough (Demo: General Query and report suppression).

MessageTypeSent toSent by
General Query0x11, group 0.0.0.0224.0.0.1querier, every 125 s
Group-Specific Query0x11, group 239.1.1.1239.1.1.1querier, after a Leave
v2 Membership Report0x16239.1.1.1member host
Leave Group0x17224.0.0.2leaving host

Leaving: the Group-Specific Query

When a host leaves (IP_DROP_MEMBERSHIP), it sends a Leave Group (type 0x17) to 224.0.0.2, all routers. The router cannot tell if that was the last member, so it moves the group to Checking Membership and sends a Group-Specific Query to the group, with a Max Resp Time of 1 s (the Last Member Query Interval). It sends up to 2 of them (the Last Member Query Count), 1 s apart. If any member answers, the group goes back to Members Present and the second query is not sent (Demo: H1 leaves, H3 keeps the group). If nobody answers, the router deletes the group after 2 s, and the stream stops within seconds instead of after 260 s (Demo: the last member leaves, the stream stops).

Time runs down. H1 sends a Leave Group to 224.0.0.2 at t = 0. R1 sends Group-Specific Query 1 at 0 s and query 2 at 1 s; nobody answers; at 2 s R1 deletes 239.1.1.1. In the other case H3 answers query 1 at 0.8 s and the group stays.
After a Leave the router asks the group twice, 1 s apart; one answer keeps the group, silence deletes it after 2 s.

IGMP snooping

To a plain switch, a multicast MAC address is like the broadcast address: it never learns it from a source address, so it floods the frame out of every port. Every host gets the video, and the ones that never joined throw it away in their network card after it has already used their link (Demo: no snooping, the video floods every port). A switch with IGMP snooping (RFC 4541) reads the IGMP messages that pass through it:

  • a Query tells it which port leads to the router (the router port, port 1 here); queries are still flooded;
  • a Report adds its port to the group's list; the report is passed only to the router port;
  • a Leave is passed to the router port; the port is removed if no report comes back on it after the router's Group-Specific Queries;
  • data for the group goes only to the listed ports and the router port.

Because reports now go only to the router, the other members never hear them, and report suppression stops happening: every member answers each query. That is what the switch needs, since it must see at least one report on every member port (Demo: with snooping, every member answers).

IGMPv3

IGMPv3 (RFC 3376) adds source filtering: a host can say "239.1.1.1, but only from 10.0.0.10" (INCLUDE mode) or "from anyone except …" (EXCLUDE mode). That makes source-specific multicast (SSM, 232.0.0.0/8) possible. v3 reports (type 0x22) go to 224.0.0.22, carry a list of group records, and have no report suppression: each host answers for itself, which also suits snooping switches. Leaving is a report that changes the group to INCLUDE with no sources.

Beyond the LAN: PIM

IGMP only runs between hosts and their first router. To get a stream from a source on another network, routers use a multicast routing protocol, usually PIM (Protocol Independent Multicast): the router that hears a report sends a PIM Join towards the source or a rendezvous point, and a distribution tree grows hop by hop. On this page the source is on the same LAN, so R1 gets a copy of the video but has no PIM join from another router and does not route it on.

See also the Ethernet switch for how a switch learns unicast MAC addresses and why it floods what it does not know, ARP for broadcast on the same LAN, VLANs, which limit flooding by splitting one switch into several LANs, and TCP vs UDP: multicast traffic is UDP.

What the page leaves out

The querier election between two routers and the Other Querier Present timer, IGMPv1 hosts and routers on the same LAN (compatibility timers), the repeated unsolicited report, startup queries, IGMPv3 records and source lists, snooping details such as fast-leave, the snooping querier, flooding of unregistered groups (some switches flood a group with no members; this page sends it only to the router port) and the 224.0.0.x range that is always flooded, MLD (the IPv6 version of IGMP), and PIM itself.

On the mind map

Open the Networking mind mapNetworkingLayers & links: frames on one local networkLayers & linksIP & routing: packets hop between networksIP & routingCore services: address, name and timeCore servicesTCP, UDP & sockets: end to end between two portsTCP, UDP & socketsHTTP & TLS: what a browser does per requestHTTP & TLSAPIs & push: how apps talk to serversAPIs & pushProxies & edge: boxes in the middle of the pathProxies & edgeContainers: virtual networks from Linux partsContainersReal-time media: voice and video over UDPReal-time mediaSecurity at the edge: filter traffic at the borderSecurity at the edgeProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ALoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNROpen the Networking mind mapNetworkingframes on one local networkLayers & linksProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ALoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNR
This page on the Networking mind map · 83 pages in 10 branches · open it to see the whole map and test yourself in recall mode.