John Saunders said:
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.
Oh dear. I think we both understand that MAC addresses and IP addresses can
change. Two examples, changing the NIC on my server changes the MAC but not
the IP. Changing the IP associated a NIC does not change the MAC. ARP is
used to join the two together, it makes is possible for me to change a NIC
and keep the same IP safe in the knowledge that traffic destined to the
server will reach it sucessfully.
We cannot assume anything especially m=m. We can however find a MAC
associated with an IP and be sure it is correct. We cannot however be sure
how long that information will be valid. This is why the ARP cache, at
least on a 2000 box, has a 5 second timeout on its entries. This timeout is
a lot shorter than that of many networking applications so a change in a MAC
address is not noticed by the application.
How an application uses this information is irrelevant. If a developer does
not fully understand how the networking layer works and their app fails,
tough luck.
This does not however invalidate the argument that MAC and IP addresses are
related. The conversion between the two is necessary component of an
IP/Ethernet network hence the necessity for ARP. On their own IP's and MACs
mean nothing, ARP is the relationship between the two.
The layers are of course seperate, we could swap layer 2 for a system that
does not use MACs and IP could still run over it. However not matter what
system is employed the movement between layers is still required. Hence a
relationship between the layers. In OO design this would be known as an
Interface. No one cares about what goes on behind the Interface just that
the Interface is known.
So a relationship between IP and MAC exists because of the standard
Interface between Layer 3 and Layer 2. You can change Layer 2 to whatever
you like but still a relationship will exist because of the Interface. In
our instance ARP is the Interface. ARP for example is available in a number
of Layer 2 systems Ethernet and Token Ring networks make use of it. So
switching between the two is possible (in practice this would be a darn
sight more than ticking a box
).
I hope this makes things clearer. A relationship must exist between Layer 3
and Layer 2. In our case it is ARP. If a relationship exists between Layer
3 and 2 then by implication a relationship between IP and MAC must also
exist.
Cheers,
Gareth.