You can use two commands:
arp to get the info that you need.
ping allows you to broadcast to your network and any device that on the network and capable of responding will reply.
Let's assume your network is 192.168.1.0. Broadcast your ping by using the broadcast address 192.168.1.255
$ ping 192.168.1.255
This will go on forever, so either ControlC or use the
-t option to set a timeout. For example, for 20 seconds of pining...
$ ping -t 20 192.168.1.255
You will get a bunch of responses; some of which will be duplicate. This will continue for 20 seconds then stop.
arp to find the names:
$ arp -a
allans-imac.home (192.168.1.12) at a8:20:66:40:5b:10 on en0 ifscope permanent [ethernet]
grace-pc.home (192.168.1.18) at 0:34:f6:5:f7:29 on en0 ifscope [ethernet]
grace-iphone.home (192.168.1.150) at b8:63:3a:14:3e:f7 on en0 ifscope [ethernet]
nas.home (192.168.1.23) at 0:12:43:20:aa:3d on en0 ifscope [ethernet]
That's a truncated sample of the output from my network (names, MACs and IPs randomized for security). As you can see, it includes the hostnames and MACs of devices I have on my network.
Sleeping devices (like my HP printer and my MacBook Pro) didn't respond and aren't in the arp table. Then again, they don't show up in Finder, either.
With the application of
awk, you should be able to extract what you need.