• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dpid.dpid_to_str函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ryu.lib.dpid.dpid_to_str函数的典型用法代码示例。如果您正苦于以下问题:Python dpid_to_str函数的具体用法?Python dpid_to_str怎么用?Python dpid_to_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dpid_to_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):
        super(OfTester, self).__init__()
        self._set_logger()

        self.target_dpid = self._convert_dpid(CONF['test-switch']['target'])
        self.tester_dpid = self._convert_dpid(CONF['test-switch']['tester'])
        self.logger.info('target_dpid=%s',
                         dpid_lib.dpid_to_str(self.target_dpid))
        self.logger.info('tester_dpid=%s',
                         dpid_lib.dpid_to_str(self.tester_dpid))
        test_dir = CONF['test-switch']['dir']
        self.logger.info('Test files directory = %s', test_dir)

        self.target_sw = OpenFlowSw(DummyDatapath(), self.logger)
        self.tester_sw = OpenFlowSw(DummyDatapath(), self.logger)
        self.state = STATE_INIT_FLOW
        self.sw_waiter = None
        self.waiter = None
        self.send_msg_xids = []
        self.rcv_msgs = []
        self.ingress_event = None
        self.ingress_threads = []
        self.thread_msg = None
        self.test_thread = hub.spawn(
            self._test_sequential_execute, test_dir)
开发者ID:paisa4ever,项目名称:ryu,代码行数:25,代码来源:tester.py


示例2: switch_desc_handler

    def switch_desc_handler(self, ev):
        switch_str = ""
        stats = ev.msg.body

        dp_desc = stats.dp_desc
        hw_desc = stats.hw_desc
        mfr_desc = stats.mfr_desc
        serial_num = stats.serial_num
        sw_desc = stats.sw_desc


        switch_str = "\n\n==========================================\n"
        switch_str += " Switch Description: \n"
        switch_str += "==========================================\n"
        switch_str += "* Manufacturer description: \t" + mfr_desc + "\n" 
        switch_str += "* Hardware description: \t" + hw_desc + "\n"
        switch_str += "* Software description: \t" + sw_desc + "\n"
        switch_str += "* Serial number:         \t" + serial_num + "\n"
        switch_str += "* Datapath description: \t" + dp_desc + "\n"
        switch_str += "==========================================\n\n"

        # Save 
        fd = open("./results/switch_" + dpidlib.dpid_to_str(ev.msg.datapath.id) + "_v10_extra.txt", 'a+')
        fd.write(switch_str)
        fd.close()

        # Combined
        self.combined_str += (switch_str)

        # Last handle.. So save combined string
        fd = open("./results/switch_" + dpidlib.dpid_to_str(ev.msg.datapath.id) + "_v10_combined.txt", 'a+')
        fd.write(self.combined_str)
        fd.close()
开发者ID:PrincetonUniversity,项目名称:AdvNet-OF_Scripts,代码行数:33,代码来源:features_10.py


示例3: __str__

 def __str__(self):
     return "EventTunnelPort<dpid %s port_no %d remote_dpid %s " "add_del %s>" % (
         dpid_lib.dpid_to_str(self.dpid),
         self.port_no,
         dpid_lib.dpid_to_str(self.remote_dpid),
         self.add_del,
     )
开发者ID:savi-dev,项目名称:ryu,代码行数:7,代码来源:gre_tunnel.py


示例4: packet_in_handler

    def packet_in_handler(self, ev):
        self.logger.debug('packet_in_handler')
        msg = ev.msg
        datapath = msg.datapath
        ofproto = datapath.ofproto

        # TODO: subscribe only the designated datapath
        dpid = datapath.id
        if dpid != self.interface.dpid:
            self.logger.debug('packet_in_handler dpid %s %s',
                              dpid_lib.dpid_to_str(dpid),
                              dpid_lib.dpid_to_str(self.interface.dpid))
            return

        in_port = None
        for field in msg.match.fields:
            if field.header == ofproto.OXM_OF_IN_PORT:
                in_port = field.value
                break

        if in_port != self.interface.port_no:
            self.logger.debug('packet_in_handler in_port %s %s',
                              in_port, self.interface.port_no)
            return

        self._send_vrrp_packet_received(msg.data)
开发者ID:5g-empower,项目名称:empower-ryu,代码行数:26,代码来源:monitor_openflow.py


