I couldn’t find much information on how the Bootstrap Router hash function is calculated. Most sources teach that the mask dictates how much of the group IP address is used in the hash calculation and that the RP IP address that returns the highest value from the BSR hash algorithm becomes the chosen RP for that group, but don’t give detail on how the BSR hash is calculated.
I found the following algorithm in RFC 4601:
Value(G,M,C(i))=(1103515245 * ((1103515245 * (G&M)+12345) XOR C(i)) + 12345) mod 2^31
Mushing together various python examples from the Internet gave me the following script:
mask=int('11111111111111111111111111111110', 2) group='126.96.36.199' rpip='188.8.131.52' groupbin=''.join(format(int(x), '08b') for x in group.split('.')) groupdec=int(groupbin, 2) rpipbin=''.join(format(int(x), '08b') for x in rpip.split('.')) rpipdec=int(rpipbin, 2) bsrhash=(1103515245*((1103515245*(groupdec & mask)+12345)^rpipdec)+12345)%(2**31) print bsrhash
The output generated by the script when amending the ‘mask’, ‘group’ and ‘rpip’ variables matches the hash generated by the ‘
show ip pim rp-hash‘ command on IOS.