本文整理汇总了Python中traffic.core.helpers.Receiver.recv方法的典型用法代码示例。如果您正苦于以下问题:Python Receiver.recv方法的具体用法?Python Receiver.recv怎么用?Python Receiver.recv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traffic.core.helpers.Receiver
的用法示例。
在下文中一共展示了Receiver.recv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_traffic_flow
# 需要导入模块: from traffic.core.helpers import Receiver [as 别名]
# 或者: from traffic.core.helpers.Receiver import recv [as 别名]
def verify_traffic_flow(self, src_vm, dst_vm):
fab_connections.clear()
vm_list = [src_vm, dst_vm]
for vm in vm_list:
out = vm.wait_till_vm_is_up()
if out == False:
return {'result': out, 'msg': "%s failed to come up" % vm.vm_name}
else:
self.logger.info('Installing Traffic package on %s ...' %
vm.vm_name)
vm.install_pkg("Traffic")
self.logger.info("-" * 80)
self.logger.info('Starting TCP Traffic from %s to %s' %
(src_vm.vm_ip, dst_vm.vm_ip))
self.logger.info("-" * 80)
stream_list = []
profile = {}
sender = {}
receiver = {}
tx_vm_node_ip = self.inputs.host_data[
self.nova_fixture.get_nova_host_of_vm(src_vm.vm_obj)]['host_ip']
tx_local_host = Host(
tx_vm_node_ip, self.inputs.username, self.inputs.password)
send_host = Host(src_vm.local_ip, src_vm.vm_username,
src_vm.vm_password)
rx_vm_node_ip = self.inputs.host_data[
self.nova_fixture.get_nova_host_of_vm(dst_vm.vm_obj)]['host_ip']
rx_local_host = Host(
rx_vm_node_ip, self.inputs.username, self.inputs.password)
recv_host = Host(dst_vm.local_ip, dst_vm.vm_username,
dst_vm.vm_password)
stream1 = Stream(protocol="ip", proto="tcp", src=src_vm.vm_ip,
dst=dst_vm.vm_ip, sport=8000, dport=9000)
stream2 = Stream(protocol="ip", proto="tcp", src=src_vm.vm_ip,
dst=dst_vm.vm_ip, sport=8000, dport=9001)
stream3 = Stream(protocol="ip", proto="tcp", src=src_vm.vm_ip,
dst=dst_vm.vm_ip, sport=8000, dport=9002)
count = 0
stream_list = [stream1, stream2, stream3]
for stream in stream_list:
profile[stream] = {}
sender[stream] = {}
receiver[stream] = {}
count = count + 1
send_filename = 'sendtcp_%s' % count
recv_filename = 'recvtcp_%s' % count
profile[stream] = ContinuousProfile(
stream=stream, listener=dst_vm.vm_ip, chksum=True)
sender[stream] = Sender(
send_filename, profile[stream], tx_local_host, send_host, self.inputs.logger)
receiver[stream] = Receiver(
recv_filename, profile[stream], rx_local_host, recv_host, self.inputs.logger)
receiver[stream].start()
sender[stream].start()
self.logger.info('Sending traffic for 10 seconds')
time.sleep(10)
self.logger.info('Checking Flow records')
flow_result = False
flow_result2 = False
flow_result3 = False
rev_flow_result = False
rev_flow_result1 = False
rev_flow_result2 = False
src_vm_vrf_name = src_vm.vn_fq_name + ':' + src_vm.vn_name
vn_vrf_id = src_vm.get_vrf_id(src_vm.vn_fq_name, src_vm_vrf_name)
src_port = unicode(8000)
dpi1 = unicode(9000)
dpi2 = unicode(9001)
dpi3 = unicode(9002)
dpi_list = [dpi1, dpi2, dpi3]
vm_node_ips = []
vm_node_ips.append(src_vm.vm_node_ip)
if (src_vm.vm_node_ip != dst_vm.vm_node_ip):
vm_node_ips.append(dst_vm.vm_node_ip)
# inspect_h100= self.agent_inspect[src_vm.vm_node_ip]
# flow_rec1= inspect_h100.get_vna_fetchflowrecord(vrf=vn_vrf_id,sip=src_vm.vm_ip,dip=dst_vm.vm_ip,sport=src_port,dport=dpi1,protocol='6')
# flow_rec2= inspect_h100.get_vna_fetchflowrecord(vrf=vn_vrf_id,sip=src_vm.vm_ip,dip=dst_vm.vm_ip,sport=src_port,dport=dpi2,protocol='6')
# flow_rec3= inspect_h100.get_vna_fetchflowrecord(vrf=vn_vrf_id,sip=src_vm.vm_ip,dip=dst_vm.vm_ip,sport=src_port,dport=dpi3,protocol='6')
# flow_recs= []
# flow_recs= [flow_rec1, flow_rec2, flow_rec3]
# print flow_recs
# flow_result= True
# i= 0
# for flow_rec in flow_recs:
# if flow_rec is None:
# flow_result= False
# if flow_result is True:
# i += 1
# self.logger.info('%s Flows from %s to %s exist on Agent %s'%(i, src_vm.vm_ip, dst_vm.vm_ip, src_vm.vm_node_ip))
#.........这里部分代码省略.........