Search code examples
network-programmingroutesbroadcast

Can we use directed broadcast as limited broadcast? See scenario below


I am learning Computer Networks and was reading about limited and directed broadcast.

If a host with IP 200.100.1.1 wants to send packets to all host in the same network, then does the procedures A and B, to achieve our goal, differs?

Procedure A SRC- 200.100.1.1 DEST- 200.100.1.255

Procedure B SRC- 200.100.1.1 DEST- 255.255.255.255

So, can we use Procedure A to do the task required as the directed broadcast(destination) is aiming at its own network? Or Procedure A is incorrect and Procedure B is the right way to go.


Solution

  • IP directed broadcast packets have a destination IP address that is a valid broadcast address for the subnet that is the target of the directed broadcast (the target subnet). The intent of an IP directed broadcast is to flood the target subnet with the broadcast packets without broadcasting to the entire network. reference; emphasis added

    Assume the following:

    • We have an IP address of 200.100.1.1 (11001000.01100100.00000001 .00000001)
    • The netmask is /24 (or 255.255.255.0) (11111111.11111111.11111111 .00000000)

    Then:

    The network address is a bitwise AND between these two:

    11001000.01100100.00000001 .00000001
    11111111.11111111.11111111 .00000000
    =
    11001000.01100100.00000001 .00000000
    200      100      1         0
    

    So we know the network is 200.100.1.0.

    To determine the broadcast address, we invert the subnet mask and OR it with the network address.

    Network:          11001000.01100100.00000001 .00000000
    Inverted Netmask: 00000000.00000000.00000000 .11111111
                      11001000.01100100.00000001 .11111111
                    =
                      200      100      1         255
    

    The broadcast for 200.100.1.0/24 will be on 200.100.1.255

    We also know that this network will have 254 possible hosts in it (or 253 given a gateway address; and the assumption that .0 is not addressable so 200.100.1.1 -> 200.100.1.254).