Broadcast

What is broadcast

Broadcast is sent to everybody that wants to receive it, but he MUST be on the same physical network, because by default routers/gateways do not forward BROADCAST messages.
Another limitation of broadcast is the MTU of interface, by default a broadcast packet cannot exceed the max MTU size of an interface (for ethernet is 1460 (1500 - 20 (IP Header) - 20 (UDP Header)).

Broadcast address could be 255.255.255.255 or the network broadcast address. (old broadcast address was 0.0.0.0 now this is known as the network address)
For example network 192.168.20.0 with netmask 255.255.255.0 has a broadcast address of 192.168.20.255 (192.168.20.0 might work for backward compatibility)

Do you know your IP address, do you have a netmask, and you want to compute your network/broadcast address ?
Your network address is: < IP Address > & Netmask
Your Broadcast address is: < IP Address > | ( ˜ Netmask )

!!! This table might be wrong and is for sure not complete !!!

NetworkNetmask Broadcast address
10.0.0.0FF000000 (255.0.0.0) (8 bit) 10.255.255.255
10.0.0.0FF800000 (255.128.0.0)(9 bit) 10.127.255.255
10.0.0.0FFD00000 (255.192.0.0)(10 bit) 10.63.255.255
10.0.0.0FFE0000 (255.224.0.0)(11 bit) 10.31.255.255
10.0.0.0FFF00000 (255.240.0.0)(12 bit) 10.15.255.255
10.0.0.0FFF80000 (255.248.0.0)(13 bit) 10.7.255.255
10.0.0.0FFFD0000 (255.252.0.0)(14 bit) 10.3.255.255
10.0.0.0FFFE0000 (255.254.0.0)(15 bit) 10.1.255.255
10.0.0.0FFFF0000 (255.255.0.0)(16 bit) 10.0.255.255
10.0.0.0FFFF8000 (255.255.128.0)(17 bit) 10.0.127.255
10.0.0.0FFFFD000 (255.255.192.0)(18 bit) 10.0.63.255
10.0.0.0FFFFE000 (255.255.224.0)(19 bit) 10.0.31.255
10.0.0.0FFFFF000 (255.255.240.0)(20 bit) 10.0.15.255
10.0.0.0FFFFF800 (255.255.248.0)(21 bit) 10.0.7.255
10.0.0.0FFFFFD00 (255.255.252.0)(22 bit) 10.0.3.255
10.0.0.0FFFFFE00 (255.255.254.0)(23 bit) 10.0.1.255
10.0.0.0FFFFFF00 (255.255.255.0)(24 bit) 10.0.0.255
10.0.0.0FFFFFF80 (255.255.255.128)(25 bit) 10.0.0.127
10.0.0.0FFFFFFD0 (255.255.255.192)(26 bit) 10.0.0.63
10.0.0.0FFFFFFE0 (255.255.255.224)(27 bit) 10.0.0.31
10.0.0.0FFFFFFF0 (255.255.255.240)(28 bit) 10.0.0.15
10.0.0.0FFFFFFF8 (255.255.255.248)(29 bit) 10.0.0.7
10.0.0.0FFFFFFFD (255.255.255.252)(30 bit) 10.0.0.3

Sample code

This is a sample broadcast server without error handling
----------- cut here ------------------

----------- cut here ------------------
This is a sample broadcast client without error handling
----------- cut here ------------------

----------- cut here ------------------