示例5: to_dict

 def to_dict(self):
     return {'dpid': dpid_to_str(self.dp.id),
             'name': self.name,
             'neighbors': [dpid_to_str(switch.dp.id) for switch in self.neighbors],
             'ports': [port.to_dict() for (port_no, port) in self.ports.items()],
             'arp_table': self.get_arp_list(),
             'routing_table': self.get_routing_table()}
开发者ID:hungys,项目名称:RoutingFlow,代码行数:7,代码来源:switch.py


示例6: _hosts

    def _hosts(self, req, **kwargs):
        body = None
        db = database(DB_PATH)

        if 'dpid' in kwargs:
            dpid = dpid_lib.str_to_dpid(kwargs['dpid'])
            rcd_dpid = selectDPID(dpid=dpid)
            host_of_dpid = []
            tmp = {'mac':'a', 'port':0,'ip':'a', 'slave':1}
            for x in rcd_dpid:
                tmp['mac'], tmp['port'], tmp['ip'], tmp['slave'] = x[0].encode('utf-8'), x[1], x[2].encode('utf-8'), x[3]
                hosts_of_dpid.append(dict(tmp))
            body = json.dumps(hosts_of_dpid)
        else:
            rcd_dev = db.selectDEVICE()    
            hosts = []
            tmp = {'user_id':0, 'dpid':0,'mac':'a', 'vlan':0, 'ip': 'a', 'port':0}
            #add gateway
            tmp['mac'] = db.selectGATEWAY()[0][0].encode('utf-8')
            tmp['ip'] = db.selectGATEWAY()[0][1].encode('utf-8')
            gw_dpid = db.getDPIDBySlave(mac_addr=tmp['mac'])
            if None != gw_dpid:
                tmp['port'] = db.findDPIDByX(gw_dpid,'MAC_ADDR',tmp['mac'])[0][0]
                tmp['dpid'] = dpid_lib.dpid_to_str(gw_dpid)
                hosts.append(dict(tmp))
            #add host
            for dev in rcd_dev:
                tmp['mac'], tmp['vlan'], tmp['user_id'] = dev[0].encode('utf-8'), dev[1], dev[2]
                dpid = db.getDPIDBySlave(mac_addr=tmp['mac'])
                tmp['dpid'] = dpid_lib.dpid_to_str(dpid)
                rcd_host = db.findDPIDByX(dpid,'MAC_ADDR',tmp['mac'])
                tmp['port'], tmp['ip'] = rcd_host[0][0], rcd_host[0][1].encode('utf-8')
                hosts.append(dict(tmp))
            body = json.dumps(hosts)
        return Response(content_type='application/json', body=body)
开发者ID:istarli,项目名称:mobile_vlan,代码行数:35,代码来源:rest_admin.py


示例7: port_status_handler

    def port_status_handler(self, ev):
        msg = ev.msg
        reason = msg.reason
        datapath = msg.datapath
        port = msg.desc
        ofproto = datapath.ofproto

        if reason == ofproto.OFPPR_ADD:
            LOG.debug('DPSET: A port was added.' +
                      '(datapath id = %s, port number = %s)',
                      dpid_to_str(datapath.id), port.port_no)
            self._port_added(datapath, port)
            self.send_event_to_observers(EventPortAdd(datapath, port))
        elif reason == ofproto.OFPPR_DELETE:
            LOG.debug('DPSET: A port was deleted.' +
                      '(datapath id = %s, port number = %s)',
                      dpid_to_str(datapath.id), port.port_no)
            self._port_deleted(datapath, port)
            self.send_event_to_observers(EventPortDelete(datapath, port))
        else:
            assert reason == ofproto.OFPPR_MODIFY
            LOG.debug('DPSET: A port was modified.' +
                      '(datapath id = %s, port number = %s)',
                      dpid_to_str(datapath.id), port.port_no)
            self.port_state[datapath.id].modify(port.port_no, port)
            self.send_event_to_observers(EventPortModify(datapath, port))
开发者ID:AndreiaAB,项目名称:ryu,代码行数:26,代码来源:dpset.py


示例8: _setup_data_fwd_flows

    def _setup_data_fwd_flows(self, src_mac, dst_mac):
        """
        Given two MAC addresses, set up flows on their connected switches
        towards each other, so that they can forward packets between each other
        """
        (src_dpid, src_port) = (self.inception.
                                      mac_to_dpid_port[src_mac])
        (dst_dpid, dst_port) = (self.inception.
                                      mac_to_dpid_port[dst_mac])

        # If src_dpid == dst_dpid, no need to set up flows
        if src_dpid == dst_dpid:
            return

        src_ip = self.inception.dpid_to_ip[src_dpid]
        dst_ip = self.inception.dpid_to_ip[dst_dpid]
        src_fwd_port = self.inception.dpid_to_conns[src_dpid][dst_ip]
        dst_fwd_port = self.inception.dpid_to_conns[dst_dpid][src_ip]
        src_datapath = self.inception.dpset.get(src_dpid)
        dst_datapath = self.inception.dpset.get(dst_dpid)
        src_ofproto = src_datapath.ofproto
        dst_ofproto = dst_datapath.ofproto
        src_ofproto_parser = src_datapath.ofproto_parser
        dst_ofproto_parser = dst_datapath.ofproto_parser
        if (src_dpid, dst_mac) not in self.inception.unicast_rules:
            actions_fwd = [src_ofproto_parser.OFPActionOutput(src_fwd_port)]
            instructions_fwd = [src_datapath.ofproto_parser.
                                OFPInstructionActions(
                                src_ofproto.OFPIT_APPLY_ACTIONS, actions_fwd)]
            src_datapath.send_msg(src_ofproto_parser.OFPFlowMod(
                        datapath=src_datapath,
                        match=src_ofproto_parser.OFPMatch(eth_dst=dst_mac),
                        cookie=0, command=src_ofproto.OFPFC_ADD,
                        priority=priority.DATA_FWD,
                        flags=src_ofproto.OFPFF_SEND_FLOW_REM,
                        instructions=instructions_fwd
                        ))
            self.inception.unicast_rules.append((src_dpid, dst_mac))
            LOGGER.info("Setup forward flow on switch=%s"
                        "towards mac=%s", dpid_to_str(src_dpid), dst_mac)

        if (dst_dpid, src_mac) not in self.inception.unicast_rules:
            actions_dst = [dst_ofproto_parser.OFPActionOutput(dst_fwd_port)]
            instructions_dst = [dst_datapath.ofproto_parser.
                                OFPInstructionActions(
                                dst_ofproto.OFPIT_APPLY_ACTIONS, actions_dst)]
            dst_datapath.send_msg(dst_ofproto_parser.OFPFlowMod(
                        datapath=dst_datapath,
                        match=dst_ofproto_parser.OFPMatch(eth_dst=src_mac),
                        cookie=0, command=dst_ofproto.OFPFC_ADD,
                        priority=priority.DATA_FWD,
                        flags=dst_ofproto.OFPFF_SEND_FLOW_REM,
                        instructions=instructions_dst
                        ))
            self.inception.unicast_rules.append((dst_dpid, src_mac))
            LOGGER.info("Setup forward flow on switch=%s"
                        "towards mac=%s", dpid_to_str(dst_dpid), src_mac)
开发者ID:kindofblue,项目名称:ryu,代码行数:57,代码来源:inception_arp.py


示例9: _do_lacp

    def _do_lacp(self, req_lacp, src, msg):
        """packet-in process when the received packet is LACP."""
        datapath = msg.datapath
        dpid = datapath.id
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            port = msg.in_port
        else:
            port = msg.match['in_port']

        self.logger.info("SW=%s PORT=%d LACP received.",
                         dpid_to_str(dpid), port)
        self.logger.debug(str(req_lacp))

        # when LACP arrived at disabled port, update the status of
        # the slave i/f to enabled, and send a event.
        if not self._get_slave_enabled(dpid, port):
            self.logger.info(
                "SW=%s PORT=%d the slave i/f has just been up.",
                dpid_to_str(dpid), port)
            self._set_slave_enabled(dpid, port, True)
            self.send_event_to_observers(
                EventSlaveStateChanged(datapath, port, True))

        # set the idle_timeout time using the actor state of the
        # received packet.
        if req_lacp.LACP_STATE_SHORT_TIMEOUT == \
           req_lacp.actor_state_timeout:
            idle_timeout = req_lacp.SHORT_TIMEOUT_TIME
        else:
            idle_timeout = req_lacp.LONG_TIMEOUT_TIME

        # when the timeout time has changed, update the timeout time of
        # the slave i/f and re-enter a flow entry for the packet from
        # the slave i/f with idle_timeout.
        if idle_timeout != self._get_slave_timeout(dpid, port):
            self.logger.info(
                "SW=%s PORT=%d the timeout time has changed.",
                dpid_to_str(dpid), port)
            self._set_slave_timeout(dpid, port, idle_timeout)
            func = self._add_flow.get(ofproto.OFP_VERSION)
            assert func
            func(src, port, idle_timeout, datapath)

        # create a response packet.
        res_pkt = self._create_response(datapath, port, req_lacp)

        # packet-out the response packet.
        out_port = ofproto.OFPP_IN_PORT
        actions = [parser.OFPActionOutput(out_port)]
        out = datapath.ofproto_parser.OFPPacketOut(
            datapath=datapath, buffer_id=ofproto.OFP_NO_BUFFER,
            data=res_pkt.data, in_port=port, actions=actions)
        datapath.send_msg(out)
开发者ID:AkiraSuu,项目名称:ryu,代码行数:55,代码来源:lacplib.py


示例10: create_switch_to_switch_links

 def create_switch_to_switch_links(self):
     for link in self.links:
         src_port = link.src.port_no
         dst_port = link.dst.port_no
         src_dpid = format_dpid_str(dpid_to_str(link.src.dpid))
         dst_dpid = format_dpid_str(dpid_to_str(link.dst.dpid))
         src_port_id = src_dpid + str(src_port)
         dst_port_id = dst_dpid + str(dst_port)
         src_port_vertex  = self.get_unique_port_vertex(src_port_id)
         dst_port_vertex  = self.get_unique_port_vertex(dst_port_id)
         self.create_link_edge(src_port_vertex,dst_port_vertex)
开发者ID:zubair1234,项目名称:Assignment,代码行数:11,代码来源:switch.py


示例11: _get_bridge_name

 def _get_bridge_name(self):
     """ get Bridge name of a given 'datapath_id' """
     command = ovs_vsctl.VSCtlCommand(
         'find',
         ('Bridge',
          'datapath_id=%s' % dpid_lib.dpid_to_str(self.datapath_id)))
     self.run_command([command])
     if not isinstance(command.result, list) or len(command.result) != 1:
         raise OVSBridgeNotFound(
             datapath_id=dpid_lib.dpid_to_str(self.datapath_id))
     return command.result[0].name
开发者ID:Huangmachi,项目名称:ryu,代码行数:11,代码来源:bridge.py


示例12: _get_bridge_name

 def _get_bridge_name(self):
     """ get Bridge name of a given 'datapath_id' """
     command = ovs_vsctl.VSCtlCommand(
         'find',
         ('Bridge',
          'datapath_id=%s' % dpid_lib.dpid_to_str(self.datapath_id)))
     self.run_command([command])
     result = command.result
     if len(result) == 0 or len(result) > 1:
         raise OVSBridgeNotFound(
             datapath_id=dpid_lib.dpid_to_str(self.datapath_id))
     return result[0].name
开发者ID:aryantaheri,项目名称:ryu,代码行数:12,代码来源:bridge.py


示例13: unregist_ofs

 def unregist_ofs(dp):
     if dp.id in FirewallController._OFS_LIST:
         del FirewallController._OFS_LIST[dp.id]
         dpid_str = dpid_lib.dpid_to_str(dp.id)
         try:
             http_request_test(dpid_str, 'leave')
         except:
             print "DrawBridge controller is not enabled"
         #http_request_test(dpid_str, 'leave')
         # again, make a POST request to the DrawBridge controller.
         FirewallController._LOGGER.info('dpid=%s: Leave firewall.',
                                         dpid_lib.dpid_to_str(dp.id))
开发者ID:luminshi,项目名称:ryu,代码行数:12,代码来源:rest_drawbridge_customized_firewall.py


示例14: table_features_handler

    def table_features_handler(self, ev):

        feature_str = ""
        prop_str = ""

        ## Fields
        print ev.msg.datapath
        table_list = ev.msg.body
        for t in table_list:

            table_id = t.table_id
            name = t.name
            metadata_match = t.metadata_match
            metadata_write = t.metadata_write
            # config = t.config   ## Bitmap that is provided for backward compability in OF.
            max_entries = t.max_entries
            properties = t.properties

            #
            feature_str = "\n\n==========================================\n"
            feature_str += " Table Feature: " + str(table_id) + "\n"
            feature_str += "==========================================\n"

            feature_str += (
                "Table Id:             "
                + str(table_id)
                + "\n"
                + "Name:                 "
                + str(name)
                + "\n"
                + "Metadata_match:       "
                + str(hex(metadata_match))
                + "\n"
                + "Metadata_write:       "
                + str(hex(metadata_write))
                + "\n"
                + "Max entries:          "
                + str(max_entries)
                + "\n"
            )

            prop_str = self.property_parser(properties)

        # Save
        fd = open("./results/switch_" + dpidlib.dpid_to_str(ev.msg.datapath.id) + "_v13_table.txt", "a+")
        fd.write(feature_str + prop_str)
        fd.close()

        # Combined
        #        self.combined_str += (feature_str + prop_str)
        self.combined_str_map[dpidlib.dpid_to_str(ev.msg.datapath.id)] += feature_str + prop_str
开发者ID:PrincetonUniversity,项目名称:AdvNet-OF_Scripts,代码行数:51,代码来源:features_13.py


示例15: port_stats_reply_handler

    def port_stats_reply_handler(self, ev):
        dpid = dpidlib.dpid_to_str(ev.msg.datapath.id)

        if self.looped[dpid] is True:
            # Last handle.. So save combined string
            fd = open("./results/switch_" + dpidlib.dpid_to_str(ev.msg.datapath.id) + "_v13_combined.txt", "a+")
            fd.write(self.combined_str_map[dpidlib.dpid_to_str(ev.msg.datapath.id)])
            fd.close()
            return

        ports = []
        port_num_list = []
        for stat in ev.msg.body:
            ports.append(
                "port_no=%d "
                "rx_packets=%d tx_packets=%d "
                "rx_bytes=%d tx_bytes=%d "
                "rx_dropped=%d tx_dropped=%d "
                "rx_errors=%d tx_errors=%d "
                "rx_frame_err=%d rx_over_err=%d rx_crc_err=%d "
                "collisions=%d duration_sec=%d duration_nsec=%d"
                % (
                    stat.port_no,
                    stat.rx_packets,
                    stat.tx_packets,
                    stat.rx_bytes,
                    stat.tx_bytes,
                    stat.rx_dropped,
                    stat.tx_dropped,
                    stat.rx_errors,
                    stat.tx_errors,
                    stat.rx_frame_err,
                    stat.rx_over_err,
                    stat.rx_crc_err,
                    stat.collisions,
                    stat.duration_sec,
                    stat.duration_nsec,
                )
            )
            # 	    print stat.port_no
            port_num_list.append(stat.port_no)

        # Add to Overview
        fd = open("./results/switch_" + dpid + "_v13_overview.txt", "a")
        fd.write("\n\n" + "Port number list (shown to controller): " + str(port_num_list) + "\n")
        fd.close()

        # Add to combined
        self.combined_str_map[dpid] += "\n\n" + "Port number list (shown to controller): " + str(port_num_list) + "\n"
        self.looped[dpid] = True
开发者ID:PrincetonUniversity,项目名称:AdvNet-OF_Scripts,代码行数:50,代码来源:features_13.py


示例16: to_dict

 def to_dict(self):
     return {
         "dpid": dpid_to_str(self.dpid),
         "port_no": port_no_to_str(self.port_no),
         "hw_addr": self.hw_addr,
         "name": self.name.rstrip("\0"),
     }
开发者ID:hsiaohsuan1l1l,项目名称:OpenADM,代码行数:7,代码来源:switches.py


示例17: _create_lacp

 def _create_lacp(self, datapath, port, req):
     """create a LACP packet."""
     actor_system = datapath.ports[datapath.ofproto.OFPP_LOCAL].hw_addr
     res = slow.lacp(
         actor_system_priority=0xffff,
         actor_system=actor_system,
         actor_key=req.actor_key,
         actor_port_priority=0xff,
         actor_port=port,
         actor_state_activity=req.LACP_STATE_PASSIVE,
         actor_state_timeout=req.actor_state_timeout,
         actor_state_aggregation=req.actor_state_aggregation,
         actor_state_synchronization=req.actor_state_synchronization,
         actor_state_collecting=req.actor_state_collecting,
         actor_state_distributing=req.actor_state_distributing,
         actor_state_defaulted=req.LACP_STATE_OPERATIONAL_PARTNER,
         actor_state_expired=req.LACP_STATE_NOT_EXPIRED,
         partner_system_priority=req.actor_system_priority,
         partner_system=req.actor_system,
         partner_key=req.actor_key,
         partner_port_priority=req.actor_port_priority,
         partner_port=req.actor_port,
         partner_state_activity=req.actor_state_activity,
         partner_state_timeout=req.actor_state_timeout,
         partner_state_aggregation=req.actor_state_aggregation,
         partner_state_synchronization=req.actor_state_synchronization,
         partner_state_collecting=req.actor_state_collecting,
         partner_state_distributing=req.actor_state_distributing,
         partner_state_defaulted=req.actor_state_defaulted,
         partner_state_expired=req.actor_state_expired,
         collector_max_delay=0)
     self.logger.info("SW=%s PORT=%d LACP sent.",
                      dpid_to_str(datapath.id), port)
     self.logger.debug(str(res))
     return res
开发者ID:AkiraSuu,项目名称:ryu,代码行数:35,代码来源:lacplib.py


示例18: _register

    def _register(self, dp):
        LOG.debug('DPSET: register datapath %s', dp)
        assert dp.id is not None

        # while dpid should be unique, we need to handle duplicates here
        # because it's entirely possible for a switch to reconnect us
        # before we notice the drop of the previous connection.
        # in that case,
        # - forget the older connection as it likely will disappear soon
        # - do not send EventDP leave/enter events
        # - keep the PortState for the dpid
        if dp.id in self.dps:
            self.logger.warning('DPSET: Multiple connections from %s',
                                dpid_to_str(dp.id))
            self.logger.debug('DPSET: Forgetting datapath %s', self.dps[dp.id])
            self.logger.debug('DPSET: New datapath %s', dp)
        self.dps[dp.id] = dp
        if dp.id not in self.port_state:
            self.port_state[dp.id] = PortState()
            ev = EventDP(dp, True)
            with warnings.catch_warnings():
                warnings.simplefilter('ignore')
                for port in dp.ports.values():
                    self._port_added(dp, port)
                    ev.ports.append(port)
            self.send_event_to_observers(ev)
开发者ID:AndreiaAB,项目名称:ryu,代码行数:26,代码来源:dpset.py


示例19: _switch_enter_handler

    def _switch_enter_handler(self, ev):
        # get_switch(self, None) outputs the list of switches object.
        self.topo_switches = get_switch(self, None)
        # get_link(self, None) outputs the list of links object.
        self.topo_links = get_link(self, None)

        """
        Now you have saved the links and switches of the topo. But they are object, we need to use to_dict() to trans them  
        """
        # print '*'*40,"Switch_set",'*'*40
        for switch in self.topo_switches:
            dp = switch.dp
            dp_no = dpid_to_str(dp.id)
            if (Switch_set.has_key(dp_no) == False):
                ports = switch.ports
                Switch_set[dp_no] = [port.to_dict() for port in ports]
        # pprint.pprint(Switch_set)
        Switch_set_json = json.dumps(Switch_set, indent=4)
        Ssj_file = open('./Info/Static/Switch_json.json','w+')
        Ssj_file.write(Switch_set_json)
        Ssj_file.close()

        # print '*'*40,"Link_set",'*'*40
        Link_set = [ link.to_dict() for link in self.topo_links ]
        # pprint.pprint(Link_set)
        Link_set_json = json.dumps(Link_set, indent=4)
        Lsj_file = open('./Info/Static/Link_json.json','w+')
        Lsj_file.write(Link_set_json)
        Lsj_file.close()
        self.logger.info("******_switch_enter_handler, Switch_set & Link_set******")
开发者ID:xuan63,项目名称:TopoInfoLearner_Monitor,代码行数:30,代码来源:TopoInfoLearner.py


示例20: handle_arp_reply

    def handle_arp_reply(self, msg, pkt, arp_pkt):
        """
            called when receiving ARP reply from hosts.
            the host will send their MAC address back to switch.
            (1) save the MAC address information in ARP table.
            (2) try to resend the packet in the buffer.
            (3) remove the sent packet from the buffer queue.
        """
        switch = self.switches[msg.datapath.id]
        in_port_no = msg.in_port
        gateway = switch.ports[in_port_no].gateway
        replied_buffer = []

        logger.info('receive ARP reply: from %s (dpid=%s)', str(arp_pkt.src_ip), dpid_lib.dpid_to_str(msg.datapath.id))

        if gateway and gateway.ipv4 == netaddr.IPAddress(arp_pkt.dst_ip):
            self.update_arp_entry(switch, pkt)
            # try to resend the buffered packets
            for i in xrange(len(switch.msg_buffer)):
                msg, pkt, outport_no = switch.msg_buffer[i]
                if self.deliver_to_host(msg, pkt, outport_no):
                    replied_buffer.append(i)

            replied_buffer.sort(reverse = True)
            for i in replied_buffer:
                switch.msg_buffer.pop(i)
开发者ID:hungys,项目名称:RoutingFlow,代码行数:26,代码来源:routing.py



注:本文中的ryu.lib.dpid.dpid_to_str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dpid.str_to_dpid函数代码示例发布时间:2022-05-27
下一篇:
Python app_manager.AppManager类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap