I've created a server that listens for broadcast messages from a client that sends them. My local address looks like 192.168.88.***
. I tested two cases: clients that send broadcast messages to 192.168.88.255
and 255.255.255.255
, but there wasn't any difference.
So, what is the difference between them, and when to use each of them?
CodePudding user response:
255.255.255.255
broadcasts to all subnets. Though most routers don't broadcast across subnets by default, you usually need to enable that capability.
192.168.88.255
broadcasts only to the 192.168.88.xxx
subnet specifically.
CodePudding user response:
IP addresses are split into a network prefix (the top bits) and host (the bottom bits). Assuming 192.168.88.***
is 192.168.88.0/24
(a network mask of 255.255.255.0
), the low order 8 bits can hold 255 network addresses from 192.168.88.0
to 192.168.88.254
, and the local broadcast address 192.168.88.255
.
But you need to have specific knowledge about the subnet to write this broadcast address. For instance, 192.168.88/23
would have a broadcast address of 192.168.89.255
.
255.255.255.255
is just an alias to the local broadcast address just as 0.0.0.0
is an alias to the local network. They can both be used generically without any special configuration. That's the difference. You really wouldn't bother using 192.168.88.255
because you'd also need a facility to configure that value. Why bother?