2

My two hosts reside on the same Ethernet segment. Host A is 10.1.0.1/16, host B is 10.1.0.2/16. A sends directed UDP broadcasts to 10.1.255.255 and a UDP listening socket bound to INADDR_ANY on B receives them.

After I'm changing IP configuration on A to 10.0.0.1/16 so that it belongs to a different IP subnet and starts broadcasting to 10.0.255.255, that same socket on B still receives this broadcast.

If I restart the listening application on B, these broadcasts to a "wrong" subnet are not received by the socket any more.

Question: why the networking stack of B does not drop the packet, which is neither a unicast to B nor a broadcast to subnet of B, until socket shutdown?

I know that RFC1122 says:

Hosts SHOULD use the Limited Broadcast address to broadcast to a connected network.

I understand that the application on A sending directed broadcasts with the intention to broadcast to own subnet does not follow the "should" clause. But my question is why B does not drop them as long as UDP socket is alive.

I observed this behavior on Linux kernels 4.4 and 3.13.

  • 2
    When you say "B receives this broadcast", what program is actually showing that – packet capture (tcpdump) or a regular UDP socket? – user1686 Aug 13 '17 at 11:10
  • @grawity UDP socket. (Naturally, tcpdump as well, also when the interface is not in promiscuous mode.) – Konstantin Shemyak Aug 13 '17 at 13:06
  • Just because host B sees the traffic, which is normal, doesn't mean that it acts on it. Depending on your monitoring method, you may be misinterpreting your data. If you are using a network sniffing tool the Ethernet adapter is probably in promiscuous mode, so ofcourse it is going to see all traffic on the network rather it is addressed to it or not. – Appleoddity Aug 13 '17 at 13:24
  • It also matters if these devices are connected via a switch or hub. – Appleoddity Aug 13 '17 at 13:25
  • 2
    @Appleoddity: At Ethernet layer it's perfectly normal regardless (since all broadcast types share the same MAC address); I suppose the OP is asking why it's not dropped once it reaches IP layer. – user1686 Aug 13 '17 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.