Esempio n. 1
0
            passed = True
        os.remove('capture.pcap')
    except RpcError as e:
        raise
    finally:
        drone.stopTransmit(tx_port)
        suite.test_end(passed)

    # ----------------------------------------------------------------- #
    # TESTCASE: Verify invoking stopTransmit() when transmit is not running
    #           is a NOP
    # ----------------------------------------------------------------- #
    passed = False
    suite.test_begin('stopTransmitWhenTransmitNotRunningIsNop')
    try:
        tx_stats = drone.getStats(tx_port)
        log.info('--> (tx_stats)' + tx_stats.__str__())
        if tx_stats.port_stats[0].state.is_transmit_on:
            raise Exception('Unexpected transmit ON state')
        log.info('stopping transmit multiple times')
        drone.stopTransmit(tx_port)
        time.sleep(1)
        drone.stopTransmit(tx_port)
        time.sleep(1)
        drone.stopTransmit(tx_port)

        # if we reached here, that means there was no exception
        passed = True
    except RpcError as e:
        raise
    finally:
Esempio n. 2
0
    log.info('starting transmit')
    drone.startTransmit(tx_port)

    # wait for transmit to finish
    log.info('waiting for transmit to finish ...')
    time.sleep(7)

    # stop transmit and capture
    log.info('stopping transmit')
    drone.stopTransmit(tx_port)
    log.info('stopping capture')
    drone.stopCapture(rx_port)

    # get tx/rx stats
    log.info('retreiving stats')
    tx_stats = drone.getStats(tx_port)
    rx_stats = drone.getStats(rx_port)

    #log.info('--> (tx_stats)' + tx_stats.__str__())
    #log.info('--> (rx_stats)' + rx_stats.__str__())
    log.info('tx pkts = %d, rx pkts = %d' % 
            (tx_stats.port_stats[0].tx_pkts, rx_stats.port_stats[0].rx_pkts))

    # retrieve and dump received packets
    log.info('getting Rx capture buffer')
    buff = drone.getCaptureBuffer(rx_port.port_id[0])
    drone.saveCaptureBuffer(buff, 'capture.pcap')
    log.info('dumping Rx capture buffer')
    os.system('tshark -r capture.pcap')
    os.remove('capture.pcap')