Not exactly. Some machines will let themselves be seen, and others may not.
But here's what you can do as a first effort:
1. Open Terminal
2. Type
ifconfig en0 (for Ethernet) or
ifconfig en1 (for Airport)
The third line of the output reads
inet 192.168.x.x netmask 0xffffff00
broadcast 192.168.1.255
or something similar. The part in bold (broadcast 192.168.1.255) is called the
broadcast address. That's the address to send things to if you want
everyone on the network to receive the packet.
3. Ping the broadcast address.
Pinging sends a packet that requests, "please reply to let me know if you're there." Machines don't have to reply if they don't want to.
Type
ping 192.168.1.255 (or whatever your broadcast address is)
Press control-C to stop the pinging after a bit.
You'll get something like the following:
Code:
64 bytes from xxx.xxx.245.95: icmp_seq=0 ttl=64 time=0.376 ms
64 bytes from xxx.xxx.245.1: icmp_seq=0 ttl=255 time=51.563 ms (DUP!)
64 bytes from xxx.xxx.245.95: icmp_seq=1 ttl=64 time=0.36 ms
64 bytes from xxx.xxx.245.70: icmp_seq=1 ttl=64 time=1.969 ms (DUP!)
64 bytes from xxx.xxx.245.112: icmp_seq=1 ttl=64 time=6.158 ms (DUP!)
64 bytes from xxx.xxx.245.95: icmp_seq=2 ttl=64 time=0.365 ms
64 bytes from xxx.xxx.245.70: icmp_seq=2 ttl=64 time=1.974 ms (DUP!)
64 bytes from xxx.xxx.245.112: icmp_seq=2 ttl=64 time=6.164 ms (DUP!)
Looking at the replies, you can get a sense of how many unique machines are out there. But remember this only finds machines that are willing to be found.
Here's a command that will do the whole thing at once:
ping -c 10 $(ifconfig en0 | awk '/broadcast/ {print $6}') | awk '/bytes from/ {print $4}' | sed -e 's/://' | sort -u -n -t. +3 +2 +1 +0
Or, if you just want the count:
ping -c 10 $(ifconfig en0 | awk '/broadcast/ {print $6}') | awk '/bytes from/ {print $4}' | sed -e 's/://' | sort -u -n -t. +3 +2 +1 +0 | wc -l
One other thing you can do is, after you've pinged the broadcast address and asked machines to tell you that they're there, consult your
ARP table, which is the table your machine uses to keep track of how to reach machines on the network.
Type
arp -a to see the list of machines your Mac presently knows about on the network.