當前位置: 首頁>>代碼示例>>Python>>正文


Python Receiver.recv方法代碼示例

本文整理匯總了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))

#.........這裏部分代碼省略.........
開發者ID:rishiv,項目名稱:contrail-test,代碼行數:103,代碼來源:ecmp_traffic.py


注:本文中的traffic.core.helpers.Receiver.recv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。