1

I am trying to use python to broadcast to my local network, and I cannot find a way to get the subnet mask. I have been suggested to use the default Class C network subnet mask 255.255.255.0, and use the resulting broadcast address calculation unless a user provides subnet mask details, which I want to absolutely avoid for the end user.

If a user has a subdivided Class C network, will the the broadcast calculated in this way reach the whole local network, or will it only reach the highest bit division of the local network? My understanding is shaky.

8
  • 3
    Network classes died in 1993 with the introduction of CIDR. Please leave them dead and buried. Programming question are explicitly off-topic here, see the help center.
    – Zac67
    Commented Mar 24, 2020 at 15:06
  • 2
    Network classes are dead (please let them rest in peace), killed in 1993 (two years before the commercial Internet!) by RFCs 1517, 1518, and 1519, which defined CIDR (Classless Inter-Domain Routing). We have not used network classes in this century.
    – Ron Maupin
    Commented Mar 24, 2020 at 15:07
  • This isn't a programming question; I am not asking how to program something. I am asking for help with my understanding of networks. Sorry for my lack of understanding. I might be asking an XY question here, because I don't have a strong understanding of networks. Is assuming a 255.255.255.0 subnet mask a good idea for most residential networks? Commented Mar 24, 2020 at 15:12
  • 3
    Assuming any network mask for any network is a fool's game.
    – Ron Maupin
    Commented Mar 24, 2020 at 15:18
  • 1
    "I don't have a strong understanding of networks." Unless your application is simply a test toy, you should have a complete understanding of networking before creating network applications, that is how we have so many network vulnerabilities and networks get hacked: too many programmers with a weak understanding of network protocols are releasing network applications full of vulnerabilities.
    – Ron Maupin
    Commented Mar 24, 2020 at 15:22

1 Answer 1

4

First, if you are using broadcast and network classes then you are still stuck in the last century. Network classes are dead.

Broadcasts interrupt every host on the LAN (routers, printers, all PCs, etc.), including those not interested in the broadcast. Many companies now will reject applications that use broadcast because it interrupts every host, and it can be a security problem. In fact, IPv6 has eliminated broadcast, and if your application relies on broadcast, you cannot simply port it to IPv6. Also, broadcasts will not cross a router.

The modern way to do things is to use multicast. The hosts interested will subscribe to a particular multicast group (preferably one from the Organization-Local scope of 239.0.0.0/8). The application sending will then send to the multicast group as the destination address, and the hosts subscribed to the multicast group will get and process the packets, but other host will not be interrupted. Multicast routing can be enabled, and, unlike broadcast packets, multicast packets can be routed to other networks.


If you insist on broadcast, then simply use the limited broadcast address of 255.255.255.255, and that will send a broadcast to every host on the LAN. Remember that broadcasts are stopped at a router, so any hosts on a different network will need a host on that network to send a broadcast.

1
  • Wow, that is a lot of new information that I had never heard of. Thank you, I will start looking into this immediately. You might have broken my mental block! I again apologize if I seem like an idiot; I have been somewhat forced into doing networking despite having no prior experience and I feel pretty bad asking stupid questions. Commented Mar 24, 2020 at 15:22

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