Today's quiz question

Garrett Goebel garrett at scriptpro.com
Wed May 4 16:00:54 CDT 2005


Gerald Combs wrote:
> 
> What happens when you run
> 
>     ping 0x7f.1
> 
> and why?

I came in late and only guessed part of it myself. Here's the short summary
of what's going on for those who didn't bother to follow the link...

You ping 127.0.0.1.

ping uses inet_aton from the standard c library to convert the string 0x7f.1
into a 32 bit integer value.

The string is assumed to be a series of numbers separated by .'s.

A number prefixed with 0x is assumed to be hexidecimal. Likewise, were it to
be prefixed with only a 0 it would be assumed to be octal. This is standard
practice for ascii to number conversions.

Each number is assumed to be an 8 bit value. However, the rightmost number
in the series is as big as the remaining number of bits to be populated in
the 32 bit value.

So...

127.1     = 01111111 000000000000000000000001
127.0.1   = 01111111 00000000 0000000000000001
127.0.0.1 = 01111111 00000000 00000000 00000000


I wonder how it works out under IPv6?

Garrett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://kclug.org/pipermail/kclug/attachments/20050504/06025e33/attachment.htm


More information about the Kclug mailing list