summaryrefslogtreecommitdiffstats
path: root/misc/stats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-12-19 12:51:47 +0100
committerMartin Mares <mj@ucw.cz>1998-12-19 12:51:47 +0100
commit87b60bf7e8ad12b3efd3d6f37df0d029f50d2d91 (patch)
tree08e7758f9f14a3446286d42e78812860524de5a9 /misc/stats
parent02933ddbbec94f1bb01c0b9e5198fe272c1f5025 (diff)
downloadbird-87b60bf7e8ad12b3efd3d6f37df0d029f50d2d91.tar
bird-87b60bf7e8ad12b3efd3d6f37df0d029f50d2d91.zip
Added several tools for fib hashing function analysis. It turned out
we can use very simple function which is monotonic with respect to re-hashing: n ^= n >> 16; n ^= n << 10; h = (n >> (16 - o)) & ((1 << o) - 1); where o is table order. Statistical analysis for both backbone routing table and local OSPF routing tables gives values near theoretical optimum for uniform distribution (see ips.c for formulae). The trick is very simple: We always calculate a 16-bit hash value n and use o most significant bits (this gives us monotonity wrt. rehashing if we sort the chains by the value of n). The first shift/xor pair reduces the IP address to a 16-bit one, the second pair makes higher bits of the 16-bit value uniformly distributed even for tables containing lots of long prefixes (typical interior routing case with 24-bit or even longer prefixes).
Diffstat (limited to 'misc/stats')
-rwxr-xr-xmisc/stats9
1 files changed, 9 insertions, 0 deletions
diff --git a/misc/stats b/misc/stats
new file mode 100755
index 0000000..57920ce
--- /dev/null
+++ b/misc/stats
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+make ips
+echo "Global tables:"
+for a in 4 5 6 7 8 9 10 11 12 13 14 15 ; do
+ ./ips <global $a $((1<<($a+2)))
+ done
+echo "Local tables:"
+./ips <local 6 1000