mirror of
https://github.com/Wojtek242/route0.git
synced 2024-11-22 07:05:25 +01:00
Add IS-IS scenario to two-node topology
This commit is contained in:
parent
1c74dd16c9
commit
f992fc0426
19
route-0.py
19
route-0.py
@ -9,7 +9,7 @@ from mininet.cli import CLI
|
||||
from router import Router
|
||||
from topology.one_node.topo import NetTopo as OneNode
|
||||
from topology.two_nodes.topo import NetTopo as TwoNodes
|
||||
from scenario import Basic, Plain
|
||||
from scenario import Basic, Plain, Isis
|
||||
|
||||
|
||||
def start_deamon(node, daemon, conf_dir):
|
||||
@ -17,7 +17,7 @@ def start_deamon(node, daemon, conf_dir):
|
||||
|
||||
"""
|
||||
node.cmd("/usr/lib/frr/{daemon}"
|
||||
" -f {conf_dir}/{daemon}/{node_name}.conf"
|
||||
" -f {conf_dir}/{node_name}.conf"
|
||||
" -d"
|
||||
" -i /tmp/{node_name}-{daemon}.pid"
|
||||
" > /tmp/{node_name}-{daemon}.out 2>&1"
|
||||
@ -32,11 +32,11 @@ def run(topo, scenario):
|
||||
os.system("rm -f /tmp/R*.log /tmp/R*.pid /tmp/R*.out")
|
||||
os.system("rm -f /tmp/h*.log /tmp/h*.pid /tmp/h*.out")
|
||||
os.system("mn -c >/dev/null 2>&1")
|
||||
os.system("killall -9 zebra staticd > /dev/null 2>&1")
|
||||
os.system("killall -9 zebra staticd isisd > /dev/null 2>&1")
|
||||
|
||||
net = Mininet(topo=topo, switch=Router)
|
||||
net.start()
|
||||
scenario.setup(net)
|
||||
scenario.setup(net, topo.topo_dir)
|
||||
|
||||
# WARNING: FRR can get confused unless all daemons on each node are started
|
||||
# together.
|
||||
@ -48,7 +48,7 @@ def run(topo, scenario):
|
||||
|
||||
if node in scenario.zebra:
|
||||
# Start Zebra (routing table daemon)
|
||||
start_deamon(node, "zebra", topo.topo_dir)
|
||||
start_deamon(node, "zebra", scenario.zebra_conf)
|
||||
|
||||
# Delete spare loopback address for convenience
|
||||
node.cmd("ip addr del 127.0.0.1/8 dev lo")
|
||||
@ -56,11 +56,15 @@ def run(topo, scenario):
|
||||
|
||||
if node in scenario.staticd:
|
||||
# Start static route daemon
|
||||
start_deamon(node, "staticd", topo.topo_dir)
|
||||
start_deamon(node, "staticd", scenario.staticd_conf)
|
||||
|
||||
if node in scenario.isisd:
|
||||
# Start IS-IS daemon
|
||||
start_deamon(node, "isisd", scenario.isisd_conf)
|
||||
|
||||
CLI(net)
|
||||
net.stop()
|
||||
os.system("killall -9 zebra staticd")
|
||||
os.system("killall -9 zebra staticd isisd")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -72,6 +76,7 @@ if __name__ == "__main__":
|
||||
scenario = {
|
||||
"plain": Plain,
|
||||
"basic": Basic,
|
||||
"isis": Isis,
|
||||
}
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
78
scenario.py
78
scenario.py
@ -1,3 +1,6 @@
|
||||
import os
|
||||
|
||||
|
||||
class Scenario(object):
|
||||
"""Class that describes a network scenario. A scenario defines which nodes
|
||||
are routers and which are hosts as well as which nodes need to start which
|
||||
@ -10,6 +13,24 @@ class Scenario(object):
|
||||
self._hosts = None
|
||||
self._zebra = None
|
||||
self._staticd = None
|
||||
self._isisd = None
|
||||
|
||||
self._zebra_conf = None
|
||||
self._staticd_conf = None
|
||||
self._isisd_conf = None
|
||||
|
||||
self._reset()
|
||||
|
||||
def _reset(self):
|
||||
self._routers = set()
|
||||
self._hosts = set()
|
||||
self._zebra = set()
|
||||
self._staticd = set()
|
||||
self._isisd = set()
|
||||
|
||||
self._zebra_conf = None
|
||||
self._staticd_conf = None
|
||||
self._isisd_conf = None
|
||||
|
||||
@property
|
||||
def routers(self):
|
||||
@ -39,6 +60,34 @@ class Scenario(object):
|
||||
"""
|
||||
return self._staticd
|
||||
|
||||
@property
|
||||
def isisd(self):
|
||||
"""Set of nodes that should run isisd.
|
||||
|
||||
"""
|
||||
return self._isisd
|
||||
|
||||
@property
|
||||
def zebra_conf(self):
|
||||
"""Directory with zebra config files.
|
||||
|
||||
"""
|
||||
return self._zebra_conf
|
||||
|
||||
@property
|
||||
def staticd_conf(self):
|
||||
"""Directory with staticd config files.
|
||||
|
||||
"""
|
||||
return self._staticd_conf
|
||||
|
||||
@property
|
||||
def isisd_conf(self):
|
||||
"""Directory with isisd config files.
|
||||
|
||||
"""
|
||||
return self._isisd_conf
|
||||
|
||||
def _routers_and_hosts(self, net):
|
||||
"""Separate nodes into routers and hosts based on their names.
|
||||
|
||||
@ -52,13 +101,12 @@ class Scenario(object):
|
||||
else:
|
||||
self._hosts.add(node)
|
||||
|
||||
def setup(self, net):
|
||||
def setup(self, net, _topo_dir):
|
||||
"""Setup the scenario.
|
||||
|
||||
"""
|
||||
self._reset()
|
||||
self._routers_and_hosts(net)
|
||||
self._zebra = set()
|
||||
self._staticd = set()
|
||||
|
||||
|
||||
class Plain(Scenario):
|
||||
@ -76,7 +124,27 @@ class Basic(Scenario):
|
||||
def __init__(self):
|
||||
Scenario.__init__(self)
|
||||
|
||||
def setup(self, net):
|
||||
self._routers_and_hosts(net)
|
||||
def setup(self, net, topo_dir):
|
||||
super(Basic, self).setup(net, topo_dir)
|
||||
|
||||
self._zebra = self._routers.union(self._hosts)
|
||||
self._staticd = self._hosts
|
||||
|
||||
self._zebra_conf = os.path.join(topo_dir, "zebra")
|
||||
self._staticd_conf = os.path.join(topo_dir, "staticd")
|
||||
|
||||
|
||||
class Isis(Basic):
|
||||
"""Run IS-IS on all routers.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
Basic.__init__(self)
|
||||
|
||||
def setup(self, net, topo_dir):
|
||||
super(Isis, self).setup(net, topo_dir)
|
||||
|
||||
self._isisd = self._routers
|
||||
|
||||
self._isisd_conf = os.path.join(topo_dir, "scenario/isis/isisd")
|
||||
|
20
topology/two_nodes/scenario/isis/isisd/R1.conf
Normal file
20
topology/two_nodes/scenario/isis/isisd/R1.conf
Normal file
@ -0,0 +1,20 @@
|
||||
! -*- isisd -*-
|
||||
|
||||
hostname R1
|
||||
|
||||
router isis ROUTE0
|
||||
net 49.0001.0000.0000.0001.00
|
||||
|
||||
interface lo
|
||||
ip router isis ROUTE0
|
||||
isis passive
|
||||
|
||||
interface R1-eth1
|
||||
ip router isis ROUTE0
|
||||
isis circuit-type level-2-only
|
||||
|
||||
interface R1-eth2
|
||||
ip router isis ROUTE0
|
||||
isis passive
|
||||
|
||||
log file /tmp/R1-isisd.log debugging
|
20
topology/two_nodes/scenario/isis/isisd/R2.conf
Normal file
20
topology/two_nodes/scenario/isis/isisd/R2.conf
Normal file
@ -0,0 +1,20 @@
|
||||
! -*- isisd -*-
|
||||
|
||||
hostname R2
|
||||
|
||||
router isis ROUTE0
|
||||
net 49.0002.0000.0000.0002.00
|
||||
|
||||
interface lo
|
||||
ip router isis ROUTE0
|
||||
isis passive
|
||||
|
||||
interface R2-eth1
|
||||
ip router isis ROUTE0
|
||||
isis circuit-type level-2-only
|
||||
|
||||
interface R2-eth2
|
||||
ip router isis ROUTE0
|
||||
isis passive
|
||||
|
||||
log file /tmp/R2-isisd.log debugging
|
Loading…
Reference in New Issue
Block a user