Socket programming - broadcast with net mask class B

541 views Asked by At

I have a problem with broadcasting data when I'm using class B of netmask. For example I have 3 PC's with these configs:

PC1: IP Address: 192.168.1.10 Netmask: 255.255.0.0

PC2: IP Address: 192.168.1.11 Netmask: 255.255.0.0

PC3: IP Address: 192.168.2.5 Netmask: 255.255.0.0

I want to send a broadcast packet from PC1 to PC's in range 1 only (PC2 in this example). But as I found I should use 192.168.255.255 as broadcast address that sends the packet to PC2 and PC3 together. I can't use something like 192.168.1.255 to send the packet to PC2 only. Is there any way to send packet to range 1 only?

Thanks in advance

1

There are 1 answers

2
konqi On

Network wise all the machines are in the same subnet (range). Thus the broadcast will always target all nodes on this subnet. Depending on what you are doing i suggest:

  • Use multicast
  • Teach your receiving nodes to ignore packets that are not intended for them