3

Consider a host on 10.0.0.0/24 sending a packet to 10.0.0.255 and 10.255.255.255.

In the first case all hosts on his subnet should recieve the packets but would the entire network receive the packet in the latter case? Do routers forward such datagrams? If not, what are the exceptions to the rule?

1
  • NB: It doesn't have to be a datagram, but most time it will be one.
    – bot47
    May 9, 2019 at 7:31

3 Answers 3

7

IPv4 uses limited broadcasts (to 255.255.255.255) and directed broadcasts (to the subnet address with all host bits set to 1, e.g. 10.0.0.255 for the 10.0.0.0/24 subnet).

Limited broadcasts are generally not routable and won't be forwarded.

Directed broadcasts are routable in principle but won't be forwarded by default. However, many routers can be configured to forward them. Often, directed broadcast forwarding is limited by the admin to special cases, e.g. for wake-on-LAN (by source IP, transport protocol & port, destination subnet, ...).

Consider a host on 10.0.0.0/24 sending a packet to 10.0.0.255 and 10.255.255.255.

10.0.0.255 is the host subnet's directed broadcast address and gets sent as a broadcast.

10.255.255.255 is outside the host's subnet, so it is send to the according gateway. Usually, it is actually forwarded until the last hop (e.g. 10.255.255.1/24) discovers it to be a directed broadcast and drops it.

Any intermediate hop can't actually decide whether it's a broadcast or not (the destination may not even support broadcasting) unless it's specifically configured that way.

An intermediate router could decide to drop the apparent broadcast if it has a specific route to the destination subnet.

2
  • So I understand that 10.255.255.255 classifies as a directed broadcast and default behavior is to not forward such packets right?
    – Weezy
    May 9, 2019 at 8:16
  • 2
    @Weezy 10.255.255.255 may be a directed broadcast. That depends on the destination subnet. E.g. 10.0.15.255 is a directed broadcast for the 10.0.0.0/20 subnet but it could also be a normal host address in the 10.0.0.0/19 subnet. 10.255.255.255 wouldn't be a broadcast address in the 10.0.0.0/7 or in the 10.255.255.254/31 subnets.
    – Zac67
    May 9, 2019 at 8:22
3

First of all: Routers won't forward broadcast traffic.

From this point I'm talking about IPv4 over Ethernet, because different technologies have different ideas if something like broadcast exists or not. In this case, this also applies to WLAN, so it might be applicable to your scenario.

At first we should distinguish between two kinds of broadcast addresses: the broadcast address 255.255.255.255, and the network broadcast address which is 10.0.0.255 for 10.0.0.0/24. 10.255.255.255 is no broadcast address for 10.0.0.0/24. It doesn't even belong to the network. Actually, you even can't be sure it really is a broadcast address (It often is, though). When a client on a different network sends a packet to the address 10.0.0.255, it has no way of knowing that this address is a broadcast address. Actually, only the routers directly connected to 10.0.0.0/24 know it's the network broadcast address. Generally speaking, routers will unicast-forward incoming packets which have a network broadcast address as destination, unless they are directly connected to that network/subnet and therefore know that the destination address is a broadcast address. This is because you would be easily able to saturate all Ethernet links belonging to the destination network as switches will broadcast the packet (frame) to all ports belonging to that (layer 2) network.

Now imagine the case of 255.255.255.255. What would happen if it was happily routed? It would end up in any network that is reachable through routing. So this is an obvious exception.

The rule for the exception is: Only forward packets, that have the destination Ethernet address set to the address of the incoming interface on the router. Don't forward packets of which you know they will be a broadcast on the destination network.

A host on 10.0.0.0/24 knows that 10.0.0.255/24 will usually be the network broadcast. It will set the destination Ethernet address to the address defined as broadcast, which is all FF. This certainly isn't the address the router cares about for forwarding.

There are some mechanisms for forwarding selected broadcasts between selected networks, e.g. for spreading UPnP through collision domain borders. Those is often proxied, though.

3
  • Generally speaking routers will not forward incoming packets which have the network broadcast address as destination. You may want to add some precision or context to that statement. It is only true for routers that have an interface into that subnet and thus know that what the network broadcast address of that subnet happens to be. Any other router NOT having an interface into that subnet will just treat that packet as unicast and forward it according to the forwarding information base (a.k.a. "routing table"). May 9, 2019 at 7:41
  • I had this included in a previous draft of the answer. Adjusted.
    – bot47
    May 9, 2019 at 7:50
  • Sorry to nitpick again; you might want to check again, there's a double negation in there: as they won't know should probably be something like as only they know. Even better, the statement should not be negated in the first part: Generally, routers _will_ unicast-forward incoming packets which have a network broadcast address as destination, _unless_ they are directly connected to that network/subnet and therefore know that the destination address is a broadcast address. May 9, 2019 at 8:13
0

You have to have good understanding about Network IP vs Broadcast IP.

Network Address is first Ip address of the network and it will not be random ip address and it will help to identify Network segment. All address in same network address part will be in same network segment. As per your example 10.0.0.0/24 is a network address and network address part is 10.0.0. last 0(zero) represent number of host in network segment.

Broadcast address is last address and it use to address all nodes in network.

In your case 10.0.0.255 is a broadcast address. 10.255.255.255 is not related to your network because your subnet is /24. /24 means, you are not allowed to change 24 bit in your address when it is in binary format.

Therefore 10.255.255.255 is not related to your network. You wont receive any traffic from this ip adress.

1
  • You misunderstood my question. I'm well aware that 10.255.255.255 is not a part of the local network.
    – Weezy
    May 9, 2019 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.