本文整理汇总了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)
示例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]))
示例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])
示例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)
示例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
示例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
示例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)
示例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])
示例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)
示例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])
示例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)
示例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