in reply to Re: Re: Re: integer encoder/decoder
in thread integer encoder/decoder

I thought about splitting it up actually. I didn't want to just do the whole ip like
enterprise.10000.10182.192.168.254.12.3888206
even though I have seen that before because I don't really want them knowing the IP.

I also could split to two 16bit numbers, but it just comes down to simplicity. Why add 3 extra oid levels if I can just make one? That also makes it easier on the client, only having to remember one.

That was the whole point of this node. To find a way to get one unique 9 digit number out of the IP and sessionid.

There must be some kind of mathematical munging formula. I don't care really..it can use mod, division, whatever. As long as it's unique for that IP and sessionid. I don't even really need to be able to decode it. Can't anybody help???

Replies are listed 'Best First'.
•Re: Re: Re: Re: Re: integer encoder/decoder
by merlyn (Sage) on Mar 14, 2003 at 00:58 UTC
    There must be some kind of mathematical munging formula. I don't care really..it can use mod, division, whatever. As long as it's unique for that IP and sessionid. I don't even really need to be able to decode it. Can't anybody help???
    How many times must we say (at least three so far) that you can't put ten pounds of potatoes into a five pound sack?

    This can't be done. Get it?

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Re: Re: Re: Re: integer encoder/decoder
by zengargoyle (Deacon) on Mar 14, 2003 at 02:10 UTC

    then you have one hope.

    and it's a slim one.

    but you might be able to wring the last bit of info out.

    the absolute max session id is 999_999_999 which in binary is: $ perl -e 'printf"%032b$/",999999999' 00111011100110101100100111111111 you have the 2 most significant bits to work with. %NASs = ( '192.168.254.12' => 0, '192.168.255.13' => 1, '192.168.256.2' => 2, '192.168.243.1' => 3 ); so you can fit 4 IP's and a session id in 32 bits. if you want to assume that your session id won't go above 463129087 th +en you can steal another bit and have 8 IPs. $ perl -le 'print unpack "N", pack "B*", "0001101110011010110010011111 +1111"' 463129087 or along the same lines, use the NAS number and session id with a dot, only because it's easier for humans. 1.4596831 12.4596831 instead of the 16bit big numbers...

    this assumes an OID part can be 32 bits.

    $ snmpget -v 1 $CENSORED sysDescr.9999999999 Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: system.sysDescr.4294967295 $ snmpget -v 1 $CENSORED sysDescr.4294967294 Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: system.sysDescr.4294967294 $ snmpget -v 1 $CENSORED sysDescr.4294967295 Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: system.sysDescr.4294967295 $ snmpget -v 1 $CENSORED sysDescr.4294967296 Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: system.sysDescr.4294967295

    which may or may not be true.