[NTLUG:Discuss] localhost vs "real" IP address

Dennis Rice dennis at dearroz.com
Tue Jan 13 07:26:40 CST 2009


Ken wrote:

Chris Cox wrote:

> > George Lass wrote:
>   
>> >> Sorry, I got that backwards.  It should have read something like:
>> >>
>> >> ... how much more overhead in using the IP address for eth0 as compared to 127.0.0.1...
>>     
> > 
> >  :)   Well.. that obviously varies.  But I'm not sure how quantifiable it is... anyone?
>   

It really should not vary.  Both translate to an internal interface.

traceroute to 192.168.1.5 (192.168.1.5), 30 hops max, 40 byte packets
 1  neptune.local (192.168.1.5)  0.071 ms  0.032 ms  0.031 ms

and

traceroute to neptune (127.0.0.1), 30 hops max, 40 byte packets
 1  neptune.loafman.com (127.0.0.1)  0.072 ms  0.031 ms  0.031 ms

Both come up with 0.031ms on my machine.  One is going to an internal
'lo' interface, the other to 'eth0'.  I would imagine the difference
could be measured with enough repetition and measurement.  I doubt it
would amount to even a 0.1% difference.

...Ken


Both must be identical.  The only difference between the two segments 
coming out of the Transport Layer (Layer 4) is the destination IP 
address, namely 127.0.0.1 or the local interface address.  Both packets 
terminate at the ICMP function, which resides at the Network Layer 
(Layer 3).  The ICMP function is responsible for responding back or 
looping back the message, plus other management functions.  ICMP does 
not care what the origin is, or whether the packet came from the Data 
Link Layer (Layer 2) or the Transport Layer - it just loops it back.

Many believe that when pinging one's local address that the loopback is 
in the Data Link Layer or Physical Layer -- that is totally incorrect.  
It would be nice is if one could ping a MAC address, then one could see 
a response from the Data Link Layer, but no mechanism exists for a MAC 
address to respond.




More information about the Discuss mailing list