コード例 #1
0
    def __init__(self):
        "Create custom topo."

        # Initialize topology
        Topo_WiFi.__init__(self)

        # Add hosts and switches
        leftStation = self.addStation('sta1')
        rightStation = self.addStation('sta2')
        leftAP = self.addAccessPoint('ap3')
        rightAP = self.addAccessPoint('ap4')

        # Add links
        self.addLink(leftStation, leftAP)
        self.addLink(leftAP, rightAP)
        self.addLink(rightAP, rightStation)
コード例 #2
0
    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo_WiFi.__init__( self )

        # Add hosts and switches
        leftStation = self.addStation( 'sta1' )
        rightStation = self.addStation( 'sta2' )
        leftAP = self.addAccessPoint( 'ap3' )
        rightAP = self.addAccessPoint( 'ap4' )

        # Add links
        self.addLink( leftStation, leftAP )
        self.addLink( leftAP, rightAP )
        self.addLink( rightAP, rightStation )
コード例 #3
0
 def testActualDpidAssignment(self):
     """Verify that AP dpid is the actual dpid assigned if dpid is
     passed in ap creation."""
     dpid = self.dpidFrom(0xABCD)
     ap = Mininet_wifi(topo=Topo_WiFi(), accessPoint=self.accessPointClass,
                       station=Station, controller=Controller,
                      ).addAccessPoint('ap1', dpid=dpid)
     self.assertEqual(ap.dpid[1:], dpid)
コード例 #4
0
 def testDefaultDpid(self):
     """Verify that the default dpid is assigned using a valid provided
     canonical apname if no dpid is passed in ap creation."""
     ap = Mininet_wifi(topo=Topo_WiFi(),
                       accessPoint=self.accessPointClass,
                       station=Station, controller=Controller,
                      ).addAccessPoint('ap1')
     self.assertEqual(ap.defaultDpid(), ap.dpid)
コード例 #5
0
    def testDefaultDpidLen(self):
        """Verify that Default dpid length is 16 characters consisting of
        16 - len(hex of first string of contiguous digits passed in ap
        name) 0's followed by hex of first string of contiguous digits passed
        in ap name."""
        ap = Mininet_wifi(topo=Topo_WiFi(), accessPoint=self.accessPointClass,
                          station=Station, controller=Controller,
                         ).addAccessPoint('ap123')

        self.assertEqual(ap.dpid, self.dpidFrom(123))
コード例 #6
0
    def __init__(self, stations, aps, hosts, switches, links, log_dir,
                 bmv2_exe, pcap_dir, **opts):
        Topo_WiFi.__init__(self, **opts)
        sta_links = []
        ap_links = []

        # assumes station always comes first for station<-->ap links
        for link in links:
            if (link['node2'][0] == 's' and link['node2'][1] == 't') \
                    or link['node1'][0] == 'h':
                sta_links.append(link)
            else:
                ap_links.append(link)

        if switches:
            for switch, params in switches.iteritems():
                if "program" in params:
                    switchClass = configureP4Switch(
                        sw_path=bmv2_exe,
                        json_path=params["program"],
                        log_console=True,
                        pcap_dump=pcap_dir)
                else:
                    # add default ap
                    switchClass = None

                if 'device_id' in params:
                    device_id = params['device_id']
                else:
                    device_id = None

                if 'grpc_port' in params:
                    grpc_port = params['grpc_port']
                else:
                    grpc_port = None

                if 'thrift-port' in params:
                    thrift_port = params['thrift-port']
                else:
                    thrift_port = None

                self.addSwitch(switch,
                               log_file="%s/%s.log" % (log_dir, switch),
                               grpc_port=grpc_port,
                               device_id=device_id,
                               thrift_port=thrift_port,
                               cls=switchClass)

        if aps:
            for ap, params in aps.iteritems():
                if "program" in params:
                    apClass = configureP4AP(sw_path=bmv2_exe,
                                            json_path=params["program"],
                                            log_console=True,
                                            pcap_dump=pcap_dir)
                else:
                    # add default ap
                    apClass = None
                if int(ap[2:]) == 1:
                    x, y = 100, 300
                elif int(ap[2:]) == 2:
                    x, y = 500, 300

                if 'device_id' in params:
                    device_id = params['device_id']
                else:
                    device_id = None

                if 'grpc_port' in params:
                    grpc_port = params['grpc_port']
                else:
                    grpc_port = None

                if 'thrift-port' in params:
                    thrift_port = params['thrift-port']
                else:
                    thrift_port = None

                self.addAccessPoint(ap,
                                    log_file="%s/%s.log" % (log_dir, ap),
                                    position='%s,%s,0' % (x, y),
                                    grpc_port=grpc_port,
                                    device_id=device_id,
                                    thrift_port=thrift_port,
                                    cls=apClass,
                                    passwd='123456789a',
                                    encrypt='wpa2',
                                    ieee80211r='yes',
                                    mobility_domain='a1b2')

        for sta in stations:
            sta_num = int(sta[3:])
            sta_ip = "10.0.%d.%d" % (sta_num, sta_num)
            sta_mac = '08:00:00:00:%02x:%s%s' % (sta_num, sta_num, sta_num)
            self.addStation(str(sta),
                            ip=sta_ip + '/24',
                            mac=sta_mac,
                            encrypt='wpa2',
                            bgscan_threshold=-70,
                            s_inverval=1,
                            l_interval=2)

        for host in hosts:
            host_num = int(host[1:])
            host_ip = "10.0.%d.%d" % (host_num, host_num)
            host_mac = '08:00:00:00:%02x:%s%s' % (host_num, host_num, host_num)
            if host_num == 3:
                self.addHost(str(host),
                             ip=host_ip + '/24',
                             mac=host_mac,
                             inNamespace=False)
            else:
                self.addHost(str(host), ip=host_ip + '/24', mac=host_mac)
            for switch in switches:
                switch_name = str(switch)
                self.addLink(host, str(switch_name))

        for link in ap_links:
            sw1_name, sw1_port = self.parse_ap_node(link['node1'])
            sw2_name, sw2_port = self.parse_ap_node(link['node2'])
            self.addLink(sw1_name, sw2_name, port1=sw1_port, port2=sw2_port)
