# igmp — IPv4 IGMPv1/v2/v3 Multicast Queries, Joins & Leaves (`igmp`)

> **FrameAssembly v3.2.2** · Protocol 11 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/igmp

- **Full Protocol Name:** Internet Group Management Protocol v1, v2 & v3
- **Keyword:** `igmp`
- **OSI Layer & Transport:** Layer 3 · IPv4 Proto 2 (TTL 1)
- **Host Endpoint Rule:** IPv4-Only
- **Standards:** RFC 1112, RFC 2236, RFC 3376
- **Wireshark Display Filter:** `igmp`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 -> IGMPv1/v2/v3 (IPv4 Proto 2 (TTL 1))`

## Overview

Multicast is great right up until IGMP snooping misbehaves and floods video onto every desk phone in the building. `igmp` builds `query`, `report`, and `leave` frames at `ttl 1` with RFC 1112 multicast MACs.

Internet Group Management Protocol (`igmp`) manages IPv4 multicast group memberships between receivers and local multicast routers (and Layer 2 IGMP Snooping switches) over **IPv4 Protocol `2`** with `ttl 1`.

FrameAssembly supports all three protocol generations—`v1` (RFC 1112), `v2` (RFC 2236, default, adding fast `leave`), and `v3` (RFC 3376 source-specific Group Record Membership Reports `0x22` and 12-byte Queries)—computing the RFC ones-complement IGMP checksum automatically.

## Minimal Quickstart (`igmp_quickstart.frasm`)

```frameassembly
host querier  { ip 10.20.1.1 }
host receiver { ip 10.20.1.55 }

compile {
    querier -> receiver igmp v2 query group 224.0.0.1 maxresp 100 wait 5ms
    receiver -> querier igmp v2 report group 239.1.1.10
}
```

### Automatic Wire Calculations

- Encapsulates inside IPv4 Protocol `2` with link-local `ttl 1` by default.
- Maps version + operation cleanly onto wire Type codes: `0x11` (`query`, 8B in v1/v2 or 12B in v3), `0x12` (`v1 report`), `0x16` (`v2 report`), `0x17` (`v2 leave`), and `0x22` (`v3 report` with `MODE_IS_EXCLUDE` Group Record).
- Derives RFC 1112 multicast destination MACs (`01:00:5e:xx:xx:xx`) automatically when the destination host IP is in `224.0.0.0/4`.

## Practical Lab Example: VLAN-Tagged IGMPv2 Query,IGMPv3 Receiver Join, and IGMPv2 Fast Leave (`igmp_snooping_vlan.frasm`)

Demonstrates a multicast router polling VLAN 50, one receiver joining `239.255.10.1` via IGMPv3, and a second receiver joining and leaving via IGMPv2.

```frameassembly
host mcast_rtr { ip 10.50.0.1 }
host all_hosts { ip 224.0.0.1 }
host decoder_1 { ip 10.50.0.21 }
host decoder_2 { ip 10.50.0.22 }

compile {
    // 1. General Query to 224.0.0.1 (auto-derives MAC 01:00:5e:00:00:01)
    mcast_rtr -> all_hosts igmp v2 query group 0.0.0.0 maxresp 100 vlan 50 wait 4ms
    // 2. Receiver 1 sends IGMPv3 Membership Report for 239.255.10.1
    decoder_1 -> mcast_rtr igmp v3 report group 239.255.10.1 vlan 50 wait 3ms
    // 3. Receiver 2 joins and then leaves 239.255.10.2 via IGMPv2
    decoder_2 -> mcast_rtr igmp v2 report group 239.255.10.2 vlan 50 wait 20ms
    decoder_2 -> mcast_rtr igmp v2 leave group 239.255.10.2 vlan 50
}
```

```bash
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show igmp_snooping_vlan.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly igmp_snooping_vlan.frasm igmp_snooping_vlan.pcap
frameassembly igmp_snooping_vlan.frasm igmp_snooping_vlan.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse igmp_snooping_vlan.pcap igmp_snooping_vlan_edited.frasm

