I am using following code to retrieve MAC address for an IP address.
public string GetMACAddressFromARP(string ipAddress)
{
IPAddress ipAdd;
try
{
ipAdd = IPAddress.Parse(ipAddress);
}
catch (Exception ex)
{
return null;
}
byte[] macAddr = new byte[6];
uint macAddrLen = (uint)macAddr.Length;
if (SendARP((int)ipAdd.Address, 0, macAddr,
ref macAddrLen) != 0)
return null;
StringBuilder macAddressString = new StringBuilder();
for (int i = 0; i < macAddr.Length; i++)
{
if (macAddressString.Length > 0)
macAddressString.Append(":");
macAddressString.AppendFormat("{0:x2}", macAddr[i]);
}
return macAddressString.ToString();
}
but, I want to get complete MAC address which usually we can see by using arp -a command.
Any idea?