I have a pcPC (in the successive diagrams pc1
) equipped with a network interface that can be directly connected to another pcPC or to a managed switch.
I want to be able to get the MAC address of the closest device ofin the network.
Just to be more precise:
Situation #1
+-----+ +----------------+ +---------------+
| pc1 |-------| managed switch |-------| other devices |
+-----+ +----------------+ +---------------+
In this case, I want to get the macMAC address of the managed switch.
Situation #2
+-----+ +-----+
| pc1 |-------| pc2 |
+-----+ +-----+
In this case, I want to get the mac address of pc2.
What can I use to retrieve the MAC address of the first network device?
Update
As far as I know, I cannot use ARP, because in PC1's ARP table, I'll see all the MAC addresses related to the IP addresses on the ethernet segment. But, but I have no way in general to know the IP address of the device at the other end of the cable (this is painful in the case of the switch). This is why I am looking for something like ping at datalinkthe data link layer with a TTL of 1.