当前位置: 首页>>代码示例>>Python>>正文


Python app_manager.lookup_service_brick方法代码示例

本文整理汇总了Python中ryu.base.app_manager.lookup_service_brick方法的典型用法代码示例。如果您正苦于以下问题:Python app_manager.lookup_service_brick方法的具体用法?Python app_manager.lookup_service_brick怎么用?Python app_manager.lookup_service_brick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ryu.base.app_manager的用法示例。


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

示例1: __init__

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkMonitor, self).__init__(*args, **kwargs)
		self.name = 'monitor'
		self.datapaths = {}
		self.port_stats = {}
		self.port_speed = {}
		self.flow_stats = {}
		self.flow_speed = {}
		self.stats = {}
		self.port_features = {}
		self.free_bandwidth = {}   # self.free_bandwidth = {dpid:{port_no:free_bw,},} unit:Kbit/s
		self.awareness = lookup_service_brick('awareness')
		self.graph = None
		self.capabilities = None
		self.best_paths = None

		# Start to green thread to monitor traffic and calculating
		# free bandwidth of links respectively.
		self.monitor_thread = hub.spawn(self._monitor)
		self.save_freebandwidth_thread = hub.spawn(self._save_bw_graph) 
开发者ID:Huangmachi,项目名称:PureSDN,代码行数:22,代码来源:network_monitor.py

示例2: get_Link_Loss

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def get_Link_Loss(self, src_dpid, dst_dpid):
        self.is_loss_task = 1
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        src_port = topo.get_link_to_port(topo.network_aware.link_to_port, src_dpid, dst_dpid)[0]
        dst_port = topo.get_link_to_port(topo.network_aware.link_to_port, dst_dpid, src_dpid)[0]
        self.send_port_stats_request(self.datapaths[src_dpid], src_port)
        self.send_port_stats_request(self.datapaths[dst_dpid], dst_port)
        self.reply_count_src={'dpid':src_dpid, 'port':src_port, 'count':1}
        self.reply_count_dst={'dpid':dst_dpid, 'port':dst_port, 'count':1}

        while self.reply_count_src['count'] != 0 or self.reply_count_dst['count'] != 0 :
            time.sleep(0.01)

        self.is_loss_task = 0

        self._get_Link_Loss(src_dpid, src_port, dst_dpid, dst_port)
        self._get_Link_Loss(dst_dpid, dst_port, src_dpid, src_port)

        return ((src_port, self.port_stats[(src_dpid, src_port)][-1], self.link_loss[(src_dpid, dst_dpid)][-1]), 
            (dst_port, self.port_stats[(dst_dpid, dst_port)][-1], self.link_loss[(dst_dpid, src_dpid)][-1])) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:22,代码来源:loss_measure.py

示例3: get_Flow_Loss

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def get_Flow_Loss(self, src_ip, dst_ip):
        self.is_loss_task = 1
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        flow_path = topo.flowPaths[(src_ip,dst_ip)]
        self.flow_reply_count = {'src_ip':src_ip, 'dst_ip':dst_ip, 'count':2}
        self.send_flow_stats_request(self.datapaths[flow_path[0]])
        self.send_flow_stats_request(self.datapaths[flow_path[-1]])

        while self.flow_reply_count['count'] != 0 :
            time.sleep(0.01)

        self.is_loss_task = 0

        self._get_Flow_Loss(src_ip, dst_ip, flow_path[0], flow_path[-1])

        return (src_ip, dst_ip, flow_path[0], self.flow_stats[flow_path[0]][(src_ip, dst_ip)][-1],
            flow_path[-1], self.flow_stats[flow_path[-1]][(src_ip, dst_ip)][-1], self.flow_loss[(src_ip, dst_ip)][-1]) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:19,代码来源:loss_measure.py

示例4: __init__

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkMonitor, self).__init__(*args, **kwargs)
		self.name = 'monitor'
		self.awareness = lookup_service_brick('awareness')
		self.datapaths = {}
		self.port_stats = {}
		self.port_speed = {}
		self.flow_stats = {}
		self.flow_speed = {}
		self.stats = {}
		self.port_features = {}
		self.free_bandwidth = {}   # {dpid:{port_no:free_bw,},} Unit:Kbit/s
		self.graph = None
		self.capabilities = None
		self.best_paths = None
		# Create four data structures for Hedera specially.
		self.hostsList = []
		self.flows = []   # Record flows that need to be rescheduled. (hmc)
		self.statRecord = []
		self.pre_GFF_path = {}   # Record the last GFF path of flows

		# Start to green thread to monitor traffic and calculating
		# free bandwidth of links respectively.
		self.monitor_thread = hub.spawn(self._monitor)
		self.save_freebandwidth_thread = hub.spawn(self._save_bw_graph) 
开发者ID:Huangmachi,项目名称:Hedera,代码行数:27,代码来源:network_monitor.py

示例5: create_bw_graph

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def create_bw_graph(self, bw_dict):
		"""
			Save bandwidth data into networkx graph object.
		"""
		try:
			graph = self.awareness.graph
			link_to_port = self.awareness.link_to_port
			for link in link_to_port:
				(src_dpid, dst_dpid) = link
				(src_port, dst_port) = link_to_port[link]
				if src_dpid in bw_dict and dst_dpid in bw_dict:
					bw_src = bw_dict[src_dpid][src_port]
					bw_dst = bw_dict[dst_dpid][dst_port]
					bandwidth = min(bw_src, bw_dst)
					# Add key:value pair of bandwidth into graph.
					if graph.has_edge(src_dpid, dst_dpid):
						graph[src_dpid][dst_dpid]['bandwidth'] = bandwidth
					else:
						graph.add_edge(src_dpid, dst_dpid)
						graph[src_dpid][dst_dpid]['bandwidth'] = bandwidth
				else:
					if graph.has_edge(src_dpid, dst_dpid):
						graph[src_dpid][dst_dpid]['bandwidth'] = 0
					else:
						graph.add_edge(src_dpid, dst_dpid)
						graph[src_dpid][dst_dpid]['bandwidth'] = 0
			return graph
		except:
			self.logger.info("Create bw graph exception")
			if self.awareness is None:
				self.awareness = lookup_service_brick('awareness')
			return self.awareness.graph 
开发者ID:Huangmachi,项目名称:PureSDN,代码行数:34,代码来源:network_monitor.py

示例6: test_delay

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def test_delay(self, src_dpid, dst_dpid):
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        test_path = topo.get_path(src_dpid,dst_dpid)
        print test_path
        if test_path is None:
            return test_path

        self.resetTime(test_path)
        #test src rtt
        self.rtt_src['time'] = self.send_meter_stats_request(self.datapaths[src_dpid])
        #test dst rtt
        self.rtt_dst['time'] = self.send_meter_stats_request(self.datapaths[dst_dpid])

        if(len(test_path) > 2):
            for dpid in test_path[1:-1]:
                self.total_rtt += self.send_meter_stats_request(self.datapaths[dpid])



        #send test packet
        for i in range(len(test_path)-1):
            src = test_path[i]
            dst = test_path[i+1]
            out_port = topo.get_link_to_port(topo.network_aware.link_to_port, src, dst)[0]
            p = self.build_packet(out_port)
            self.total_time+=self.send_packet_out(self.datapaths[src], self.datapaths[src].ofproto.OFP_NO_BUFFER, 
                self.datapaths[src].ofproto.OFPP_CONTROLLER, out_port, p.data)


        #time.sleep(1)
        while self.packets_NO != 0 or self.reply_NO != 0:
	       time.sleep(0.01)

        print ("success")
        delay_result = abs(self.total_time)-abs(self.total_rtt)-(self.rtt_src['time']+self.rtt_dst['time'])/2
        print (abs(self.total_time))
        print (abs(self.total_rtt))
        print ((self.rtt_src['time']+self.rtt_dst['time'])/2)
        return delay_result 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:41,代码来源:get_delay.py

示例7: add_Link_Task

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def add_Link_Task(self, src_dpid, dst_dpid):
        self.is_loss_task = 1
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        src_port = topo.get_link_to_port(topo.network_aware.link_to_port, src_dpid, dst_dpid)[0]
        dst_port = topo.get_link_to_port(topo.network_aware.link_to_port, dst_dpid, src_dpid)[0]
        self.send_port_stats_request(self.datapaths[src_dpid], src_port)
        self.send_port_stats_request(self.datapaths[dst_dpid], dst_port)
        self.reply_count_src={'dpid':src_dpid, 'port':src_port, 'count':1}
        self.reply_count_dst={'dpid':dst_dpid, 'port':dst_port, 'count':1}

        while self.reply_count_src['count'] != 0 or self.reply_count_dst['count'] != 0 :
            time.sleep(0.01)

        self.is_loss_task = 0
        return (src_dpid, src_port, dst_dpid, dst_port) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:17,代码来源:loss_measure.py

示例8: add_Flow_Task

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def add_Flow_Task(self, src_ip, dst_ip):
        self.is_loss_task = 1

        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        flow_path = topo.flowPaths[(src_ip,dst_ip)]
        self.flow_reply_count = {'src_ip':src_ip, 'dst_ip':dst_ip, 'count':2}
        self.send_flow_stats_request(self.datapaths[flow_path[0]])
        self.send_flow_stats_request(self.datapaths[flow_path[-1]])

        while self.flow_reply_count['count'] != 0 :
            time.sleep(0.01)

        self.is_loss_task = 0
        return (src_ip, dst_ip, flow_path[0], flow_path[-1]) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:16,代码来源:loss_measure.py

示例9: add_Port_Task

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def add_Port_Task(self, src_dpid, dst_dpid):
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        src_port = topo.get_link_to_port(topo.network_aware.link_to_port, src_dpid, dst_dpid)[0]
        dst_port = topo.get_link_to_port(topo.network_aware.link_to_port, dst_dpid, src_dpid)[0]
        self.send_port_stats_request(self.datapaths[src_dpid], src_port)
        self.send_port_stats_request(self.datapaths[dst_dpid], dst_port)
        return (src_dpid, src_port, dst_dpid, dst_port) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:9,代码来源:bandwidth_measure.py

示例10: get_Flow_Bandwidth

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def get_Flow_Bandwidth(self, dpid, src_ip, dst_ip):
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        self.flow_reply_count = {'dpid':dpid, 'src_ip':src_ip, 'dst_ip':dst_ip, 'count':1}
        self.send_flow_stats_request(self.datapaths[dpid])

	while self.flow_reply_count['count'] != 0 :
            time.sleep(0.01)
	print self.flow_stats
	return (dpid, src_ip, dst_ip, self.flow_stats[dpid][(src_ip, dst_ip)][-1], self.flow_speed[dpid][(src_ip, dst_ip)][-1]) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:11,代码来源:bandwidth_measure.py

示例11: add_Flow_Task

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def add_Flow_Task(self, dpid, src_ip, dst_ip):
        topo = app_manager.lookup_service_brick('Shortest_Forwarding')
        self.flow_reply_count = {'dpid':dpid, 'src_ip':src_ip, 'dst_ip':dst_ip, 'count':1}
        self.send_flow_stats_request(self.datapaths[dpid])
        return (dpid,src_ip,dst_ip) 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:7,代码来源:bandwidth_measure.py

示例12: zclient_connection_factory

# 需要导入模块: from ryu.base import app_manager [as 别名]
# 或者: from ryu.base.app_manager import lookup_service_brick [as 别名]
def zclient_connection_factory(sock, addr):
    LOG.debug('Connected from client: %s: %s', addr, sock)
    zserv = app_manager.lookup_service_brick(ZServer.__name__)
    with contextlib.closing(ZClient(zserv, sock, addr)) as zclient:
        try:
            zclient.start()
        except Exception as e:
            LOG.error('Error in client%s: %s', addr, e)
            raise e 
开发者ID:openstack,项目名称:deb-ryu,代码行数:11,代码来源:zserver.py


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