Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.programming,comp.unix.programmer Subject: Re: hash function over IP address Date: Thu, 05 Apr 2012 12:08:58 +0100 Lines: 28 Message-ID: <87k41uo2ph.fsf@sapphire.mobileactivedefense.com> References: <87hawzyy3z.fsf@blp.benpfaff.org> <87398jw4ep.fsf@sapphire.mobileactivedefense.com> <87d37nyvjw.fsf@blp.benpfaff.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net 0G7ZVh9RNRKr3uyTcg+4CwMvEhfibTZ9FHAzokSkTZbzK9XFI= Cancel-Lock: sha1:n9tz5xP6yAqWPRCOFB9/GJGxeW4= sha1:+grXFuEBpRA+qPAscloZX44s9I4= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Xref: csiph.com comp.programming:1421 comp.unix.programmer:2362 blp@cs.stanford.edu (Ben Pfaff) writes: > Rainer Weikusat writes: > >> Ben Pfaff writes: >>> "Mark" writes: >>> >>>> I'm trying to find a way create a hash value over multiple IP addresses (I >>>> keep a list of IP addresses and its number is variable. The simplest method >>>> I've found so far is (obviously not the most effective and collision free): >>> >>> Why not use one of many available high-quality hash functions? >>> Three that come to mind without even going to a search engine: >>> Jenkins lookup3, murmurhash, FNV. >> >> The simple answer is these hash functions are designed to be used for >> large, variable length string keys NOT for small, fixed-size >> quantities which can be compared with a single machine instruction. >> >> http://burtleburtle.net/bob/hash/integer.html >> http://www.cris.com/~Ttwang/tech/inthash.htm > > He has a list of multiple IP addresses. A hash function for > variable length keys may well be appropriate. Calculating the hash value must be cheaper than the full comparisons which will be needed for a linear search. And performing extensive byte-shuffling on machine words is not a good strategy to achieve that.