I suggest to make the discovery aware of of the net and broadcast addresses what using the subnet.
e.g. in network 192.168.1.0/24 the addresses 0 and 255 shoud be obmitted from the scan
It makes no sense to scan them as they will never be valid IP with the selected mask,
And it will avoid that nodes gets discovered with a invalid IP