There is no fail safe method to detect all devices attached to a network. Still, you can use the IP address and netmask of the NIC to find out what the range of possible IP addresses is for the network that NIC is connected to. Then for each individual NIC in that range you can use ARP to find out if there is an active NIC on the network.

You will of course not receive any answer from devices that are currently off (but still may have a fixed IP address asigned to them).

Please note - one NIC may have multiple ranges of addresses for different subnets it is connected to.

In any case, this is not something I have ever needed to do, but this is probably how I would go about it..