Broadcasting and Multicasting: Mapping to MAC Addresses, Sending and Receiving
How one packet reaches many hosts: subnet and limited broadcasts, SO_BROADCAST, why routers don't forward directed broadcasts, mapping IPv4 and IPv6 multicast groups to Ethernet addresses, joining groups, multicast TTL and loopback, and filtering at each layer, all shown in a lab.
kvi5hnuCode Sprout team member16 min readOn this page
Most IP traffic is unicast: one sender, one receiver. Two other kinds of addresses (article 12) deliver a single packet to many receivers:
- Broadcast reaches every host on a network. IPv4 has it, and IPv6 dropped it.
- Multicast reaches only the hosts that have asked for it by joining a group. IPv4 added it later (RFC 1112), and IPv6 depends on it, because neighbor discovery uses it (article 42).
Applications use them for two kinds of job:
- Delivering the same data to many receivers, such as market data feeds, video distribution inside a network, or routing protocol updates, without sending a separate copy to each.
- Finding a server you don't know the address of yet. DHCP (article 29) broadcasts because the client has no address at all. Multicast DNS, SSDP (Simple Service Discovery Protocol, used by UPnP devices such as smart TVs) and many device discovery protocols multicast to a well-known group.
TCP can't use either. A TCP connection is between exactly two endpoints, so broadcast and multicast are for UDP (article 45) and for protocols that run directly over IP, such as ICMP, OSPF (a routing protocol used inside organizations) and IGMP (the multicast group-membership protocol, article 44).
The diagram compares the three kinds of delivery on one LAN, showing which hosts process each frame:

