# This is a clockwise ring distance function.
# It depends on a globally defined k, the key size.
# The largest possible node id is 2^k.
def distance(a, b):
    if a==b:        
        return 0
    elif a<b:       
        return b-a;
    else:
        return (2^k)+(b-a);
                    
