Distance Vector Routing algorithm in Python