The trade-off: broadcast is simple, but every host on the network must receive and process every broadcast, whether or not it cares. Multicast involves only interested hosts, but it needs more machinery: group membership in hosts, filtering in network cards, and signaling to switches and routers (article 44).
The lab is one Ethernet segment (a Linux bridge) with three hosts, h1, h2 and h3 (192.0.2.11–13/24), and a router r (192.0.2.1) that connects to a server on 198.51.100.0/24.
Broadcasting
On an Ethernet, the broadcast MAC address ff:ff:ff:ff:ff:ff reaches every station on the LAN or VLAN. Switches flood it out of every port. IPv4 has two broadcast addresses that map to it:
- The subnet-directed broadcast address: the subnet's prefix with all host bits set to 1. For 192.0.2.0/24 it's 192.0.2.255.
- The limited broadcast address
255.255.255.255, meaning "everyone on this link", whatever the subnet is. A host that doesn't know its address yet uses it, as DHCP does.
Linux shows the subnet broadcast address on each interface (after brd) and keeps a broadcast route for it in the local table:
inet 192.0.2.11/24 brd 192.0.2.255 scope global eth0
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
broadcast 192.0.2.255 dev eth0 proto kernel scope link src 192.0.2.11
A broadcast ping
The classic way to see who's on a subnet is to ping its broadcast address. Linux's ping needs -b for that, and by default Linux hosts don't answer broadcast pings at all:
net.ipv4.icmp_echo_ignore_broadcasts = 1
WARNING: pinging broadcast address
2 packets transmitted, 0 received, 100% packet loss, time 1065ms
That's net.ipv4.icmp_echo_ignore_broadcasts = 1, the defense against the smurf attack (article 42). After turning it off on h2, h3 and r, the ping gets several answers for each request:
64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=0.251 ms
64 bytes from 192.0.2.13: icmp_seq=1 ttl=64 time=0.251 ms
64 bytes from 192.0.2.12: icmp_seq=1 ttl=64 time=0.251 ms
64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=0.120 ms
2 packets transmitted, 2 received, +2 duplicates, 0% packet loss, time 1035ms
02:00:00:00:00:01 -> ff:ff:ff:ff:ff:ff IP 192.0.2.11 -> 192.0.2.255 ICMP type 8
02:00:00:00:00:fe -> 02:00:00:00:00:01 IP 192.0.2.1 -> 192.0.2.11 ICMP type 0
02:00:00:00:00:03 -> 02:00:00:00:00:01 IP 192.0.2.13 -> 192.0.2.11 ICMP type 0
02:00:00:00:00:02 -> 02:00:00:00:00:01 IP 192.0.2.12 -> 192.0.2.11 ICMP type 0
echo replies in the capture: 6
The capture on h1 shows what happened at both layers:
- The request was an ordinary IPv4 packet to 192.0.2.255 in an Ethernet frame addressed to
ff:ff:ff:ff:ff:ff.h1didn't need ARP: it saw from its routing table that 192.0.2.255 is a broadcast address, and that alone determines the MAC address. - Each reply was unicast from the responder's own address to
h1.pingmarks the extra repliesDUP!and counts them as "+2 duplicates". h1learned the addresses of three hosts it didn't know about, which is the discovery use of broadcast.pingshows only one reply to the second request because it exits as soon as its last request has been answered. The capture, which ran a little longer, holds all six replies: three for each request.
SO_BROADCAST
Sending to a broadcast address from an application needs one extra step: the socket must have the SO_BROADCAST option set. Without it, the kernel refuses the send, so that a program can't flood a network by accident:
without SO_BROADCAST: [Errno 13] Permission denied
with SO_BROADCAST: sent to 192.0.2.255 and 255.255.255.255
On Linux the error is EACCES ("Permission denied"). That's also why ping needs -b: the flag sets SO_BROADCAST.
Which interface does a limited broadcast go out on? There's no single answer for a host with several interfaces. The standards never settled whether it should go out of all of them. Linux, FreeBSD and modern Windows send it on one interface, chosen by the routing table (on Linux, the default route's interface unless the socket is bound to a device with SO_BINDTODEVICE). Programs such as DHCP clients that care bind to a specific interface.
Directed broadcasts don't cross routers
A directed broadcast for a remote subnet, such as 198.51.100.255 sent from 192.0.2.0/24, would have to be forwarded by a router and then broadcast on the far network. That was the amplifier in smurf attacks, so RFC 2644 changed the default: routers must not forward directed broadcasts unless configured to. In the lab, h1 sent one to the server's subnet:
h1 sent a datagram to 198.51.100.255 (directed broadcast for the far subnet)
net.ipv4.conf.eth1.bc_forwarding = 0
server received: 0 datagram(s)
The router r received it, because its default route goes there, but didn't forward it: Linux's bc_forwarding is 0, and the server saw nothing. Some networks still enable directed broadcasts on specific router interfaces for Wake-on-LAN "magic packets" sent from another subnet.
Multicast addresses and their MAC addresses
IPv4 multicast addresses are 224.0.0.0/4: the top four bits are always 1110, which leaves 28 bits for the group ID. IPv6 multicast addresses start with ff, then 4 bits of flags and 4 bits of scope, leaving 112 bits for the group (article 12). A few ranges matter in practice:
- 224.0.0.0/24 (IPv4) and ff02::/16 (IPv6) are link-local. Routers never forward them. This is where all-hosts (224.0.0.1, ff02::1), all-routers (224.0.0.2, ff02::2), OSPF, mDNS (224.0.0.251, ff02::fb) and solicited-node addresses live.
- 232.0.0.0/8 and ff3x::/32 are for source-specific multicast (article 44).
- 239.0.0.0/8 is "administratively scoped": private to an organization, like 10/8 for unicast. IPv6 expresses this with the scope field instead (site-local ff05::, organization-local ff08::).
To deliver multicast efficiently on a LAN, each group needs its own Ethernet group address, which network cards can filter on. An Ethernet address is a group address when the lowest bit of its first byte is 1. Instead of using a protocol to look the MAC address up, as ARP does for unicast, IP derives it directly from the group address:
- IPv4: IANA owns the Ethernet prefix
00:00:5eand uses half of the corresponding group block for IPv4 multicast:01:00:5e:00:00:00to01:00:5e:7f:ff:ff. That's 23 bits, so the low 23 bits of the group address are copied in. - IPv6: the prefix is
33:33, followed by the low 32 bits of the group address (RFC 2464).

