On Wed, Aug 26, 1998 at 07:54:24PM +0800, htyj wrote: > I've seen the term "magic number" in many documents, I wonder what it is, and > how to get it(calculate it?)? TIA.
A magic number is basically an identifier... for example....if I am sniffing ethernet (ie taking in raw ethernet packets whether or not they are designated for me) but I am only concerned with IP... I can look at the packet and I know (generally) the first 12 bytes are source and destination adresses so they can be anything...but for IP I know that byte number 13 is going to be the ethertype and for IP that is 0x0800 so I can consider that a "magic number" and if I look for that I know I have IP (to be more complex./...I know the next nibble will be a 4 because IP is currently version 4) Have I lost you? basically it is a number I can use to telll what I am looking at. another example...take a MS-DOS executable...look at the first 2 bytes... they will ALWAYS be "MZ" This is a magic number for MS DOS executables It is basically some number which you can know exactly how to find which will identify what you are looking at. These are often chosen on purpose (there is really no reason for an MS DOS executable to begin with "MZ" except for the fact that it helps to identify it does that clear it up? check out /etc/magic it is a file which defines filetypes by their "magic numbers" -Steve -- /* -- Stephen Carpenter <[EMAIL PROTECTED]> --- <[EMAIL PROTECTED]>------------ */ E-mail "Bumper Stickers": "A FREE America or a Drug-Free America: You can't have both!" "honk if you Love Linux"