Re: get MAC Address from IP
From: John Saunders (johnwsaundersiii)
Date: 11/11/04
- Next message: Nick Malik: "Re: How to send data from an ASP form to a visual basic form?"
- Previous message: MrMike: "RE: DropDownList.SelectedValue not working"
- In reply to: Gareth Watson: "Re: get MAC Address from IP"
- Next in thread: Gareth Watson: "Re: get MAC Address from IP"
- Reply: Gareth Watson: "Re: get MAC Address from IP"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Nov 2004 09:46:05 -0500
"Gareth Watson" <gw-ext@abs-ltd.com> wrote in message
news:eOPwys0xEHA.4028@TK2MSFTNGP15.phx.gbl...
>
> "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
> news:%238LW%23gUxEHA.3976@TK2MSFTNGP09.phx.gbl...
>> "YAN" <YAN@discussions.microsoft.com> wrote in message
>> news:9586DF60-A3BF-4C58-B94B-B59B7535F775@microsoft.com...
>>> Hi,
>>> I want to get the mac address from a machine, which i have the IP
>>> address of
>>> that machine, how can i do that?
>>
>> You can't. There's no relationship between the two.
>>
>> And besides, a machine may have multiple IP addresses and multiple MAC
>> addresses.
>>
>> John Saunders
>>
>>
>
> No relationship between MAC address and IP address? Did I read that
> right! Of course there's a relationship how else would you move from layer
> 3 (IP) to layer 2 (MAC).
>
> In fact there is a whole protocol for this conversion. Its called ARP.
>
> Basically ARP broadcasts on the segment asking all the devices to repond
> with their MAC if they own the stated IP. This is a simplification of the
> process but it is basically what happens.
>
> I have no idea how to do this in .Net but saying there is no relationship
> is clearly not the case.
Do this thought experiment.
1) ARP for the MAC address associated with a given IP address (*). Call the
result "m".
2) Now, once again ARP for the MAC address, calling the result "m'".
Question: under what circumstances will m = m'?
If your code lives in a world where those circumstances will always apply,
then for your code, there is a relationship between IP address and MAC
address. But in general, m may not be the same as m', which means that, in
general, there is no useful relationship between IP address and MAC address.
Also, IN GENERAL, it's a bad idea for code which is not running the network
to screw with network "stuff" like IP addresses (also routes, etc). If the
code isn't running the network, then it has no idea when the network will
decide to pull the assumptions out from under its feet.
As an example, consider code that treats the IP address as the identity of a
machine. That code will be disappointed when the machine loses its DHCP
lease and starts using a different IP address. Strangely, DHCP didn't bother
telling the code that the network had decided to change implementation
specifics. Note that the network layer won't be troubled by this change, but
this hypothetical code _will_ be.
This rant is probably just a sign that I'm getting old, but you might want
to consider the different layers of a network like different classes in an
OO design. Class "EndApplication" shouldn't be using nor depending on
private members of class "Network". In fact, there's some reason to doubt
that class "EndApplication" should even know of the existance of class
"Network".
John Saunders
(*) I presume you realize that ARP is not a routed protocol? You can't use
it at all for a machine not on the same logical network segment. Even on the
same logical segment, you may not be able to use it on all hosts, as
something at the Network/Datalink layer may block ARP traffic.
- Next message: Nick Malik: "Re: How to send data from an ASP form to a visual basic form?"
- Previous message: MrMike: "RE: DropDownList.SelectedValue not working"
- In reply to: Gareth Watson: "Re: get MAC Address from IP"
- Next in thread: Gareth Watson: "Re: get MAC Address from IP"
- Reply: Gareth Watson: "Re: get MAC Address from IP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|