For example, 239.129.2.3 has second byte 129, binary 10000001. Its top bit is one of the 5 lost bits, leaving 0000001, so it maps to 01:00:5e:01:02:03, the same as 239.1.2.3. The mapping can't be one-to-one: 28 bits of group ID go into 23 bits, so 2⁵ = 32 IPv4 groups share every Ethernet address. For IPv6 it's far worse in theory (2⁸⁰ groups per address), but in practice most IPv6 groups differ in their low 32 bits. The lab computed a few:
224.0.0.1 -> 01:00:5e:00:00:01
224.0.0.251 -> 01:00:5e:00:00:fb
239.1.2.3 -> 01:00:5e:01:02:03
239.129.2.3 -> 01:00:5e:01:02:03
225.1.2.3 -> 01:00:5e:01:02:03
232.1.2.3 -> 01:00:5e:01:02:03
ff02::1 -> 33:33:00:00:00:01
ff02::fb -> 33:33:00:00:00:fb
ff02::1:ff00:12 -> 33:33:ff:00:00:12
The four groups that end in .1.2.3, from 225/8, 232/8 and 239/8, with and without the high bit of the second byte, all land on the same Ethernet address. A host that joins one of them will receive frames for all of them at the hardware level, and higher layers must discard the extras. That's why administrators choosing group addresses are advised to avoid ones that collide with heavily used groups, such as anything that maps to 01:00:5e:00:00:xx, the same addresses as the 224.0.0.x link-local groups.
Joining a group
A host doesn't receive a group's traffic until a process on it joins the group. Membership is per interface: a process can join the same group on several interfaces, or many groups on one. The sockets API does this with IP_ADD_MEMBERSHIP (IPv4) or IPV6_JOIN_GROUP (IPv6). Source-specific versions (IP_ADD_SOURCE_MEMBERSHIP, and the protocol-independent MCAST_JOIN_SOURCE_GROUP from RFC 3678) say which senders the process wants to hear. Leaving is explicit, or happens when the socket closes.
ip maddr shows an interface's memberships, at both the link and IP layers. Before any application joined anything, h2 already belonged to several groups:
link 33:33:00:00:00:01
link 01:00:5e:00:00:01
link 33:33:ff:00:00:02
link 33:33:ff:00:00:12
inet 224.0.0.1
33:33:00:00:00:01and01:00:5e:00:00:01are all-nodes (ff02::1) and all-hosts (224.0.0.1). Every host joins these.33:33:ff:00:00:02and33:33:ff:00:00:12are the Ethernet addresses ofh2's two solicited-node groups, one for its link-local address (fe80::ff:fe00:2) and one for2001:db8:1::12, used by neighbor discovery (article 42). IPv6 hosts join one for every address they have.
Then a program on h2 joined 239.1.2.3, and one on h3 joined 239.129.2.3, the colliding group:
link 33:33:00:00:00:01
link 01:00:5e:00:00:01
link 33:33:ff:00:00:02
link 33:33:ff:00:00:12
link 01:00:5e:01:02:03
inet 239.1.2.3
inet 224.0.0.1
(h3)
link 01:00:5e:01:02:03
inet 239.129.2.3
h1 default IP_MULTICAST_TTL: 1 IP_MULTICAST_LOOP: 1
h1 sent 2 datagrams to 239.1.2.3:5000
Each join added the IP group and its Ethernet address 01:00:5e:01:02:03. The kernel programs that Ethernet address into the network card's filter, and, as article 44 shows, announces the membership to routers and switches with IGMP or MLD.
Sending to a group
A process doesn't have to join a group to send to it. It just sends a UDP datagram to the group address. Three socket options control how:
IP_MULTICAST_TTL(IPv6:IPV6_MULTICAST_HOPS) is the TTL for multicast packets, and it defaults to 1, so multicast stays on the local network unless the application asks for more. TTL used to double as a scope mechanism ("TTL < 16 stays on site"); administrative scoping replaced that.IP_MULTICAST_IF(IPv6:IPV6_MULTICAST_IF) picks the outgoing interface. Without it, the routing table decides. Linux has no special multicast route by default, so IPv4 multicast follows the default route, and IPv6 uses anff00::/8route on each interface.IP_MULTICAST_LOOPdecides whether the sender's own host gets a copy, and it defaults to on. On Unix-like systems, it applies to the sending socket. Windows applies it on the receive side instead, which matters for portable code.
h1 sent two datagrams to 239.1.2.3 without joining:
h2 got 'news 1' from 192.0.2.11:50370
h2 got 'news 2' from 192.0.2.11:50370
h2 member of 239.1.2.3: received 2 datagram(s)
h3 member of 239.129.2.3: received 0 datagram(s)
h2 got both. h3 got nothing, even though it belongs to 239.129.2.3, which uses the same Ethernet address. The capture shows the frames:
02:00:00:00:00:01 -> 01:00:5e:01:02:03 IP dst 239.1.2.3 TTL 1
02:00:00:00:00:01 -> 01:00:5e:01:02:03 IP dst 239.1.2.3 TTL 1
router's other interface saw: 0 datagram(s)
The frames went to 01:00:5e:01:02:03 with TTL 1. The bridge flooded them to every port, because snooping, where a switch watches group membership messages to learn which ports want a group, is off in this lab (article 44 turns it on), so h3's interface received them too. Its IP layer then checked the full destination address, found no member for 239.1.2.3, and discarded them. The router saw them on its LAN side, but with TTL 1 and no multicast routing they went no further.
Filtering at every layer
A received multicast or broadcast frame passes through several filters, each of which can discard it:
-
The network card. It normally accepts only frames for its own address and the broadcast address. For multicast, the driver programs it with the group MAC addresses the host has joined. Cards do this in one of two ways:
- A small exact-match table. When there are more groups than entries, the card falls back to accepting all multicast ("all-multicast" mode).
- A hash filter: a bit vector indexed by a hash of the address. Unwanted addresses that hash to the same bit get through.
Either way, the card may pass frames the host didn't ask for, but never drops ones it wanted.
-
The device driver and link layer check the destination MAC address against the joined list exactly, for cards that filter imperfectly.
-
The IP layer checks the full group address against the host's memberships. This is the filter that stopped
h3in the lab, because the 23-bit mapping can't distinguish 239.1.2.3 from 239.129.2.3. It also checks the source if the host joined source-specifically. -
The transport layer delivers the datagram only to sockets bound to the destination port and member of the group. A datagram for a joined group but an unused port is discarded silently. Multicast never generates port unreachable errors (article 40).
Each layer catches what the one below lets through. Despite the imperfect mapping and filtering, multicast is still far cheaper than broadcast, where every host's IP and transport layers must look at every packet.
Common questions
Why doesn't IPv6 have broadcast?
Broadcast makes every host process every packet, and almost every use of it can be done with multicast to a group that only interested hosts join. IPv6 uses the all-nodes group ff02::1 for the rare cases that need everyone, and solicited-node groups to replace ARP's broadcasts, so a typical neighbor solicitation reaches only one host's IP layer.
Why do I get "Permission denied" when sending to a broadcast address?
The socket needs the SO_BROADCAST option, which protects against accidental broadcasts. Set it with setsockopt before sending. For ping, use -b on Linux. It isn't related to root privileges.
Why doesn't my multicast traffic leave the local network?
The default multicast TTL is 1, so routers don't forward it. Set IP_MULTICAST_TTL (or IPV6_MULTICAST_HOPS) higher, and make sure the routers between sender and receivers run multicast routing (such as PIM, Protocol Independent Multicast) and that the group isn't link-local (224.0.0.x, ff02::). Most of the Internet doesn't route multicast at all.
Do I need to join a group to send to it?
No. Joining is only for receiving. A sender just needs a UDP socket and the group address, plus IP_MULTICAST_IF if it should leave on a particular interface.
Can two programs on the same host receive the same multicast group on the same port?
Yes, if both set SO_REUSEADDR (or SO_REUSEPORT) and bind the same port. Each gets a copy of every datagram, unlike unicast UDP, where only one socket receives each datagram. That's why multicast receivers almost always set SO_REUSEADDR.
Why did my host receive traffic for a group it didn't join?
Either the 23-bit mapping put two groups on the same Ethernet address, or the card is in all-multicast or promiscuous mode, or the switch floods multicast. The IP and transport layers discard such traffic, so applications don't see it, but the CPU still handles it.
Summary
- Broadcast reaches every host on a link and exists only in IPv4. Multicast reaches hosts that joined a group and is required in IPv6.
- Both are for UDP and protocols directly over IP, not TCP. They're used for one-to-many delivery and for discovering servers.
- IPv4 has subnet-directed broadcasts (all host bits 1) and the limited broadcast 255.255.255.255. Both are sent to Ethernet
ff:ff:ff:ff:ff:ffwith no ARP. - Applications must set
SO_BROADCASTto send broadcasts. Linux ignores broadcast pings by default, and routers don't forward directed broadcasts (RFC 2644), as the lab showed. - IPv4 multicast maps the low 23 bits of the group onto
01:00:5e:00:00:00, so 32 groups share each Ethernet address. IPv6 maps the low 32 bits onto33:33:00:00:00:00. - Processes join groups per interface.
ip maddrshows the IP groups and their Ethernet addresses, including all-nodes and solicited-node groups every IPv6 host joins. - Sending needs no membership. Multicast TTL defaults to 1,
IP_MULTICAST_IFpicks the interface, andIP_MULTICAST_LOOP(default on) delivers a copy locally. - Frames are filtered by the card, the driver, IP and the transport layer. In the lab, the colliding group's frames reached
h3but were discarded at the IP layer.
Practice questions
1. A host has address 10.20.30.40/22. What is its subnet-directed broadcast address?
Answer
A /22 has 10 host bits. 30 in binary is 00011110, and the network part keeps its top 6 bits, 000111, so the network is 10.20.28.0/22. Setting the 10 host bits to 1 gives 10.20.31.255.
2. What Ethernet address carries traffic for 224.128.64.32, and which other group in 224.0.0.0/24 shares it?
Answer
The low 23 bits of 224.128.64.32 are 0.64.32 (the top bit of 128 is dropped), so the address is 01:00:5e:00:40:20. 224.0.64.32 also maps there. No group in 224.0.0.0/24 does, because those all map to 01:00:5e:00:00:xx. But 224.128.0.x groups do share addresses with them, which is why groups like 224.128.0.1 are best avoided.
3. What Ethernet address carries the solicited-node group for 2001:db8::abcd:1234?
Answer
The solicited-node group is ff02::1:ffcd:1234 (the low 24 bits cd:1234 appended to ff02::1:ff00:0/104). Its low 32 bits are ffcd1234, so the Ethernet address is 33:33:ff:cd:12:34.
4. A program sends a UDP datagram to 192.0.2.255 and gets EACCES. The same program can send to 192.0.2.12 without trouble. What's missing?
Answer
The SO_BROADCAST socket option. The kernel refuses sends to a broadcast address from a socket that hasn't set it, as the lab showed. Set it with setsockopt(SOL_SOCKET, SO_BROADCAST, 1).
5. A video stream is multicast to 239.10.0.1 on a LAN, and receivers on another subnet behind a router get nothing. List two likely causes.
Answer
The sender's multicast TTL is still the default of 1, so the router can't forward the packets, and the router may not be running multicast routing (such as PIM) or may have no receivers registered through IGMP on the other subnet. Also check that 239.10.0.1 isn't blocked at an administrative scope boundary on that router.
6. In the lab, h3 joined 239.129.2.3. Which layers did the datagrams for 239.1.2.3 pass on h3, and where were they dropped?
Answer
They passed the bridge (which flooded them, with snooping off) and h3's interface and link layer, because their Ethernet address 01:00:5e:01:02:03 matched the one h3 joined for 239.129.2.3. They were dropped at the IP layer, which compared the full destination 239.1.2.3 against h3's memberships and found none. h3's program received 0 datagrams.
Previous: IPv6 Neighbor Discovery: Router and Neighbor Messages, NUD and ND Options
Next: IGMP and MLD: Joining Multicast Groups, Queriers and Snooping

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.