# 4. Verify dissected protocol fields in tshark
tshark -r igmp_snooping_vlan.pcap
```

## All `igmp` Keywords & Header Options

Packet line pattern: `src_host -> dst_host igmp [query | report | leave] [v1 | v2 | v3 | version <1|2|3>] [group <ipv4>] [maxresp <0..255>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `query \| report \| leave` | IGMP message type | `query` | Selects Membership Query (`0x11`), Membership Report (`0x12` v1 / `0x16` v2 / `0x22` v3), or Leave Group (`0x17`). |
| `v1 \| v2 \| v3 \| version <1\|2\|3>` | Protocol version selector | `v2` | Selects RFC 1112 IGMPv1, RFC 2236 IGMPv2, or RFC 3376 IGMPv3 packet encoding. |
| `group <ipv4>` | IPv4 multicast address | `224.0.0.1 (or 0.0.0.0 general query)` | Sets the 4-byte Group Address in v1/v2 headers or the Multicast Address inside the v3 Group Record. |
| `maxresp <0..255>` | Whole number (0..255) (1/10th seconds) | `100 (10.0 seconds)` | Sets the Max Response Time byte in IGMPv2/v3 Queries (`0` in IGMPv1 and Reports). |

## Cross-Layer Options Valid with `igmp`

| Option | Range / Format | Default | Effect |
| --- | --- | --- | --- |
| `wait <number><ns\|us\|ms\|s\|m>` | Time gap (ns, us, ms, s, m) | `10ms` | Advances the packet timestamp clock after sending this packet and before the next packet (`wait 0ns` sends back-to-back). |
| `payload "<text>" \| hexpayload "<hex>"` | Quoted text or hex bytes (choose one) | `Omitted` | Appends or overrides raw payload bytes (`"deadbeef"` or `"de:ad:be:ef"`) and updates packet lengths and checksums. |
| `srcmac <mac> \| dstmac <mac> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType for this single packet. |
| `vlan <0..4095> [pcp <0..7>] [dei <0\|1>]` | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | `Untagged` | Wraps the packet in an IEEE 802.1Q VLAN tag (`0x8100`) with optional 802.1p QoS priority. |
| `qinq <0..4095> [innervlan <0..4095>]` | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | `Untagged (innervlan 1 when qinq is set)` | Double-tags the packet with outer IEEE 802.1ad S-Tag (`0x88a8`) plus inner IEEE 802.1Q C-Tag (`0x8100`). |
| `mpls <0..1048575> [label <0..1048575>] [exp\|tc <0..7>] [bos <0\|1>] [mplsttl <0..255>]` | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | `Unlabeled (at most 1 mpls tag per packet)` | Inserts a 32-bit MPLS label header (`0x8847`) ahead of the Layer 3 header. |
| `ttl <0..255> [dscp <0..63>] [ecn <0..3>]` | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | `ttl 1, dscp 0, ecn 0` | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| `ipid <0..65535> [df] [mf] [fragoffset <0..8191>]` | IPv4 ID, DF/MF flags, fragment offset 0..8191 | `ipid 1, flags 0, fragoffset 0` | Sets IPv4 Identification, Do-Not-Fragment (`df`), More-Fragments (`mf`), and fragment offset (ignored over IPv6). |

## Common Mistakes & Quick Fixes

### IPv4 Endpoints Are Required on igmp (Use mld for IPv6)

- **Avoid:** `host6_a -> host6_b igmp v3 report`
- **Valid v3.2.2 Syntax:** `host6_a -> host6_b mld report multicastaddr ff02::16`

IGMP runs exclusively over IPv4, so IPv6 hosts are rejected on `igmp` lines. For IPv6 multicast group management, use `mld` (Multicast Listener Discovery).

### maxresp Is Expressed in Tenths of a Second

- **Valid v3.2.2 Syntax:** `rtr -> host1 igmp v2 query maxresp 100`

Per RFC 2236, `maxresp 100` represents `10.0` seconds (`100 * 0.1s`), and `maxresp 10` represents `1.0` second.
