예제 #1
0
파일: topo.py 프로젝트: mfalgert/ews
    def __init__(self):
        Topo.__init__(self)
        # List of Quagga host configs
        quaggaHosts = self.addQuaggas()

        quaggas = {}
        # Setup each Quagga router
        for host in quaggaHosts:
            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           mac=host.mac,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)
            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = {
                "quaggaConfigPath": quaggaBaseConfigPath + host.name
            }
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            # Save it
            quaggas[host.name] = quaggaContainer

        # Add one host to each router
        self.addHosts(quaggas)
        # Links between routers
        self.addQuaggaLinks(quaggas)
예제 #2
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='H1',
                       ip='192.168.101.128/24',
                       DG='via 192.168.101.1'))
        quaggaHosts.append(QuaggaHost(name='R1', ip='192.168.101.1/24', DG=''))
        quaggaHosts.append(QuaggaHost(name='R2', ip='192.168.102.1/24', DG=''))
        quaggaHosts.append(QuaggaHost(name='R3', ip='192.168.103.1/24', DG=''))
        quaggaHosts.append(QuaggaHost(name='R4', ip='192.168.106.1/24', DG=''))
        quaggaHosts.append(
            QuaggaHost(name='H2',
                       ip='192.168.106.128/24',
                       DG='via 192.168.106.1'))

        # Setup each Quagga router, add a link between it and the IXP fabric
        quaggaContainer = {}
        for host in quaggaHosts:
            # Create an instance of a host, called a quaggaContainer
            quaggaContainer[host.name] = self.addHost(name=host.name,
                                                      ip=host.ip,
                                                      hostname=host.name,
                                                      defaultRoute=host.DG,
                                                      privateLogDir=True,
                                                      privateRunDir=True,
                                                      inMountNamespace=True,
                                                      inPIDNamespace=True,
                                                      inUTSNamespace=True)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

        # Attach the quaggaContainer to the IXP Fabric Switch
        self.addLink(quaggaContainer['R1'], quaggaContainer['H1'])
        self.addLink(quaggaContainer['R1'], quaggaContainer['R2'])
        self.addLink(quaggaContainer['R1'], quaggaContainer['R3'])
        self.addLink(quaggaContainer['R4'], quaggaContainer['H2'])
        self.addLink(quaggaContainer['R4'], quaggaContainer['R2'])
        self.addLink(quaggaContainer['R4'], quaggaContainer['R3'])
예제 #3
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='a1', ip='172.0.1.1/16', loIP='10.0.1.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='b1', ip='172.0.2.1/16', loIP='10.0.2.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='c1', ip='172.0.3.2/16', loIP='10.0.3.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='c2', ip='172.0.3.1/16', loIP='10.0.3.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='d1', ip='172.0.4.1/16', loIP='10.0.4.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='rs', ip='172.0.254.254/16', loIP=None))

        # Add switch for IXP fabric
        ixpfabric = self.addSwitch('fabric-sw1')

        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # Attach the quaggaContainer to the IXP Fabric Switch
            self.addLink(quaggaContainer, ixpfabric)
예제 #4
0
    def __init__(self, num_nodes):
        """Initialize a ChordDFS topology with num_nodes nodes, configure their IP
		addresses and paths to their private directories"""
        Topo.__init__(self)

        chordDFSHosts = []

        # create nodes
        for node in range(num_nodes):
            host = self.addHost(name='n{0}'.format(node + 1),
                                ip='172.1.1.{0}/24'.format(node + 1))
            chordDFSHosts.append(host)
            # create corresponding directories
            if not os.path.exists("nodes/n{0}".format(node + 1)):
                os.makedirs("nodes/n{0}".format(node + 1))
                os.makedirs("nodes/n{0}/files".format(node + 1))
                os.makedirs("nodes/n{0}/files/chord".format(node + 1))
                os.makedirs("nodes/n{0}/files/client".format(node + 1))
                os.makedirs("nodes/n{0}/logs".format(node + 1))
            # clean the directories
            else:
                for root, dirs, files in os.walk("nodes", topdown=False):
                    # dont delete the files dir
                    split_path = root.split("/")
                    if split_path[-1] != "client":
                        for f in files:
                            os.remove(os.path.join(root, f))
        ixpfabric = self.addSwitch('sw1')
        for node in chordDFSHosts:
            self.addLink(node, ixpfabric)
예제 #5
0
파일: topo.py 프로젝트: rubiruchi/DHT
    def __init__(self, total_nodes_to_create):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        self.quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        self.quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        self.base_ip_address = [172, 0, 1, 1]
        self.subnet_mask = 16
        self.loopback_address = '127.0.0.1/24'
        self.host_prefix = 'a'
        self.total_nodes = 0

        # Add switch for IXP fabric
        self.ixpfabric = self.addSwitch('fabric-sw1')

        for i in range(total_nodes_to_create):
            self.add_node()
예제 #6
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='H1', ip='192.0.1.1/24', loIP='10.0.1.1/24'))
        quaggaHosts.append(QuaggaHost(name='R1', ip='192.0.1.2/24', loIP=None))
        quaggaHosts.append(QuaggaHost(name='R2', ip='192.0.2.2/24', loIP=None))
        quaggaHosts.append(
            QuaggaHost(name='R3', ip='192.0.3.2/24', loIP='10.0.3.1/24'))
        quaggaHosts.append(
            QuaggaHost(name='R4', ip='192.0.6.1/24', loIP='10.0.4.1/24'))
        quaggaHosts.append(QuaggaHost(name='H2', ip='192.0.6.2/24', loIP=None))

        hostList = []
        print("Arun :Creating a list of hosts ")
        for host in quaggaHosts:

            # Create an instance of a host and append it to the hostList
            hostList.append(
                self.addHost(name=host.name,
                             ip=host.ip,
                             hostname=host.name,
                             privateLogDir=True,
                             privateRunDir=True,
                             inMountNamespace=True,
                             inPIDNamespace=True,
                             inUTSNamespace=True))

            # Add a loopback interface with an IP in router's announced range
            #self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
        self.addLink(hostList[0], hostList[1])
        self.addLink(hostList[1], hostList[2])
        self.addLink(hostList[1], hostList[3])
        self.addLink(hostList[4], hostList[5])
        self.addLink(hostList[2], hostList[4])
        self.addLink(hostList[3], hostList[4])
예제 #7
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='H1', ip='162.0.0.1/20', loIP='10.0.1.1/20'))
        quaggaHosts.append(
            QuaggaHost(name='R1', ip='162.0.0.2/20', loIP='10.0.2.1/20'))
        quaggaHosts.append(
            QuaggaHost(name='R2', ip='163.0.0.1/20', loIP='10.0.3.1/20'))
        quaggaHosts.append(
            QuaggaHost(name='R3', ip='164.0.0.1/20', loIP='10.0.3.1/20'))
        quaggaHosts.append(
            QuaggaHost(name='R4', ip='167.0.0.2/20', loIP='10.0.4.1/20'))
        quaggaHosts.append(
            QuaggaHost(name='H2', ip='167.0.0.1/20', loIP='10.0.5.1/20'))
        nodes = []
        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            nodes.append(
                self.addHost(name=host.name,
                             ip=host.ip,
                             hostname=host.name,
                             privateLogDir=True,
                             privateRunDir=True,
                             inMountNamespace=True,
                             inPIDNamespace=True,
                             inUTSNamespace=True))

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

        self.addLink(nodes[0], nodes[1])
        self.addLink(nodes[1], nodes[2])
        self.addLink(nodes[1], nodes[3])
        self.addLink(nodes[5], nodes[4])
        self.addLink(nodes[2], nodes[4])
        self.addLink(nodes[3], nodes[4])
예제 #8
0
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        # location of config dir
        configdir = os.path.abspath(sys.argv[1])

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath = configdir

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name = 'a1', ip = '172.0.0.1/16', mac = '08:00:27:89:3b:9f', port = 5))
        quaggaHosts.append(QuaggaHost(name = 'b1', ip = '172.0.0.11/16', mac ='08:00:27:92:18:1f', port = 6))
        quaggaHosts.append(QuaggaHost(name = 'c1', ip = '172.0.0.21/16', mac = '08:00:27:54:56:ea', port = 7))
        quaggaHosts.append(QuaggaHost(name = 'c2', ip = '172.0.0.22/16', mac = '08:00:27:bd:f8:b2', port = 8))


        "Add switch for IXP fabric"
        main_switch = self.addSwitch( 's1' )
        inbound_switch = self.addSwitch( 's2' )
        outbound_switch = self.addSwitch( 's3' )
        arp_switch = self.addSwitch( 's4' )

        self.addLink(main_switch, inbound_switch, 1, 1)
        self.addLink(main_switch, outbound_switch, 2, 1)
        self.addLink(main_switch, arp_switch, 3, 1)
        self.addLink(outbound_switch, inbound_switch, 2, 2)        

        # Add node for central Route Server"
        route_server = self.addHost('x1', ip = '172.0.255.254/16', mac='08:00:27:89:3b:ff', inNamespace = False)
        self.addLink(main_switch, route_server, 4)

        # Add node for ARP Proxy"
        arp_proxy = self.addHost('x2', ip = '172.0.255.253/16', mac='08:00:27:89:33:ff', inNamespace = False)
        self.addLink(arp_switch, arp_proxy, 2)

        "Setup each legacy router, add a link between it and the IXP fabric"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : os.path.join(configdir, host.name) }

            quaggaContainer = self.addHost( name=host.name,
                                            ip=host.ip,
                                            mac=host.mac,
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            self.addLink( quaggaContainer, main_switch , port2=host.port)
예제 #9
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='r1', ip='223.1.1.1/24'))
        quaggaHosts.append(QuaggaHost(name='r2', ip='223.1.2.1/24'))
        quaggaHosts.append(QuaggaHost(name='r3', ip='223.1.1.2/24'))
        quaggaHosts.append(QuaggaHost(name='r4', ip='223.1.3.2/24'))
        quaggaHosts.append(QuaggaHost(name='h1', ip='223.1.5.10/24'))
        quaggaHosts.append(QuaggaHost(name='h2', ip='223.1.6.10/24'))

        quaggas = {}

        # Setup each Quagga router
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = {
                'quaggaConfigPath': quaggaBaseConfigPath + host.name
            }
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            quaggas[host.name] = quaggaContainer

        # Add the links
        self.addLink(quaggas['h1'], quaggas['r1'])  # h1-eth0 : r1-eth0
        self.addLink(quaggas['h2'], quaggas['r4'])  # h2-eth0 : r4-eth0
        self.addLink(quaggas['r1'], quaggas['r2'])  # r1-eth1 : r2-eth0
        self.addLink(quaggas['r3'], quaggas['r4'])  # r3-eth0 : r4-eth1
        self.addLink(quaggas['r1'], quaggas['r3'])  # r1-eth2 : r3-eth1
        self.addLink(quaggas['r2'], quaggas['r4'])  # r2-eth1 : r4-eth2
예제 #10
0
파일: topo.py 프로젝트: USC-NSL/miniNExT
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='a1', ip='172.0.1.1/16',
                                      loIP='10.0.1.1/24'))
        quaggaHosts.append(QuaggaHost(name='b1', ip='172.0.2.1/16',
                                      loIP='10.0.2.1/24'))
        quaggaHosts.append(QuaggaHost(name='c1', ip='172.0.3.2/16',
                                      loIP='10.0.3.1/24'))
        quaggaHosts.append(QuaggaHost(name='c2', ip='172.0.3.1/16',
                                      loIP='10.0.3.1/24'))
        quaggaHosts.append(QuaggaHost(name='d1', ip='172.0.4.1/16',
                                      loIP='10.0.4.1/24'))
        quaggaHosts.append(QuaggaHost(name='rs', ip='172.0.254.254/16',
                                      loIP=None))

        # Add switch for IXP fabric
        ixpfabric = self.addSwitch('fabric-sw1')

        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # Attach the quaggaContainer to the IXP Fabric Switch
            self.addLink(quaggaContainer, ixpfabric)
예제 #11
0
    def __init__(self):
        """Initialize a Quagga topology with 4 routers and 2 hosts, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='H1', ip='170.1.1.1/24',DG='via 170.1.1.2',loIP=None))
        quaggaHosts.append(QuaggaHost(name='R1', ip='170.1.1.2/24',DG='',loIP=None))
        quaggaHosts.append(QuaggaHost(name='R2', ip='171.1.1.2/24',DG='',loIP=None))
        quaggaHosts.append(QuaggaHost(name='R3', ip='172.1.1.2/24',DG='',loIP=None))
        quaggaHosts.append(QuaggaHost(name='R4', ip='175.7.7.1/24',DG='',loIP=None))
        quaggaHosts.append(QuaggaHost(name='H2', ip='175.7.7.2/24',DG='via 175.7.7.1',loIP=None))

        hostList = []
        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:
            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           defaultRoute=host.DG,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)
            hostList.append(quaggaContainer)
            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)
            # Configure and setup the Quagga service for this node
            quaggaSvcConfig ={'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name, service=quaggaSvc,nodeConfig=quaggaSvcConfig)

        self.addLink(hostList[0], hostList[1])#H1-R1
        self.addLink(hostList[1], hostList[2])#R1-R2
        self.addLink(hostList[1], hostList[3])#R1-R3
        self.addLink(hostList[5], hostList[4])#H2-R4
        self.addLink(hostList[2], hostList[4])#R2-R4
        self.addLink(hostList[3], hostList[4])#R3-R4
예제 #12
0
    def __init__(self):
        Topo.__init__(self)
        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # Initialize data structure to map each router with the port on the switch corresponding to incoming traffic
        self.in_interface = {}
        # saving speed of each interface
        self.intf_speed = {}
        outer = self.createQuaggRing(OUTER, quaggaSvc, quaggaBaseConfigPath)

        # inner = self.createQuaggRing(INNER, quaggaSvc, quaggaBaseConfigPath, r_name="ri{:d}", s_name="si{:d}")
        # test with different naming because of problem with contorller
        inner = self.createQuaggRing(INNER,
                                     quaggaSvc,
                                     quaggaBaseConfigPath,
                                     r_name="ri{:d}",
                                     count=OUTER,
                                     bw=IN_BW)

        # creating custom connections between inner and outer rings
        self.addLinkWithSwitch(outer[0], inner[1],
                               self.addSwitch("s11", protocols='OpenFlow13'))
        self.addLinkWithSwitch(outer[2], inner[1],
                               self.addSwitch("s12", protocols='OpenFlow13'))
        self.addLinkWithSwitch(outer[2], inner[2],
                               self.addSwitch("s13", protocols='OpenFlow13'))
        self.addLinkWithSwitch(outer[3], inner[3],
                               self.addSwitch("s14", protocols='OpenFlow13'))
        self.addLinkWithSwitch(outer[5], inner[3],
                               self.addSwitch("s15", protocols='OpenFlow13'))
        self.addLinkWithSwitch(outer[5], inner[0],
                               self.addSwitch("s16", protocols='OpenFlow13'))

        # saving mapping on file
        with open(OUT_DIR + 'switch_mapping.pkl', 'wb+') as f:
            pickle.dump(self.in_interface, f)

        # saving intf speed on file
        with open(OUT_DIR + 'intf_speed.pkl', 'wb+') as f:
            pickle.dump(self.intf_speed, f)
예제 #13
0
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/configs/'

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name = 'a1', ip = '172.0.0.1/16', mac = '08:00:27:89:3b:9f', port = 1))
        quaggaHosts.append(QuaggaHost(name = 'b1', ip = '172.0.0.11/16', mac ='08:00:27:92:18:1f', port = 2))
        quaggaHosts.append(QuaggaHost(name = 'c1', ip = '172.0.0.21/16', mac = '08:00:27:54:56:ea', port = 3))
        quaggaHosts.append(QuaggaHost(name = 'c2', ip = '172.0.0.22/16', mac = '08:00:27:bd:f8:b2', port = 4))


        "Add switch for IXP fabric"
        ixpfabric = self.addSwitch( 's1' )


        "Setup each legacy router, add a link between it and the IXP fabric"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + host.name }

            quaggaContainer = self.addHost( name=host.name,
                                            ip=host.ip,
                                            mac=host.mac,
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            self.addLink( quaggaContainer, ixpfabric , port2=host.port)

        " Add root node for ExaBGP. ExaBGP acts as route server for SDX. "
        root = self.addHost('exabgp', ip = '172.0.255.254/16', inNamespace = False)
        self.addLink(root, ixpfabric, port2 = 5)
예제 #14
0
    def __init__(self):
        """Initialize a Quagga topology based on the topology information"""
        Topo.__init__(self)

        info("*** Creating dumbbell topology and adding nodes")
        self.addHost(name="client1",
                     hostname="client1",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
        self.addHost(name="client2",
                     hostname="client2",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
        self.addHost(name="router1",
                     hostname="router1",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
        self.addHost(name="router2",
                     hostname="router2",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
        self.addHost(name="server1",
                     hostname="server1",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
        self.addHost(name="server2",
                     hostname="server2",
                     privateLogDir=True,
                     privateRunDir=True,
                     inMountNamespace=True,
                     inPIDNamespace=True,
                     inUTSNamespace=True)
예제 #15
0
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/quaggacfgs/'

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name = 'a1', ip = '172.0.0.1/16', mac = '08:00:27:89:3b:9f', port = 1))
        quaggaHosts.append(QuaggaHost(name = 'b1', ip = '172.0.0.11/16', mac ='08:00:27:92:18:1f', port = 2))
        quaggaHosts.append(QuaggaHost(name = 'c1', ip = '172.0.0.21/16', mac = '08:00:27:54:56:ea', port = 3))
        quaggaHosts.append(QuaggaHost(name = 'c2', ip = '172.0.0.22/16', mac = '08:00:27:bd:f8:b2', port = 4))

        "Add switch for IXP fabric"
        ixpfabric = self.addSwitch( 's1' )


        "Setup each legacy router, add a link between it and the IXP fabric"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : scriptdir + '/quaggacfgs/' + host.name }

            quaggaContainer = self.addHost( name=host.name,
                                            ip=host.ip,
                                            mac=host.mac,
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            self.addLink( quaggaContainer, ixpfabric , port2=host.port)
        
        " Add root node for ExaBGP. ExaBGP acts as route server for SDX. "
        root = self.addHost('exabgp', ip = '172.0.255.254/16', inNamespace = False)
        self.addLink(root, ixpfabric, port2 = 5)
예제 #16
0
파일: k.py 프로젝트: fengjiangwei65/test
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory
        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/quaggacfgs/'

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name = 'a1', ip = '172.0.0.1/16', mac = '08:00:27:89:3b:9f', port = 1))
        quaggaHosts.append(QuaggaHost(name = 'b1', ip = '172.0.0.11/16', mac ='08:00:27:92:18:1f', port = 2))
 		quaggaHosts.append(QuaggaHost(name = 'c1', ip = '172.0.0.21/16', mac = '08:00:27:54:56:ea', port = 3))
예제 #17
0
파일: topology.py 프로젝트: NeveIsa/cs651
    def __init__(self):
        """Initialize a Quagga topology based on the topology information"""
        Topo.__init__(self)

        # Initialize a service helper for Quagga with default options
        self.quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        self.quaggaBaseConfigPath = '/root/configs/'

        # Setup each Quagga router
        for router_name in nc_routers('i2'):
            info("\tAdding router %s\n" % (router_name))
            self.addHost(name=router_name,
                         hostname=router_name,
                         privateLogDir=True,
                         privateRunDir=True,
                         inMountNamespace=True,
                         inPIDNamespace=True,
                         inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(router_name, ip=nc_loopback(router_name))

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': self.quaggaBaseConfigPath + router_name}
            self.addNodeService(node=router_name,
                                service=self.quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # print self.quaggaBaseConfigPath + router_name

        # Create the normal host connected to the routers
        for host_name in nc_hosts('i2'):
            info("\tAdding hosts %s\n" % (host_name))
            self.addHost(name=host_name,
                         hostname=host_name,
                         privateLogDir=True,
                         privateRunDir=True,
                         inMountNamespace=True,
                         inPIDNamespace=True,
                         inUTSNamespace=True)
예제 #18
0
    def __init__(self):
        """Initialize a Quagga topology with 4 routers and 2 hosts, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        # quaggaHosts.append(QuaggaHost(name='S1', ip='192.168.1.2/24',
        #                               loIP='127.0.0.1', mac = 'aa:aa:aa:aa:aa:aa'))
        # quaggaHosts.append(QuaggaHost(name='CA', ip='192.168.1.1/26',
        #                               loIP='127.0.0.1', mac = 'bb:bb:bb:bb:bb:bb'))
        # quaggaHosts.append(QuaggaHost(name='H2', ip='192.168.1.64/26',
        #                               loIP='127.0.0.1', mac = 'cc:cc:cc:cc:cc:cc'))
        # quaggaHosts.append(QuaggaHost(name='Target', ip='192.168.1.128/26',
        #                               loIP='127.0.0.1', mac = 'dd:dd:dd:dd:dd:dd'))
        # quaggaHosts.append(QuaggaHost(name='H4', ip='192.168.1.192/26',
        #                               loIP='127.0.0.1', mac = 'ee:ee:ee:ee:ee:ee'))

        quaggaHosts.append(
            QuaggaHost(name='S1',
                       ip='192.168.1.2/24',
                       loIP='127.0.0.1',
                       mac='aa:aa:aa:aa:aa:aa'))
        quaggaHosts.append(
            QuaggaHost(name='CA',
                       ip='192.168.1.1/24',
                       loIP='127.0.0.1',
                       mac='bb:bb:bb:bb:bb:bb'))
        quaggaHosts.append(
            QuaggaHost(name='Victim',
                       ip='192.168.1.64/24',
                       loIP='127.0.0.1',
                       mac='cc:cc:cc:cc:cc:cc'))
        quaggaHosts.append(
            QuaggaHost(name='Target',
                       ip='192.168.1.128/24',
                       loIP='127.0.0.1',
                       mac='dd:dd:dd:dd:dd:dd'))
        quaggaHosts.append(
            QuaggaHost(name='Attacker',
                       ip='192.168.1.192/24',
                       loIP='127.0.0.1',
                       mac='ee:ee:ee:ee:ee:ee'))

        hostDict = dict()

        # Setup each Quagga router, add a link between it
        for host in quaggaHosts:

            if host.name == 'S1':
                # Create an instance of a host, called a quaggaContainer
                quaggaContainer = self.addSwitch(name=host.name,
                                                 ip=host.ip,
                                                 mac=host.mac,
                                                 hostname=host.name,
                                                 privateLogDir=True,
                                                 privateRunDir=True,
                                                 inMountNamespace=True,
                                                 inPIDNamespace=True,
                                                 inUTSNamespace=True)
            else:
                # Create an instance of a host, called a quaggaContainer
                quaggaContainer = self.addHost(name=host.name,
                                               ip=host.ip,
                                               mac=host.mac,
                                               hostname=host.name,
                                               privateLogDir=True,
                                               privateRunDir=True,
                                               inMountNamespace=True,
                                               inPIDNamespace=True,
                                               inUTSNamespace=True)

            hostDict[host.name] = quaggaContainer

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

        # CA <-> S1
        self.addLink(hostDict["S1"], hostDict["CA"])
        # R1 <-> Victim
        self.addLink(hostDict["S1"], hostDict["Victim"])
        # S1 <-> Target
        self.addLink(hostDict["S1"], hostDict["Target"])
        # S1 <-> Attacker
        self.addLink(hostDict["S1"], hostDict["Attacker"])
예제 #19
0
파일: topo.py 프로젝트: arsheth/mininet
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
	h1 = self.addHost('h1', cls=QuaggaHost,ip='150.100.1.11/24',route='150.100.1.254')
#	print self
#	self.cmd('h1 route add deault gw 150.100.1.254') 
	h2 = self.addHost('h2', cls=QuaggaHost,ip='150.100.2.12/24', route='150.100.2.254')
#	h2.cmd('route add default gw 150.100.2.254')

	eth0 = { 'mac' : '00:00:00:01:01',
		 'ipAddrs' : ['150.100.1.254/24'] }
	eth1 = { 'ipAddrs' : ['172.16.1.1/24'] }
	eth2 = { 'ipAddrs' : ['172.16.2.1/24'] }
	intfs =  { 'r1-eth0': eth0,
		   'r1-eth1': eth1,
		   'r1-eth2': eth2}
	quaggaConf = '%s/quagga1.conf' % (CONFIG_DIR)
	dests = ['150.100.2.0','150.100.2.0']
	gws = ['172.16.1.254','172.16.2.254']
	ports = ['r1-eth1','r1-eth2']
	r1 = self.addHost('r1', cls=Router, quaggaConfFile=quaggaConf,intfDict = intfs) #, dests=dests,gws=gws,ports=ports)
#	r1.cmd('route add -net 150.100.2.0 gw 172.16.1.254 netmask 255.255.255.0 r1-eth1')	
#	r1.cmd('route add -net 150.100.2.0 gw 172.16.2.254 netmask 255.255.255.0 r1-eth2')
	
	eth0 = { 'mac' : '00:00:00:02:01',
		 'ipAddrs' : ['172.16.1.254/24'] }
	eth1 = { 'ipAddrs' : ['172.16.3.1/24'] }
	intfs =  { 'r2-eth0': eth0,
		   'r2-eth1': eth1}
	quaggaConf = '%s/quagga2.conf' % (CONFIG_DIR)
	
	dests = ['150.100.2.0','150.100.1.0']
	gws = ['172.16.3.254','172.16.1.1']
	ports = ['r2-eth1','r2-eth0']
	r2 = self.addHost('r2', cls=Router, quaggaConfFile=quaggaConf,intfDict = intfs) #,dests=dests,gws=gws,ports=ports)
#	r2.cmd('route add -net 150.100.2.0 gw 172.16.3.254 netmask 255.255.255.0 r2-eth1')
#	r2.cmd('route add -net 150.100.1.0 gw 172.16.1.1 netmask 255.255.255.0 r2-eth0')
	
	
	eth0 = { 'mac' : '00:00:00:03:01',
		 'ipAddrs' : ['172.16.2.254/24'] }
	eth1 = { 'ipAddrs' : ['172.16.4.1/24'] }
	intfs =  { 'r3-eth0': eth0,
		   'r3-eth1': eth1}
	quaggaConf = '%s/quagga3.conf' % (CONFIG_DIR)
	
	dests = ['150.100.2.0','150.100.1.0']
	gws = ['172.16.4.254','172.16.2.1']
	ports = ['r3-eth1','r3-eth0']
	r3 = self.addHost('r3', cls=Router,quaggaConfFile=quaggaConf,intfDict = intfs)#,dests=dests,gws=gws,ports=ports)
	#r3.cmd('route add -net 150.100.2.0 gw 172.16.4.254 netmask 255.255.255.0 r3-eth1')
	#r3.cmd('route add -net 150.100.1.0 gw 172.16.2.1 netmask 255.255.255.0 r3-eth0')
	
	
	eth1 = { 'ipAddrs' : ['172.16.4.254/24'] }
	eth0 = { 'mac' : '00:00:00:04:01',
		 'ipAddrs' : ['172.16.3.254/24'] }
	eth2 = { 'ipAddrs' : ['150.100.2.254/24'] }
	intfs =  { 'r4-eth0': eth0,
		   'r4-eth1': eth1,
		   'r4-eth2': eth2}
	quaggaConf = '%s/quagga4.conf' % (CONFIG_DIR)
#	dests = ['150.100.1.0','150.100.1.0']
#	gws = ['172.16.2.1','172.16.4.1']
#	ports = ['r4-eth0','r4-eth1']
	r4 = self.addHost('r4', cls=Router,quaggaConfFile=quaggaConf,intfDict = intfs) #,dests=dests,gws=gws,ports=ports)
	#r4.cmd('route add -net 150.100.1.0 gw 172.16.2.1 netmask 255.255.255.0 r4-eth0')
	#r4.cmd('route add -net 150.100.1.0 gw 172.16.4.1 netmask 255.255.255.0 r4-eth1')
	
	
	'''
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='h1', ip='192.168.1.1/24',
                                     loIP = '127.0.0.1'))
        quaggaHosts.append(QuaggaHost(name='h2', ip='192.168.2.100/16',
                                      loIP='127.0.0.1'))
        quaggaHosts.append(QuaggaHost(name='r1'))
        quaggaHosts.append(QuaggaHost(name='r2'))
        quaggaHosts.append(QuaggaHost(name='r3'))
        quaggaHosts.append(QuaggaHost(name='r4'))
	'''
	self.addLink(h1,r1)
	self.addLink(r1,r2)
	self.addLink(r1,r3)
	self.addLink(r2,r4)
	self.addLink(r3,r4)
	self.addLink(r4,h2)
예제 #20
0
    def __init__(self):
        """Initialize a Quagga topology with 4 routers and 2 hosts, 
           configure their IP addresses, loop back interfaces, 
           and paths to their private configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='r1',
                       ip='172.0.1.2/24',
                       loIP='10.0.1.1/24',
                       type='host'))
        quaggaHosts.append(
            QuaggaHost(name='r2',
                       ip='172.0.2.2/24',
                       loIP='10.0.2.1/24',
                       type='host'))
        quaggaHosts.append(
            QuaggaHost(name='r3',
                       ip='172.0.3.2/24',
                       loIP='10.0.3.1/24',
                       type='host'))
        quaggaHosts.append(
            QuaggaHost(name='r4',
                       ip='172.0.4.2/24',
                       loIP='10.0.4.1/24',
                       type='host'))

        quaggaHosts.append(
            QuaggaHost(name='h1',
                       ip='172.0.1.1/24',
                       loIP='10.0.1.1/24',
                       type='host'))
        quaggaHosts.append(
            QuaggaHost(name='h2',
                       ip='172.0.6.2/24',
                       loIP='10.0.6.1/24',
                       type='host'))

        # Add switch for IXP fabric
        #ixpfabric = self.addSwitch('fabric-sw1')

        containers = []

        # Setup each Quagga router
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            if host.type == 'host':
                quaggaContainer = self.addHost(name=host.name,
                                               ip=host.ip,
                                               hostname=host.name,
                                               privateLogDir=True,
                                               privateRunDir=True,
                                               inMountNamespace=True,
                                               inPIDNamespace=True,
                                               inUTSNamespace=True)
            else:
                quaggaContainer = self.addSwitch(name=host.name,
                                                 ip=host.ip,
                                                 hostname=host.name,
                                                 privateLogDir=True,
                                                 privateRunDir=True,
                                                 inMountNamespace=True,
                                                 inPIDNamespace=True,
                                                 inUTSNamespace=True)

            containers.append(quaggaContainer)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

        # Attach the quaggaContainer to the IXP Fabric Switch
        #self.addLink(quaggaContainer, ixpfabric)

# Manually assign links
        self.addLink(containers[0], containers[4])
        self.addLink(containers[0], containers[1])
        self.addLink(containers[0], containers[2])
        self.addLink(containers[1], containers[3])
        self.addLink(containers[2], containers[3])
        self.addLink(containers[3], containers[5])
예제 #21
0
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/configs/'

        "List of Quagga host configs"
        quaggaHosts = []
        ## AS A
        quaggaHosts.append(QuaggaHost(name = 'a1', ip = '172.0.0.1/16', mac = '08:00:27:89:3b:9f', sdx = 1, sdx_port = 1))
        ## AS B
        quaggaHosts.append(QuaggaHost(name = 'b1', ip = '172.0.0.2/16', mac = '08:00:27:92:18:1f', sdx = 1, sdx_port = 2))
        ## AS C
        quaggaHosts.append(QuaggaHost(name = 'c1', ip = '172.0.0.3/16', mac = '08:00:27:54:56:ea', sdx = 1, sdx_port = 3))
        ## AS D
        quaggaHosts.append(QuaggaHost(name = 'd1', ip = '172.255.0.1/16', mac = '08:00:27:bd:f8:b2', sdx = 2, sdx_port = 1))
        ## AS E
        quaggaHosts.append(QuaggaHost(name = 'e1', ip = '172.255.0.2/16', mac = '08:00:27:11:ff:aa', sdx = 2, sdx_port = 2))
        ## AS F
        quaggaHosts.append(QuaggaHost(name = 'f1', ip = '172.255.0.3/16', mac = '08:00:27:22:3b:34', sdx = 2, sdx_port = 3))
        ## AS X
        quaggaHosts.append(QuaggaHost(name = 'x1', ip = '172.2.0.2/16', mac = None, sdx = 0, sdx_port = 0))
        ## AS Z
        quaggaHosts.append(QuaggaHost(name = 'z1', ip = '172.1.0.2/16', mac = None, sdx = 0, sdx_port = 0))

        ## SDX 1
        "Add switch for fabric of SDX 1"
        sdx1_fabric = self.addSwitch( 's1' )

        " Add root node for route server of SDX 1 - exaBGP - and connect it to the fabric. "
        sdx1_rs = self.addHost('rs1', ip = '172.0.255.254/16', inNamespace = False)
        self.addLink(sdx1_rs, sdx1_fabric, port2 = 4)

        ## SDX 2
        "Add switch for fabric of SDX 2"
        sdx2_fabric = self.addSwitch( 's2' )

        " Add root node for route server of SDX 2 - exaBGP - and connect it to the fabric. "
        sdx2_rs = self.addHost('rs2', ip = '172.255.255.254/16', inNamespace = False)
        self.addLink(sdx2_rs, sdx2_fabric, port2 = 4)
   
        ## AS Border Routers
        "Setup each legacy router, add a link between it and the IXP fabric"
        routers = {}

        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + host.name }

            routers[host.name] = self.addHost( name=host.name,
                                              ip=host.ip,
					      mac=host.mac,
                                              privateLogDir=True,
                                              privateRunDir=True,
                                              inMountNamespace=True,
                                              inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            if (host.sdx == 1):
                self.addLink( routers[host.name], sdx1_fabric , port1=0, port2=host.sdx_port)
            elif (host.sdx == 2):
                self.addLink( routers[host.name], sdx2_fabric , port1=0, port2=host.sdx_port)

        "Connect border routers"
        # A -- Z
        self.addLink( routers['a1'], routers['z1'] , port1=1, port2=0)
        # Z -- D
        self.addLink( routers['d1'], routers['z1'] , port1=1, port2=1)
        # B -- X
        self.addLink( routers['b1'], routers['x1'] , port1=1, port2=0)
        # E -- X
        self.addLink( routers['e1'], routers['x1'] , port1=1, port2=1)
        # C -- F
        self.addLink( routers['c1'], routers['f1'] , port1=1, port2=1)
예제 #22
0
    def __init__(self):

        "Initialize topology"
        Topo.__init__(self)

        # location of config dir
        configdir = os.path.abspath(sys.argv[1])

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath = configdir

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(
            QuaggaHost(name='a1',
                       ip='172.0.0.1/16',
                       mac='08:00:27:89:3b:9f',
                       port=3))
        quaggaHosts.append(
            QuaggaHost(name='b1',
                       ip='172.0.0.11/16',
                       mac='08:00:27:92:18:1f',
                       port=4))
        quaggaHosts.append(
            QuaggaHost(name='c1',
                       ip='172.0.0.21/16',
                       mac='08:00:27:54:56:ea',
                       port=5))
        quaggaHosts.append(
            QuaggaHost(name='c2',
                       ip='172.0.0.22/16',
                       mac='08:00:27:bd:f8:b2',
                       port=6))

        "Add switch for IXP fabric"
        main_switch = self.addSwitch('s1')
        arp_switch = self.addSwitch('s2')
        self.addLink(main_switch, arp_switch, 1, 1)

        # Add node for central Route Server"
        route_server = self.addHost('x1',
                                    ip='172.0.255.254/16',
                                    mac='08:00:27:89:3b:ff',
                                    inNamespace=False)
        self.addLink(main_switch, route_server, 2)

        # Add node for ARP Proxy"
        arp_proxy = self.addHost('x2',
                                 ip='172.0.255.253/16',
                                 mac='08:00:27:89:33:ff',
                                 inNamespace=False)
        self.addLink(arp_switch, arp_proxy, 2)

        "Setup each legacy router, add a link between it and the IXP fabric"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : os.path.join(configdir, host.name) }

            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           mac=host.mac,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True)
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            self.addLink(quaggaContainer, main_switch, port2=host.port)
예제 #23
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []
        

        # Add switch for IXP fabric
        #ixpfabric = self.addSwitch('fabric-sw1')

	H1 = QuaggaHost(name='h1', ip='172.0.1.1/24', loIP='10.0.1.1/24')
	R1 = QuaggaHost(name='r1', ip='172.0.1.2/24', loIP='10.0.1.2/24')
	H2 = QuaggaHost(name='h2', ip='172.0.6.2/24', loIP='10.0.6.2/24')
	R4 = QuaggaHost(name='r4', ip='172.0.4.2/24', loIP='10.0.4.2/24')
	R2 = QuaggaHost(name='r2', ip='172.0.2.2/24', loIP='10.0.2.2/24')
	R3 = QuaggaHost(name='r3', ip='172.0.3.2/24', loIP='10.0.3.2/24')

	quaggaHosts.append(H1)
	quaggaHosts.append(R1)
	quaggaHosts.append(H2)
	quaggaHosts.append(R4)
	quaggaHosts.append(R2)
	quaggaHosts.append(R3)
	
	quaggaNodes = []

        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)
		
	    quaggaNodes.append(quaggaContainer);

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # Attach the quaggaContainer to the IXP Fabric Switch
            #self.addLink(quaggaContainer, ixpfabric)

	
	self.addLink(quaggaNodes[0], quaggaNodes[1], intfName1='h1-eth0', params1={'ip':'172.0.1.1/24'}, intfName2='r1-eth0', params2={'ip':'172.0.1.2/24'})

	self.addLink(quaggaNodes[1],quaggaNodes[4], intfName1='r1-eth1', params1={'ip':'172.0.2.1/24'}, intfName2='r2-eth0', params2={'ip':'172.0.2.2/24'})
	self.addLink(quaggaNodes[1],quaggaNodes[5], intfName1='r1-eth2', params1={'ip':'172.0.3.1/24'}, intfName2='r3-eth0', params2={'ip':'172.0.3.2/24'})

	self.addLink(quaggaNodes[4],quaggaNodes[3], intfName1='r2-eth1', params1={'ip':'172.0.4.1/24'}, intfName2='r4-eth0', params2={'ip':'172.0.4.2/24'})

	self.addLink(quaggaNodes[5],quaggaNodes[3], intfName1='r3-eth1', params1={'ip':'172.0.5.1/24'}, intfName2='r4-eth1', params2={'ip':'172.0.5.2/24'})
	
	self.addLink(quaggaNodes[2],quaggaNodes[3], intfName1='h2-eth0', params1={'ip':'172.0.6.2/24'}, intfName2='r4-eth2', params2={'ip':'172.0.6.1/24'})
예제 #24
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure
           their IP addresses, loop back interfaces, and paths to
           their private configuration directories. Also start a redis
           sever at IP address 172.1.1.1.  Chain topology is A -> B ->
           C -> D -> E."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)
        #       redisSvc = RedisService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'
        #        redisBaseConfigPath = selfPath + '/configs/'

        # Add switch for IXP fabric
        ixpfabricA = self.addSwitch('fabric-sw1')
        ixpfabricB = self.addSwitch('fabric-sw2')
        ixpfabricC = self.addSwitch('fabric-sw3')

        self.addLink(ixpfabricA, ixpfabricB)
        self.addLink(ixpfabricB, ixpfabricC)

        # List of Quagga host configs
        quaggaHosts = []
        # 0
        quaggaHosts.append(
            QuaggaHost(name='a1',
                       ip='172.0.1.1/8',
                       loIP='10.0.1.1/24',
                       switch=ixpfabricA))
        quaggaHosts.append(
            QuaggaHost(name='a2',
                       ip='172.0.2.1/8',
                       loIP='10.0.2.1/24',
                       switch=ixpfabricA))
        # 2
        quaggaHosts.append(
            QuaggaHost(name='b1',
                       ip='172.1.1.1/8',
                       loIP='10.1.1.1/24',
                       switch=ixpfabricB))
        quaggaHosts.append(
            QuaggaHost(name='b2',
                       ip='172.1.2.1/8',
                       loIP='10.1.2.1/24',
                       switch=ixpfabricB))
        quaggaHosts.append(
            QuaggaHost(name='b3',
                       ip='172.1.3.1/8',
                       loIP='10.1.3.1/24',
                       switch=ixpfabricB))
        quaggaHosts.append(
            QuaggaHost(name='b4',
                       ip='172.1.4.1/8',
                       loIP='10.1.4.1/24',
                       switch=ixpfabricB))
        quaggaHosts.append(
            QuaggaHost(name='b5',
                       ip='172.1.5.1/8',
                       loIP='10.1.5.1/24',
                       switch=ixpfabricB))
        # 7
        quaggaHosts.append(
            QuaggaHost(name='c1',
                       ip='172.2.1.1/8',
                       loIP='10.2.1.1/24',
                       switch=ixpfabricC))
        quaggaHosts.append(
            QuaggaHost(name='c2',
                       ip='172.2.2.1/8',
                       loIP='10.2.2.1/24',
                       switch=ixpfabricC))
        quaggaHosts.append(
            QuaggaHost(name='c3',
                       ip='172.2.3.1/8',
                       loIP='10.2.3.1/24',
                       switch=ixpfabricC))
        quaggaHosts.append(
            QuaggaHost(name='c4',
                       ip='172.2.4.1/8',
                       loIP='10.2.4.1/24',
                       switch=ixpfabricC))

        loadHosts = []

        # load generators
        # (no)

        #        testHost = self.addHost(name='test')

        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # Attach the quaggaContainer to the IXP Fabric Switch
            self.addLink(host.switch, quaggaContainer)
예제 #25
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = []

        # Add switch for IXP fabric
        #ixpfabric = self.addSwitch('fabric-sw1')

        H1 = QuaggaHost(name='h1', ip='172.0.1.1/24', loIP='10.0.1.1/24')
        R1 = QuaggaHost(name='r1', ip='172.0.1.2/24', loIP='10.0.1.2/24')
        H2 = QuaggaHost(name='h2', ip='172.0.6.2/24', loIP='10.0.6.2/24')
        R4 = QuaggaHost(name='r4', ip='172.0.4.2/24', loIP='10.0.4.2/24')
        R2 = QuaggaHost(name='r2', ip='172.0.2.2/24', loIP='10.0.2.2/24')
        R3 = QuaggaHost(name='r3', ip='172.0.3.2/24', loIP='10.0.3.2/24')

        quaggaHosts.append(H1)
        quaggaHosts.append(R1)
        quaggaHosts.append(H2)
        quaggaHosts.append(R4)
        quaggaHosts.append(R2)
        quaggaHosts.append(R3)

        quaggaNodes = []

        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            quaggaNodes.append(quaggaContainer)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            # Attach the quaggaContainer to the IXP Fabric Switch
            #self.addLink(quaggaContainer, ixpfabric)

        self.addLink(quaggaNodes[0],
                     quaggaNodes[1],
                     intfName1='h1-eth0',
                     params1={'ip': '172.0.1.1/24'},
                     intfName2='r1-eth0',
                     params2={'ip': '172.0.1.2/24'})

        self.addLink(quaggaNodes[1],
                     quaggaNodes[4],
                     intfName1='r1-eth1',
                     params1={'ip': '172.0.2.1/24'},
                     intfName2='r2-eth0',
                     params2={'ip': '172.0.2.2/24'})
        self.addLink(quaggaNodes[1],
                     quaggaNodes[5],
                     intfName1='r1-eth2',
                     params1={'ip': '172.0.3.1/24'},
                     intfName2='r3-eth0',
                     params2={'ip': '172.0.3.2/24'})

        self.addLink(quaggaNodes[4],
                     quaggaNodes[3],
                     intfName1='r2-eth1',
                     params1={'ip': '172.0.4.1/24'},
                     intfName2='r4-eth0',
                     params2={'ip': '172.0.4.2/24'})

        self.addLink(quaggaNodes[5],
                     quaggaNodes[3],
                     intfName1='r3-eth1',
                     params1={'ip': '172.0.5.1/24'},
                     intfName2='r4-eth1',
                     params2={'ip': '172.0.5.2/24'})

        self.addLink(quaggaNodes[2],
                     quaggaNodes[3],
                     intfName1='h2-eth0',
                     params1={'ip': '172.0.6.2/24'},
                     intfName2='r4-eth2',
                     params2={'ip': '172.0.6.1/24'})
예제 #26
0
	def __init__(self):
		"""Initialize a Quagga topology with 2 hosts, 5 routers, 7 switches, quagga service, in a topology according to
	Fig 1. of Lab4"""
		Topo.__init__(self)

		info( '*** Creating Quagga Routers\n' )
		# Absolute path to this python script
		selfPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))

		# Initialize the Quagga Service
		# autoStart=True (default) --> starts automatically quagga on the host
		# autoStop=True (default) --> stops automatically quagga (we don't want this)
		quaggaSvc = QuaggaService(autoStart=True, autoStop=False) 

		# Configuration file path for quagga routers
		# We require a "config" folder in the same path of the lab4_topo file, and within
		# the config folder, we require one folder for each host, named as the host itself.
		# with the corresponding daemons, zebra.conf, ripd.conf and ripngd.conf files
		quaggaBaseConfigPath = selfPath + '/configs/'

		# Initializing local variables
		netHosts = []
		NodeList = []

		# List of all hosts in the network.
		# Note that each node requires at least one IP address to avoid
		# Mininet's automatic IP address assignment
		netHosts.append(NetworkHosts(name='h1', IP='10.10.11.10/24', DG='via 10.10.11.1'))
		netHosts.append(NetworkHosts(name='h2', IP='10.10.22.20/24', DG='via 10.10.22.2'))
		netHosts.append(NetworkHosts(name='r1', IP='10.10.11.1/24', DG=''))
		netHosts.append(NetworkHosts(name='r2', IP='10.10.12.2/24', DG=''))
		netHosts.append(NetworkHosts(name='r3', IP='10.10.23.3/24', DG=''))
		netHosts.append(NetworkHosts(name='r4', IP='10.10.14.4/24', DG=''))
		netHosts.append(NetworkHosts(name='r5', IP='10.10.25.5/24', DG=''))

		for host in netHosts:
			# We create a list of node names
			NodeList.append(host.name)
			if host.name in ['h1','h2']:
				# We configure PCs with default gateway and without quagga service
				AddPCHost = self.addHost(name=host.name, ip=host.IP, defaultRoute=host.DG, hostname=host.name,  privateLogDir=True, privateRunDir=True, inMountNamespace=True, inPIDNamespace=True, inUTSNamespace=True)
			else :
				# We configure routers with quagga service without default gateway
				AddQuaggaHost = self.addHost(name=host.name, ip=host.IP, hostname=host.name,  privateLogDir=True, privateRunDir=True, inMountNamespace=True, inPIDNamespace=True, inUTSNamespace=True)
				# We setup Quagga service and path to config files
				# Note that we require one folder for each host, named as the host itself
				quaggaSvcConfig = {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
				self.addNodeService(node=host.name, service=quaggaSvc, nodeConfig=quaggaSvcConfig)

		# Adding switches to the network, we specify OpenFlow v1.3 for better IPv6 multicast support
		SW1 = self.addSwitch('SW1', protocols='OpenFlow13')
		SW2 = self.addSwitch('SW2', protocols='OpenFlow13')
		SW3 = self.addSwitch('SW3', protocols='OpenFlow13')
		SW4 = self.addSwitch('SW4', protocols='OpenFlow13')
		SW5 = self.addSwitch('SW5', protocols='OpenFlow13')
		SW6 = self.addSwitch('SW6', protocols='OpenFlow13')
		SW7 = self.addSwitch('SW7', protocols='OpenFlow13')
		SW8 = self.addSwitch('SW8', protocols='OpenFlow13')
		# We add links between switches and routers according to Fig.1 of Lab 4
		info( '*** Creating links\n' )
		self.addLink( SW1, NodeList[0], intfName2='h1-eth1'  )
		self.addLink( SW1, NodeList[2], intfName2='r1-eth3'  )

		self.addLink( SW2, NodeList[2], intfName2='r1-eth1'  )
		self.addLink( SW2, NodeList[3], intfName2='r2-eth1'  )

		self.addLink( SW3, NodeList[3], intfName2='r2-eth2'  )
		self.addLink( SW3, NodeList[4], intfName2='r3-eth1'  )

		self.addLink( SW4, NodeList[2], intfName2='r1-eth2'  )
		self.addLink( SW4, NodeList[5], intfName2='r4-eth1'  )

		self.addLink( SW5, NodeList[3], intfName2='r2-eth3'  )
		self.addLink( SW5, NodeList[6], intfName2='r5-eth1'  )

		self.addLink( SW6, NodeList[5], intfName2='r4-eth2'  )
		self.addLink( SW6, NodeList[6], intfName2='r5-eth3'  )

		self.addLink( SW7, NodeList[4], intfName2='r3-eth2'  )
		self.addLink( SW7, NodeList[6], intfName2='r5-eth2'  )

		self.addLink( SW8, NodeList[3], intfName2='r2-eth4'  )
		self.addLink( SW8, NodeList[1], intfName2='h2-eth1'  )
예제 #27
0
파일: topo.py 프로젝트: arsheth/mininet
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        h1 = self.addHost('h1',
                          cls=QuaggaHost,
                          ip='150.100.1.11/24',
                          route='150.100.1.254')
        #	print self
        #	self.cmd('h1 route add deault gw 150.100.1.254')
        h2 = self.addHost('h2',
                          cls=QuaggaHost,
                          ip='150.100.2.12/24',
                          route='150.100.2.254')
        #	h2.cmd('route add default gw 150.100.2.254')

        eth0 = {'mac': '00:00:00:01:01', 'ipAddrs': ['150.100.1.254/24']}
        eth1 = {'ipAddrs': ['172.16.1.1/24']}
        eth2 = {'ipAddrs': ['172.16.2.1/24']}
        intfs = {'r1-eth0': eth0, 'r1-eth1': eth1, 'r1-eth2': eth2}
        quaggaConf = '%s/quagga1.conf' % (CONFIG_DIR)
        dests = ['150.100.2.0', '150.100.2.0']
        gws = ['172.16.1.254', '172.16.2.254']
        ports = ['r1-eth1', 'r1-eth2']
        r1 = self.addHost('r1',
                          cls=Router,
                          quaggaConfFile=quaggaConf,
                          intfDict=intfs)  #, dests=dests,gws=gws,ports=ports)
        #	r1.cmd('route add -net 150.100.2.0 gw 172.16.1.254 netmask 255.255.255.0 r1-eth1')
        #	r1.cmd('route add -net 150.100.2.0 gw 172.16.2.254 netmask 255.255.255.0 r1-eth2')

        eth0 = {'mac': '00:00:00:02:01', 'ipAddrs': ['172.16.1.254/24']}
        eth1 = {'ipAddrs': ['172.16.3.1/24']}
        intfs = {'r2-eth0': eth0, 'r2-eth1': eth1}
        quaggaConf = '%s/quagga2.conf' % (CONFIG_DIR)

        dests = ['150.100.2.0', '150.100.1.0']
        gws = ['172.16.3.254', '172.16.1.1']
        ports = ['r2-eth1', 'r2-eth0']
        r2 = self.addHost('r2',
                          cls=Router,
                          quaggaConfFile=quaggaConf,
                          intfDict=intfs)  #,dests=dests,gws=gws,ports=ports)
        #	r2.cmd('route add -net 150.100.2.0 gw 172.16.3.254 netmask 255.255.255.0 r2-eth1')
        #	r2.cmd('route add -net 150.100.1.0 gw 172.16.1.1 netmask 255.255.255.0 r2-eth0')

        eth0 = {'mac': '00:00:00:03:01', 'ipAddrs': ['172.16.2.254/24']}
        eth1 = {'ipAddrs': ['172.16.4.1/24']}
        intfs = {'r3-eth0': eth0, 'r3-eth1': eth1}
        quaggaConf = '%s/quagga3.conf' % (CONFIG_DIR)

        dests = ['150.100.2.0', '150.100.1.0']
        gws = ['172.16.4.254', '172.16.2.1']
        ports = ['r3-eth1', 'r3-eth0']
        r3 = self.addHost('r3',
                          cls=Router,
                          quaggaConfFile=quaggaConf,
                          intfDict=intfs)  #,dests=dests,gws=gws,ports=ports)
        #r3.cmd('route add -net 150.100.2.0 gw 172.16.4.254 netmask 255.255.255.0 r3-eth1')
        #r3.cmd('route add -net 150.100.1.0 gw 172.16.2.1 netmask 255.255.255.0 r3-eth0')

        eth1 = {'ipAddrs': ['172.16.4.254/24']}
        eth0 = {'mac': '00:00:00:04:01', 'ipAddrs': ['172.16.3.254/24']}
        eth2 = {'ipAddrs': ['150.100.2.254/24']}
        intfs = {'r4-eth0': eth0, 'r4-eth1': eth1, 'r4-eth2': eth2}
        quaggaConf = '%s/quagga4.conf' % (CONFIG_DIR)
        #	dests = ['150.100.1.0','150.100.1.0']
        #	gws = ['172.16.2.1','172.16.4.1']
        #	ports = ['r4-eth0','r4-eth1']
        r4 = self.addHost('r4',
                          cls=Router,
                          quaggaConfFile=quaggaConf,
                          intfDict=intfs)  #,dests=dests,gws=gws,ports=ports)
        #r4.cmd('route add -net 150.100.1.0 gw 172.16.2.1 netmask 255.255.255.0 r4-eth0')
        #r4.cmd('route add -net 150.100.1.0 gw 172.16.4.1 netmask 255.255.255.0 r4-eth1')
        '''
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='h1', ip='192.168.1.1/24',
                                     loIP = '127.0.0.1'))
        quaggaHosts.append(QuaggaHost(name='h2', ip='192.168.2.100/16',
                                      loIP='127.0.0.1'))
        quaggaHosts.append(QuaggaHost(name='r1'))
        quaggaHosts.append(QuaggaHost(name='r2'))
        quaggaHosts.append(QuaggaHost(name='r3'))
        quaggaHosts.append(QuaggaHost(name='r4'))
	'''
        self.addLink(h1, r1)
        self.addLink(r1, r2)
        self.addLink(r1, r3)
        self.addLink(r2, r4)
        self.addLink(r3, r4)
        self.addLink(r4, h2)
예제 #28
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        zebraConf = '%s/zebra.conf' % CONFIG_DIR

        #Adding Host 1
        h1 = self.addHost('h1',
                          cls=MyHost,
                          ip='192.168.1.1/24',
                          route='192.168.1.12')

        #Adding Host 2
        h2 = self.addHost('h2',
                          cls=MyHost,
                          ip='192.168.6.12/24',
                          route='192.168.6.1')

        #Adding Router 1
        eth0 = {'ipAddrs': ['192.168.1.12/24']}
        eth1 = {'ipAddrs': ['192.168.2.1/24']}
        eth2 = {'ipAddrs': ['192.168.4.1/24']}

        intfs = {'r1-eth0': eth0, 'r1-eth1': eth1, 'r1-eth2': eth2}

        quaggaConf = '%s/quagga1.conf' % CONFIG_DIR

        r1 = self.addHost('r1',
                          cls=MyRouter,
                          quaggaConfFile=quaggaConf,
                          zebraConfFile=zebraConf,
                          intfDict=intfs)

        #Adding Router 2
        eth0 = {'ipAddrs': ['192.168.2.12/24']}
        eth1 = {'ipAddrs': ['192.168.3.1/24']}

        intfs = {'r2-eth0': eth0, 'r2-eth1': eth1}

        quaggaConf = '%s/quagga2.conf' % CONFIG_DIR

        r2 = self.addHost('r2',
                          cls=MyRouter,
                          quaggaConfFile=quaggaConf,
                          zebraConfFile=zebraConf,
                          intfDict=intfs)

        #Adding Router 3
        eth0 = {'ipAddrs': ['192.168.4.12/24']}
        eth1 = {'ipAddrs': ['192.168.5.1/24']}

        intfs = {'r3-eth0': eth0, 'r3-eth1': eth1}

        quaggaConf = '%s/quagga3.conf' % CONFIG_DIR

        r3 = self.addHost('r3',
                          cls=MyRouter,
                          quaggaConfFile=quaggaConf,
                          zebraConfFile=zebraConf,
                          intfDict=intfs)

        #Adding Router 4
        eth0 = {'ipAddrs': ['192.168.3.12/24']}
        eth1 = {'ipAddrs': ['192.168.5.12/24']}
        eth2 = {'ipAddrs': ['192.168.6.1/24']}

        intfs = {'r4-eth0': eth0, 'r4-eth1': eth1, 'r4-eth2': eth2}

        quaggaConf = '%s/quagga4.conf' % CONFIG_DIR

        r4 = self.addHost('r4',
                          cls=MyRouter,
                          quaggaConfFile=quaggaConf,
                          zebraConfFile=zebraConf,
                          intfDict=intfs)

        self.addLink(h1, r1)
        self.addLink(r1, r2)
        self.addLink(r1, r3)
        self.addLink(r2, r4)
        self.addLink(r3, r4)
        self.addLink(r4, h2)
예제 #29
0
    def __init__(self, topo_info, router_lo):
        """Initialize a Quagga topology based on the topology information"""
        Topo.__init__(self)

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = '/root/configs/'

        # Dictionnary used to store the hosts
        quagga_hosts = {}

        normal_hosts = {}

        # Setup each Quagga router
        for router_name in topo_info:
            # Create the quagga hosts
            quagga_hosts[router_name] = self.addHost(name=router_name,
                                                     hostname=router_name,
                                                     privateLogDir=True,
                                                     privateRunDir=True,
                                                     inMountNamespace=True,
                                                     inPIDNamespace=True,
                                                     inUTSNamespace=True)

            # Create the normal host connected to the quagga host above
            normal_hosts[router_name + '-host'] = self.addHost(
                name=router_name + '-host',
                hostname=router_name + '-host',
                privateLogDir=True,
                privateRunDir=True,
                inMountNamespace=True,
                inPIDNamespace=True,
                inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(router_name, ip=router_lo[router_name])

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + router_name}
            self.addNodeService(node=router_name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

            print quaggaBaseConfigPath + router_name

        # Create an open v switch to connect the network to the ouside world
        ovs_switch = self.addSwitch('EBGP_PEER', dpid='1')

        # Connect all the routers to OVS, for potentiel future ebgp sessions
        for router_name in topo_info:
            if router_name != 'HOUS':
                self.addLink(quagga_hosts[router_name],
                             ovs_switch,
                             intfName1=router_name.lower() + "-ovs",
                             intfName2="ebgp_peer")

# Add the management interface to HOUS
        self.addLink(quagga_hosts['HOUS'],
                     ovs_switch,
                     intfName1='hous-mgt-ovs',
                     intfName2='mgt')

        # Setup each link between two Quagga routers
        """links_set = Set()
        i = 0
        for router_name, ngh_list in topo_info.items():
            for ngh_ip in ngh_list:
                ngh = ngh_ip[0]
                print 'Link added between '+str(router_name)+' and '+str(ngh)

                # Make sure to only create one link between two routers
                if ngh+router_name not in links_set:
                    self.addLink(quagga_hosts[router_name], quagga_hosts[ngh], \
                        intfName1=ngh.lower()+str(i), intfName2=router_name.lower()+str(i))
                    links_set.add(router_name+ngh)

            i += 0
        # List of Quagga host configs"""
        """quaggaHosts = []
예제 #30
0
파일: jamtopo.py 프로젝트: anrl/JAMEmulator
    def __init__(self, config):
        Topo.__init__(self)
        checkDupEth(config)
        groups = ["cloud", "fog", "device"]
        nodes = dict()

        for i in groups:
            if (i in config):
                for j in config[i]: 
                    # Check if the CPU resources available to host are restricted
                    cpu = j["cpu"] if "cpu" in j else 1.0
                    if ("ip" in j): 
                        self.addHost(j["name"], ip=ip, cpu=cpu)
                    else:
                        self.addHost(j["name"], cpu=cpu)


        if (not "switch" in config or len(config["switch"]) == 0):
            raise RuntimeError("Topology must have at least one switch")
        else:
            for i in config["switch"]:
                self.addSwitch(i["name"])

        if ("router" in config):
            # Directory where this file / script is located"
            selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory
            # Initialize a service helper for Quagga with default options
            quaggaSvc = QuaggaService(autoStop=False)
            # Path configurations for mounts
            quaggaBaseConfigPath = selfPath + "/configs/"
            
            for i in config["router"]:
                # Create an instance of a host, called a quaggaContainer
                self.addHost(name=i["name"],
                             hostname=i["name"],
                             privateLogDir=True,
                             privateRunDir=True,
                             inMountNamespace=True,
                             inPIDNamespace=True,
                             inUTSNamespace=True)

                # Configure and setup the Quagga service for this node
                quaggaSvcConfig = \
                    {"quaggaConfigPath": quaggaBaseConfigPath + i["name"]}
                self.addNodeService(node=i["name"], service=quaggaSvc,
                                    nodeConfig=quaggaSvcConfig)
        
        if ("link" in config):
            for i in config["link"]:            
                bw = i["bw"] if "bw" in i else 100
                delay = i["delay"] if "delay" in i else "0ms"
                loss = i["loss"] if "loss" in i else 0     

                if isinstance(i["node1"], dict): 
                    name1 = i["node1"]["name"]
                else: 
                    name1 = i["node1"]
                if isinstance(i["node2"], dict): 
                    name2 = i["node2"]["name"]
                else: 
                    name2 = i["node2"]    
                self.addLink(name1, name2, bw=bw, delay=delay, loss=loss)
예제 #31
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(os.path.abspath(
            inspect.getfile(inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

	# Save order of node numeber/order to node name
	h1 = 0
	r1 = 1
	r2 = 2
	r3 = 3
	r4 = 4
	h2 = 5


        # List of Quagga host configs
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(name='h1', ip='10.10.11.1/24',
                                      loIP=None))
	quaggaHosts.append(QuaggaHost(name='r1', ip='10.10.11.2/24',
                                      loIP=None))
        quaggaHosts.append(QuaggaHost(name='r2', ip='10.10.12.2/24',
                                      loIP=None))
        quaggaHosts.append(QuaggaHost(name='r3', ip='10.10.13.2/24',
                                      loIP=None))
        quaggaHosts.append(QuaggaHost(name='r4', ip='10.10.14.2/24',
                                      loIP=None))
        quaggaHosts.append(QuaggaHost(name='h2', ip='10.10.16.2/24',
                                      loIP=None))



	quaggaContainers =[]
        # Setup each Quagga router, add a link between it and the IXP fabric
        for host in quaggaHosts:

            # Create an instance of a host, called a quaggaContainer
            quaggaContainers.append(self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True))


            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

	# Link between h1 r1
        self.addLink(quaggaContainers[h1],quaggaContainers[r1], params1={'ip':'10.10.11.1/24'}, params2={'ip':'10.10.11.2/24'})
        self.addLink(quaggaContainers[r1],quaggaContainers[r2], params1={'ip':'10.10.12.1/24'}, params2={'ip':'10.10.12.2/24'})
        self.addLink(quaggaContainers[r1],quaggaContainers[r3], params1={'ip':'10.10.13.1/24'}, params2={'ip':'10.10.13.2/24'})
        self.addLink(quaggaContainers[r2],quaggaContainers[r4], params1={'ip':'10.10.14.1/24'}, params2={'ip':'10.10.14.2/24'})
        self.addLink(quaggaContainers[h2],quaggaContainers[r4], params1={'ip':'10.10.16.2/24'}, params2={'ip':'10.10.16.1/24'})
        self.addLink(quaggaContainers[r3],quaggaContainers[r4], params1={'ip':'10.10.15.1/24'}, params2={'ip':'10.10.15.2/24'})
예제 #32
0
 def __init__(self, **opts):
     BaseTopo.__init__(self, **opts)
예제 #33
0
파일: topo.py 프로젝트: chuzirui/swift
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs
        quaggaHosts = {}
        #quaggaHosts['r1'] = (QuaggaHost(name='r1', ip='172.0.1.1/16', loIP='10.0.1.1/24'))
        quaggaHosts['r2'] = QuaggaHost(name='r2',
                                       ip='172.0.2.1/16',
                                       loIP='10.0.2.1/24')
        quaggaHosts['r3'] = QuaggaHost(name='r3',
                                       ip='172.0.3.1/16',
                                       loIP='10.0.3.1/24')
        quaggaHosts['r4'] = QuaggaHost(name='r4',
                                       ip='172.0.4.1/16',
                                       loIP='10.0.4.1/24')
        quaggaHosts['r5'] = QuaggaHost(name='r5',
                                       ip='172.0.5.1/16',
                                       loIP='10.0.5.1/24')
        #quaggaHosts['r6'] = (QuaggaHost(name='r6', ip='172.0.6.1/16', loIP='10.0.6.1/24'))

        # Add the switch for the SWIFTED router
        ovs_switch = self.addSwitch('s1', dpid='1')

        # Setup each Quagga router, add a link between it and the IXP fabric
        for name, host in quaggaHosts.iteritems():

            # Create an instance of a host, called a quaggaContainer
            quaggaContainer = self.addHost(name=host.name,
                                           ip=host.ip,
                                           hostname=host.name,
                                           privateLogDir=True,
                                           privateRunDir=True,
                                           inMountNamespace=True,
                                           inPIDNamespace=True,
                                           inUTSNamespace=True)

            # Add a loopback interface with an IP in router's announced range
            self.addNodeLoopbackIntf(node=host.name, ip=host.loIP)

            # Configure and setup the Quagga service for this node
            quaggaSvcConfig = \
                {'quaggaConfigPath': quaggaBaseConfigPath + host.name}
            self.addNodeService(node=host.name,
                                service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)

        r6 = self.addHost(name='r6',
                          ip='172.0.6.1/16',
                          hostname='r6',
                          privateLogDir=True,
                          privateRunDir=True,
                          inMountNamespace=True,
                          inPIDNamespace=True,
                          inUTSNamespace=True)

        r1 = self.addHost(name='r1',
                          ip='172.0.1.1/16',
                          hostname='r1',
                          privateLogDir=True,
                          privateRunDir=True,
                          inMountNamespace=True,
                          inPIDNamespace=True,
                          inUTSNamespace=True)

        # Attach the quaggaContainer to the IXP Fabric Switch
        self.addLink('r1', ovs_switch, intfName1="s1", intfName2='r1-ovs')
        self.addLink('r2', ovs_switch, intfName1="s1", intfName2='r2-ovs')
        self.addLink('r3', ovs_switch, intfName1="s1", intfName2='r3-ovs')
        self.addLink('r4', ovs_switch, intfName1="s1", intfName2='r4-ovs')
예제 #34
0
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/configs/'

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(
                           name = 'r01',
                           ip = '172.0.0.1/16',
                           mac = '08:00:27:89:3b:9f',
                           port = 1))
        quaggaHosts.append(QuaggaHost(
                           name = 'r02',
                           ip = '172.0.0.2/16',
                           mac ='08:00:27:92:18:1f',
                           port = 2))
        quaggaHosts.append(QuaggaHost(
                           name = 'r03',
                           ip = '172.0.0.3/16',
                           mac = '08:00:27:54:56:ea',
                           port = 3))

        "Add switch"
        s1 = self.addSwitch( 's1' )

        "Setup each legacy router"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + host.name }

            quaggaContainer = self.addHost( name=host.name,
                                            ip=host.ip,
                                            mac=host.mac,
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the Switch"
            self.addLink( quaggaContainer, s1 , port2=host.port, bw=1000)

            # Adicionando Roteadores agregados
            a03_config = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a03' }
            a03 = self.addHost( name='a03',
                                        ip='22.0.0.1/24',
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True)
            self.addNodeService(node='a03', service=quaggaSvc,
                            nodeConfig=a03_config)


            if(host.name == 'r02'):
                cli01r02_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'cli01r02' }
                # Adicionando Roteadores agregados
                cli01r02 = self.addHost( name='cli01r02',
                                            ip='10.0.0.2/24',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='cli01r02', service=quaggaSvc,
                                nodeConfig=cli01r02_config)

                a02_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a02' }
                # Adicionando Roteadores agregados
                a02 = self.addHost( name='a02',
                                            ip='11.0.0.2/24',
                                            mac='00:00:11:00:00:02',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='a02', service=quaggaSvc,
                                nodeConfig=a02_config)

                self.addLink(cli01r02, quaggaContainer, bw=1000)
                self.addLink(a02, quaggaContainer, bw=1000)
                self.addLink(a03, a02, bw=1000)

            elif(host.name == 'r01'):
                a01_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a01' }
                # Adicionando Roteadores agregados
                a01 = self.addHost( name='a01',
                                            ip='12.0.0.2/24',
                                            mac='00:00:12:00:00:02',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='a01', service=quaggaSvc,
                                nodeConfig=a01_config)

                self.addLink(a01, quaggaContainer, bw=1000)
                self.addLink(a03, a01, bw=1000)

        " Add root node for ExaBGP. ExaBGP acts as route server "
        root = self.addHost('exabgp', ip='172.0.255.254/16', inNamespace=False)
        self.addLink(root, s1)
예제 #35
0
    def __init__(self):
        """Initialize a Quagga topology with 5 routers, configure their IP
           addresses, loop back interfaces, and paths to their private
           configuration directories."""
        Topo.__init__(self)

        # Directory where this file / script is located"
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # script directory

        # Initialize a service helper for Quagga with default options
        quaggaSvc = QuaggaService(autoStop=False)

        # Path configurations for mounts
        quaggaBaseConfigPath = selfPath + '/configs/'

        # List of Quagga host configs

        router = QuaggaHost(name='r1', ip='192.0.1.1/24', loIP=None)

        quaggaContainer1 = self.addHost(name=router.name,
                                        ip=router.ip,
                                        hostname=router.name,
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True,
                                        inUTSNamespace=True)

        # Add a loopback interface with an IP in router's announced range

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
         {'quaggaConfigPath': quaggaBaseConfigPath + router.name}
        self.addNodeService(node=router.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)

        # Attach the quaggaContainer to the IXP Fabric Switch
        # self.addLink(quaggaContainer, ixpfabric)
        ##########################################################################
        router2 = QuaggaHost(name='r2', ip='192.0.2.1/24', loIP=None)

        quaggaContainer2 = self.addHost(name=router2.name,
                                        ip=router2.ip,
                                        hostname=router2.name,
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True,
                                        inUTSNamespace=True)

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
                {'quaggaConfigPath': quaggaBaseConfigPath + router2.name}
        self.addNodeService(node=router2.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)
        ###############################################################################
        router3 = QuaggaHost(name='r3', ip='192.0.3.1/24', loIP=None)

        quaggaContainer3 = self.addHost(name=router3.name,
                                        ip=router3.ip,
                                        hostname=router3.name,
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True,
                                        inUTSNamespace=True)

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
                {'quaggaConfigPath': quaggaBaseConfigPath + router3.name}
        self.addNodeService(node=router3.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)
        ##########################################################################
        router4 = QuaggaHost(name='r4', ip='192.0.4.1/24', loIP=None)

        quaggaContainer4 = self.addHost(name=router4.name,
                                        ip=router4.ip,
                                        hostname=router4.name,
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True,
                                        inUTSNamespace=True)

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
                {'quaggaConfigPath': quaggaBaseConfigPath + router4.name}
        self.addNodeService(node=router4.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)

        ####################################################################
        host1 = QuaggaHost(name='h1', ip='192.0.1.16/24', loIP=None)

        quaggaContainerh1 = self.addHost(name=host1.name,
                                         ip=host1.ip,
                                         hostname=host1.name,
                                         privateLogDir=True,
                                         privateRunDir=True,
                                         inMountNamespace=True,
                                         inPIDNamespace=True,
                                         inUTSNamespace=True)

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
                {'quaggaConfigPath': quaggaBaseConfigPath + host1.name}
        self.addNodeService(node=host1.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)

        host2 = QuaggaHost(name='h2', ip='192.0.4.16/24', loIP=None)

        quaggaContainerh2 = self.addHost(name=host2.name,
                                         ip=host2.ip,
                                         hostname=host2.name,
                                         privateLogDir=True,
                                         privateRunDir=True,
                                         inMountNamespace=True,
                                         inPIDNamespace=True,
                                         inUTSNamespace=True)

        # Configure and setup the Quagga service for this node
        quaggaSvcConfig= \
                {'quaggaConfigPath': quaggaBaseConfigPath + host2.name}
        self.addNodeService(node=host2.name,
                            service=quaggaSvc,
                            nodeConfig=quaggaSvcConfig)

        self.addLink(quaggaContainerh1, quaggaContainer1)
        self.addLink(quaggaContainerh2, quaggaContainer4)
        self.addLink(quaggaContainer1, quaggaContainer2)
        #self.addLink( quaggaContainer2, quaggaContainer1 )

        self.addLink(quaggaContainer1, quaggaContainer3)
        self.addLink(quaggaContainer4, quaggaContainer3)
        self.addLink(quaggaContainer4, quaggaContainer2)
    def __init__( self ):

        "Initialize topology"
        Topo.__init__( self )

        "Directory where this file / script is located"
        scriptdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory

        "Initialize a service helper for Quagga with default options"
        quaggaSvc = QuaggaService(autoStop=False)

        "Path configurations for mounts"
        quaggaBaseConfigPath=scriptdir + '/configs/'

        "List of Quagga host configs"
        quaggaHosts = []
        quaggaHosts.append(QuaggaHost(
                           name = 'r01',
                           ip = '172.0.0.1/16',
                           mac = '08:00:27:89:3b:9f',
                           port = 1))
        quaggaHosts.append(QuaggaHost(
                           name = 'r02',
                           ip = '172.0.0.2/16',
                           mac ='08:00:27:92:18:1f',
                           port = 2))
        quaggaHosts.append(QuaggaHost(
                           name = 'r03',
                           ip = '172.0.0.3/16',
                           mac = '08:00:27:54:56:ea',
                           port = 3))

        "Add switch"
        s1, s2, s3, s4, s5, s6 = [
            self.addSwitch( s ) for s in 's1', 's2', 's3', 's4', 's5', 's6'
        ]

        "Setup each legacy router, add a link between it and the IXP fabric"
        for host in quaggaHosts:
            "Set Quagga service configuration for this node"
            quaggaSvcConfig = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + host.name }

            quaggaContainer = self.addHost( name=host.name,
                                            ip=host.ip,
                                            mac=host.mac,
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
            self.addNodeService(node=host.name, service=quaggaSvc,
                                nodeConfig=quaggaSvcConfig)
            "Attach the quaggaContainer to the IXP Fabric Switch"
            self.addLink( quaggaContainer, s1 , port2=host.port)

            # Adicionando Roteadores agregados
            a03_config = \
            { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a03' }
            a03 = self.addHost( name='a03',
                                        ip='22.0.0.1/24',
                                        privateLogDir=True,
                                        privateRunDir=True,
                                        inMountNamespace=True,
                                        inPIDNamespace=True)
            self.addNodeService(node='a03', service=quaggaSvc,
                            nodeConfig=a03_config)
            self.addLink(s6, a03)


            if(host.name == 'r02'):
                cli01r02_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'cli01r02' }
                # Adicionando Roteadores agregados
                cli01r02 = self.addHost( name='cli01r02',
                                            ip='10.0.0.2/24',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='cli01r02', service=quaggaSvc,
                                nodeConfig=cli01r02_config)

                a02_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a02' }
                # Adicionando Roteadores agregados
                a02 = self.addHost( name='a02',
                                            ip='11.0.0.2/24',
                                            mac='00:00:11:00:00:02',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='a02', service=quaggaSvc,
                                nodeConfig=a02_config)

                self.addLink(s2, quaggaContainer)
                self.addLink(s3, quaggaContainer)
                self.addLink(s2, cli01r02)
                self.addLink(s3, a02)
                self.addLink(s6, a02)

            elif(host.name == 'r01'):
                a01_config = \
                { 'quaggaConfigPath' : scriptdir + '/configs/' + 'a01' }
                # Adicionando Roteadores agregados
                a01 = self.addHost( name='a01',
                                            ip='12.0.0.2/24',
                                            mac='00:00:12:00:00:02',
                                            privateLogDir=True,
                                            privateRunDir=True,
                                            inMountNamespace=True,
                                            inPIDNamespace=True)
                self.addNodeService(node='a01', service=quaggaSvc,
                                nodeConfig=a01_config)

                self.addLink(s4, quaggaContainer)
                self.addLink(s4, a01)
                self.addLink(s5, a01)
                self.addLink(s5, a03)
예제 #37
0
    def __init__(self):
        #Initialize a topology of 3 hosts, 5 routers, 4 switches
        Topo.__init__(self)

        info('*** Creating Quagga Routers\n')
        # Absolute path to this python script
        selfPath = os.path.dirname(
            os.path.abspath(inspect.getfile(inspect.currentframe())))

        # Initialize the Quagga Service
        # autoStart=True (default) --> starts automatically quagga on the host
        # autoStop=True (default) --> stops automatically quagga (we don't want this)
        quaggaSvc = QuaggaService(autoStop=False)

        # Configuration file path for quagga routers
        quaggaBaseConfigPath = selfPath + '/configs/'

        # Initializing local variables
        netHosts = []
        NodeList = []

        # List of all hosts in the network.
        # Note that each node requires at least one IP address.
        netHosts.append(
            NetworkHosts(name='h1', IP='192.10.10.10/24',
                         DG='via 192.10.10.1'))
        netHosts.append(
            NetworkHosts(name='h2', IP='192.20.20.20/24',
                         DG='via 192.20.20.2'))
        netHosts.append(
            NetworkHosts(name='h5', IP='192.50.50.50/24',
                         DG='via 192.50.50.5'))
        netHosts.append(NetworkHosts(name='r1', IP='192.10.10.1/24', DG=''))
        netHosts.append(NetworkHosts(name='r2', IP='192.20.20.2/24', DG=''))
        netHosts.append(NetworkHosts(name='r3', IP='192.13.13.3/24', DG=''))
        netHosts.append(NetworkHosts(name='r4', IP='192.24.24.4/24', DG=''))
        netHosts.append(NetworkHosts(name='r5', IP='192.50.50.5/24', DG=''))

        for host in netHosts:
            # We create a list of node names
            NodeList.append(host.name)
            if host.name in ['h1', 'h2', 'h5']:
                # We configure PCs with default gateway and without quagga service
                AddPCHost = self.addHost(name=host.name,
                                         ip=host.IP,
                                         defaultRoute=host.DG,
                                         hostname=host.name,
                                         privateLogDir=True,
                                         privateRunDir=True,
                                         inMountNamespace=True,
                                         inPIDNamespace=True,
                                         inUTSNamespace=True)
            else:
                # We configure routers with quagga service without default gateway
                AddQuaggaHost = self.addHost(name=host.name,
                                             ip=host.IP,
                                             hostname=host.name,
                                             privateLogDir=True,
                                             privateRunDir=True,
                                             inMountNamespace=True,
                                             inPIDNamespace=True,
                                             inUTSNamespace=True)
                # We setup Quagga service and path to config files
                quaggaSvcConfig = {
                    'quaggaConfigPath': quaggaBaseConfigPath + host.name
                }
                self.addNodeService(node=host.name,
                                    service=quaggaSvc,
                                    nodeConfig=quaggaSvcConfig)
        # Adding switches to the network, we specify OpenFlow v1.3 for IPv6 suppport
        SW1 = self.addSwitch('SW1', protocols='OpenFlow13')
        SW2 = self.addSwitch('SW2', protocols='OpenFlow13')
        SW5 = self.addSwitch('SW5', protocols='OpenFlow13')
        SW12 = self.addSwitch('SW12', protocols='OpenFlow13')
        SW13 = self.addSwitch('SW13', protocols='OpenFlow13')
        SW24 = self.addSwitch('SW24', protocols='OpenFlow13')
        SW345 = self.addSwitch('SW345', protocols='OpenFlow13')
        # We add links between switches and routers according to Fig.1 of Lab 4
        info('*** Creating links\n')
        self.addLink(SW1, NodeList[0], intfName2='h1-eth1')
        self.addLink(SW1, NodeList[3], intfName2='r1-eth3')

        self.addLink(SW2, NodeList[1], intfName2='h2-eth1')
        self.addLink(SW2, NodeList[4], intfName2='r2-eth3')

        self.addLink(SW5, NodeList[2], intfName2='h5-eth1')
        self.addLink(SW5, NodeList[7], intfName2='r5-eth1')

        self.addLink(SW12, NodeList[3], intfName2='r1-eth2')
        self.addLink(SW12, NodeList[4], intfName2='r2-eth2')

        self.addLink(SW13, NodeList[3], intfName2='r1-eth1')
        self.addLink(SW13, NodeList[5], intfName2='r3-eth1')

        self.addLink(SW24, NodeList[4], intfName2='r2-eth1')
        self.addLink(SW24, NodeList[6], intfName2='r4-eth1')

        self.addLink(SW345, NodeList[5], intfName2='r3-eth2')
        self.addLink(SW345, NodeList[6], intfName2='r4-eth2')
        self.addLink(SW345, NodeList[7], intfName2='r5-eth2')