コード例 #7
0
    def processTopo(topoFile):
        config = configparser.ConfigParser(delimiters=' ')
        config.read(topoFile)
        topo = Topo_WiFi()

        items = config.items('stations')
        debug("Stations")
        for item in items:
            debug(item[0].split(':'))
            name = item[0].split(':')[0]
            params = {}
            for param in item[1].split(' '):
                if param == "_":
                    continue
                key = param.split('=')[0]
                value = param.split('=')[1]
                if key in ['range']:
                    value = int(value)
                params[key] = value

            topo.addStation(name, **params)

        try:
            debug("Switches")
            items = config.items('switches')
            for item in items:
                debug(item[0].split(':'))
                name = item[0].split(':')[0]
                topo.addSwitch(name)
        except configparser.NoSectionError:
            debug("Switches are optional")
            pass

        try:
            debug("APs")
            items = config.items('accessPoints')
            for item in items:
                debug(item[0].split(':'))
                name = item[0].split(':')[0]
                ap_params = {}
                for param in item[1].split(' '):
                    if param == "_":
                        continue
                    key = param.split('=')[0]
                    value = param.split('=')[1]
                    if key in ['range']:
                        value = int(value)
                    ap_params[key] = value
                topo.addAccessPoint(name, **ap_params)
        except configparser.NoSectionError:
            debug("APs are optional")
            pass

        items = config.items('links')
        debug("Links")
        for item in items:
            link = item[0].split(':')
            debug(link)
            params = {}
            for param in item[1].split(' '):
                if param == "_":
                    continue
                key = param.split('=')[0]
                value = param.split('=')[1]
                if key in ['bw', 'jitter', 'max_queue_size']:
                    value = int(value)
                if key == 'loss':
                    value = float(value)
                params[key] = value

            topo.addLink(link[0], link[1], **params)

        return topo
コード例 #8
0
    def __init__(self, stations, aps, links, log_dir, bmv2_exe, pcap_dir,
                 **opts):
        Topo_WiFi.__init__(self, **opts)
        sta_links = []
        ap_links = []

        # assumes station always comes first for station<-->ap links
        for link in links:
            if link['node2'][0] == 's':
                sta_links.append(link)
            else:
                ap_links.append(link)

        for ap, params in aps.iteritems():
            if "program" in params:
                apClass = configureP4AP(sw_path=bmv2_exe,
                                        json_path=params["program"],
                                        log_console=True,
                                        pcap_dump=pcap_dir)
            else:
                # add default ap
                apClass = None
            if int(ap[2:]) == 1:
                x, y = 100, 100
            elif int(ap[2:]) == 2:
                x, y = 300, 100
            elif int(ap[2:]) == 3:
                x, y = 100, 300
            elif int(ap[2:]) == 4:
                x, y = 300, 300

            self.addAccessPoint(ap,
                                log_file="%s/%s.log" % (log_dir, ap),
                                position='%s,%s,0' % (x, y),
                                cls=apClass)

        for link in sta_links:
            sta_name = link['node2']
            ap_name, sw_port = self.parse_ap_node(link['node1'])
            sta_num = int(sta_name[3:])
            sta_ip = "10.0.%d.%d" % (sta_num, sta_num)
            sta_mac = '08:00:00:00:%02x:%s%s' % (sta_num, sta_num, sta_num)
            if int(ap_name[2:]) == 1 and sta_num == 1:
                x, y = 80, 80
            elif int(ap_name[2:]) == 1 and sta_num == 2:
                x, y = 120, 80
            elif int(ap_name[2:]) == 2 and sta_num == 3:
                x, y = 280, 80
            elif int(ap_name[2:]) == 2 and sta_num == 4:
                x, y = 320, 80
            self.addStation(sta_name,
                            ip=sta_ip + '/24',
                            mac=sta_mac,
                            position='%s,%s,0' % (x, y))
            self.addLink(sta_name,
                         ap_name,
                         delay=link['latency'],
                         bw=link['bandwidth'])

        for link in ap_links:
            sw1_name, sw1_port = self.parse_ap_node(link['node1'])
            sw2_name, sw2_port = self.parse_ap_node(link['node2'])
            if int(sw1_name[2:]) == 1 or int(sw1_name[2:]) == 2:
                sw1_port -= 1
            self.addLink(sw1_name,
                         sw2_name,
                         port1=sw1_port,
                         port2=sw2_port,
                         delay=link['latency'],
                         bw=link['bandwidth'])
コード例 #9
0
    def __init__(self, stations, aps, hosts, switches, links, log_dir,
                 bmv2_exe, pcap_dir, **opts):
        Topo_WiFi.__init__(self, **opts)
        sta_links = []
        ap_links = []

        # assumes station always comes first for station<-->ap links
        for link in links:
            if (link['node2'][0] == 's' and link['node2'][1] == 't') \
                    or link['node1'][0] == 'h':
                sta_links.append(link)
            else:
                ap_links.append(link)

        if switches:
            for switch, params in switches.iteritems():
                if "program" in params:
                    switchClass = configureP4Switch(
                        sw_path=bmv2_exe,
                        json_path=params["program"],
                        log_console=True,
                        pcap_dump=pcap_dir)
                else:
                    # add default ap
                    switchClass = None

                if 'device_id' in params:
                    device_id = params['device_id']
                else:
                    device_id = None

                if 'grpc_port' in params:
                    grpc_port = params['grpc_port']
                else:
                    grpc_port = None

                if 'thrift-port' in params:
                    thrift_port = params['thrift-port']
                else:
                    thrift_port = None

                self.addSwitch(switch,
                               log_file="%s/%s.log" % (log_dir, switch),
                               grpc_port=grpc_port,
                               device_id=device_id,
                               thrift_port=thrift_port,
                               cls=switchClass)

        if aps:
            for ap, params in aps.iteritems():
                if "program" in params:
                    apClass = configureP4AP(sw_path=bmv2_exe,
                                            json_path=params["program"],
                                            log_console=True,
                                            pcap_dump=pcap_dir)
                else:
                    # add default ap
                    apClass = None
                if int(ap[2:]) == 1:
                    x, y = 100, 100
                elif int(ap[2:]) == 2:
                    x, y = 300, 100

                if 'device_id' in params:
                    device_id = params['device_id']
                else:
                    device_id = None

                if 'grpc_port' in params:
                    grpc_port = params['grpc_port']
                else:
                    grpc_port = None

                if 'thrift-port' in params:
                    thrift_port = params['thrift-port']
                else:
                    thrift_port = None

                self.addAccessPoint(ap,
                                    log_file="%s/%s.log" % (log_dir, ap),
                                    position='%s,%s,0' % (x, y),
                                    grpc_port=grpc_port,
                                    device_id=device_id,
                                    thrift_port=thrift_port,
                                    cls=apClass)

        for link in sta_links:

            if link['node1'][0] == 'h':
                sta_name = link['node1']
                sw = link['node2']
                sta_num = int(sta_name[1:])
            else:
                sta_name = link['node2']
                sw = link['node1']
                sta_num = int(sta_name[3:])
            ap_name, sw_port = self.parse_ap_node(sw)
            sta_ip = "10.0.%d.%d" % (sta_num, sta_num)
            sta_mac = '08:00:00:00:%02x:%s%s' % (sta_num, sta_num, sta_num)
            if link['node1'][0] != 'h':
                if int(ap_name[2:]) == 1:
                    x, y = 100, 80
                elif int(ap_name[2:]) == 2:
                    x, y = 340, 80
            if link['node1'][0] == 'h':
                self.addHost(sta_name, ip=sta_ip + '/24', mac=sta_mac)
            else:
                self.addStation(sta_name,
                                ip=sta_ip + '/24',
                                mac=sta_mac,
                                position='%s,%s,0' % (x, y))

            self.addLink(sta_name, ap_name)

        for link in ap_links:
            sw1_name, sw1_port = self.parse_ap_node(link['node1'])
            sw2_name, sw2_port = self.parse_ap_node(link['node2'])
            self.addLink(sw1_name, sw2_name, port1=sw1_port, port2=sw2_port)