Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just realised something;

I've been developing web applications for a relatively long time now. Maybe in the last 10 years, I had my IP addresses stored in databases etc in IPv6 aware types just in case we had an IPv6 deployment in future. Better be ready.

Last month, I was working on something that needed to store IP logs. I packed them in 32 bit unsigned integers. Was not a well thought decision. I think I don't care anymore, just gave up.

Anyone doing the opposite of that? Maybe I was naive to jump on the train that early and these are better times. Felt like that 5 years ago too though.



I think a 32-bit hash of an IPv6 address will be fine for a long time, and remain much faster to search/sort than a 128-bit value.

I also think that if you can't upgrade your database you're going to have other problems as well.


> I think a 32-bit hash of an IPv6 address will be fine for a long time

Be careful with this, a 32 bit hash can see collisions with remarkably low numbers. A 50% chance of a collision is seen with ~75k entries: http://preshing.com/20110504/hash-collision-probabilities/

Depends on your application as to whether this is a problem or not.


50% chance of one collision. Be careful with those maths!


Yes, thanks for the clarification, it's what I meant with "a collision" but I realise that's ambiguous.


No worries, and you're absolutely right that it depends on your application whether this is a problem or not!

Estimating population sizes? "Unrecognised IP addresses?" Probably fine.

Interning the hash and using the real IP address in a database someplace? Probably not.


No, it's a 50% probability of there being at least one collision (or, put another way, a 50% chance of there being no collisions).


You're absolutely right, but it won't let me edit it.

Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: