I was working on some changes to the babeld-lab repo. I ended up not using any of the existing code, but learning from the concepts, so I put the new code in its own repo:
https://github.com/sudomesh/network-lab
It reads a JSON network graph format defining nodes and edges and uses it to create nodes in network namespaces linked by virtual ethernet edges of differing quality (babeld-lab connects all nodes to one switch).
Each edge has configurable latency and packet loss in both directions provided by tc netem.
Each node can run arbitrary scripts in its namespace on startup. These scripts could be used to start a routing protocol.
-Jehan