The difference between layer-2 and layer-3 broadcasts? Please explain with an example

broadcastlayer2layer3

What is the difference between broadcast addresses ff.ff.ff.ff.ff.ff (Layer 2) and 255.255.255.255 (Layer 3)?

Best Answer

You need to understand the difference between layer-2 and layer-3 for an answer to have any real meaning for you, and I suspect you don't.

A layer-2 network is a LAN, and all hosts on it are peers. A LAN is bounded by layer-3. The layer-2 frames are delivered to the host with the destination MAC address in the frame. I one host wants to send something to all the hosts on the LAN, it will address the frame(s) with the ffff:ffff:ffff MAC address. Each host is obligated to strip the frame and inspect the packet to see if the packet is meant for it.

A layer-3 network is usually, but not always, on a layer-2 LAN. Router use layer-3 to send packets between LANs. A host on a LAN cannot send a layer-3 packet without first encapsulating it in a layer-2 frame, and that requires layer-2 MAC addresses.

You need ARP (or an equivalent, see IPv6) to resolve the layer-3 address to a layer-2 address. When a host sends a packet to another host on the same LAN, it first looks in its ARP cache to see if it has a layer-2 address for the layer-3 address. If it does not, it sends an ARP request. The ARP request is broadcast at layer-2 to all hosts on the LAN, looking for the host which owns the layer-3 address. The host owning that address will respond with an ARP reply, giving the requesting host its MAC address. In this case, a layer-2 broadcast gets the attention of all the hosts on the LAN, but only the host with the layer-3 address responds.

A layer-3 broadcast packet is meant for all hosts on the layer-3 network. When a host needs to resolve the layer-3 broadcast, it uses the layer-2 broadcast address for the frame.

There are two types of layer-3 broadcast: the limited broadcast, 255.255.255.255, as you noted, and the network broadcast, the highest IP address in a network. The limited broadcast can never cross a router, while a network broadcast may cross a router if the router has been configured that way, although that is considered a security risk, and routers do not allow this, by default, but that was not always the case.