I am studying about arp, and I want to know more about how it works. Right now, I am using Wireshark and this function that returns the mac address from a given ip address ipAddress
:
IPAddress IP = IPAddress.Parse(ipAddress);
byte[] macAddr = new byte[6];
uint macAddrLen = (uint)6;
// Destination, Source, pMacAddr, PhyAddrLen
if (SendARP((int)IP.Address, 0, macAddr, ref macAddrLen) != 0)
{
Console.WriteLine("ARP RESPONSE FAILED");
}
string[] str = new string[(int)macAddrLen];
for (int i = 0; i < macAddrLen; i++)
{
str[i] = macAddr[i].ToString("x2");
}
return string.Join(":", str).ToUpper();
I set ipAddress
to 192.168.1.68
that is an active computer in my network. I successfully capture my Arp Request in Wireshark. Here's what it look like:From the picture above, IntelCor
is my PC. The line selected in blue is what my program sent. The next line after blue is the mac address I am getting. My question is why myself respond and answer what mac address does 192.168.1.68
owns (I can tell from the destination section). While other Arp Request from the router. like this one: (192.168.1.76
is me)Was answered not by the router, but by myself! Thank you.