So, if you have an address like, for example: 192.168.1.1 to know the broadcast ip is easy; the last triplet is always 255: 192.168.1.255
Actually, that is not true: the broadcast address is the last address in your netblock - which may or may not be 255. It is only .255 if you have the entire class C routed and made available to you
The key to determining your broadcast address is your netmask
If your IP is 192.168.1.12 and the netmask is 255.255.255.0 then yes, the broadcast address is 192.168.1.255.
However, your provider / administrator can also assign (much) smaller blocks of IP's to you -- if you do not have your own class C (256 addresses) but get a smaller block of addresses assigned (4, 8, 16, 32, 64 or 128)
You lose 2 usable IP addresses in this block:
- The last one is the broadcast IP that sends to all computers in your own netblock
- One arbitrary address (typically the first, or 2nd-to-last, but could be any depending on your router setup) is the gateway address that routes to your upstream network (often the internet)
I don't remember the exact math, so don't quote me on this, but it goes something like this:
If your IP address is 192.168.1.4, and your netmask is 255.255.255.248, it means you have a block of 8 IP's in your 'network'.
248 in binary = 1111000
Which leaves 8 possible addresses in this subnet. Since your own address ends in .4, the block of 8 it is in encompasses the IP's .0 through .7. That means that the broadcast IP would actually be 192.168.1.7, and not .255
If your own IP had been .12 it means that your range had gone from .8 to .15, and .15 would be the broadcast -- etc.
Netmasks *do* have a purpose, and you can't just count on always being able to broadcast to .255. The .255 IP may be in someone else's network entirely depending on your network layout, and be completely unreachable to you.
These broken up blocks are typical for people on a T1 (etc) frame connection that don't need / pay for an entire class C subnet of addresses, or high-end framed DSL connections where your ISP may give you get a small routable block of IP's.
Most internal company networks and such do lump the entire class C together, but while it is common, you still shouldn't *count* on it.