def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, verbose=True):
    """Send packets at layer 2 using tcpreplay for performance
    pps:  packets per second
    mpbs: MBits per second
    realtime: use packet's timestamp, bending time with realtime value
    loop: number of times to process the packet list
    file_cache: cache packets in RAM instead of reading from disk at each iteration
    iface: output interface
    verbose: if False, discard tcpreplay output """
    if iface is None:
        iface = conf.iface
    argv = [conf.prog.tcpreplay, "--intf1=%s" % iface ]
    if pps is not None:
        argv.append("--pps=%i" % pps)
    elif mbps is not None:
        argv.append("--mbps=%f" % mbps)
    elif realtime is not None:
        argv.append("--multiplier=%i" % realtime)
    else:
        argv.append("--topspeed")
    if not verbose:
        argv.append("-q")
    if loop:
        argv.append("--loop=%i" % loop)
        if file_cache:
            argv.append("--enable-file-cache")

    f = get_temp_file()
    argv.append(f)
    wrpcap(f, x)
    with open(os.devnull, "wb") as null:
        proc_output = null if not verbose else None
        try:
            subprocess.check_call(argv,
                                  stdout=proc_output,
                                  stderr=proc_output)
        except KeyboardInterrupt:
            log_interactive.info("Interrupted by user")
        except Exception as e:
            log_interactive.error("while trying to exec [%s]: %s" % (argv[0],e))
        finally:
            os.unlink(f)
def sendpfast ( x , pps = None , mbps = None , realtime = None , loop = 0 , file_cache = False , iface = None , verbose = True ) : if iface is None : iface = conf . iface argv = [ conf . prog . tcpreplay , "--intf1=%s" % iface ] if pps is not None : argv . append ( "--pps=%i" % pps ) elif mbps is not None : argv . append ( "--mbps=%f" % mbps ) elif realtime is not None : argv . append ( "--multiplier=%i" % realtime ) else : argv . append ( "--topspeed" ) if not verbose : argv . append ( "-q" ) if loop : argv . append ( "--loop=%i" % loop ) if file_cache : argv . append ( "--enable-file-cache" ) f = get_temp_file ( ) argv . append ( f ) wrpcap ( f , x ) with open ( os . devnull , "wb" ) as null : proc_output = null if not verbose else None try : subprocess . check_call ( argv , stdout = proc_output , stderr = proc_output ) except KeyboardInterrupt : log_interactive . info ( "Interrupted by user" ) except Exception as e : log_interactive . error ( "while trying to exec [%s]: %s" % ( argv [ 0 ] , e ) ) finally : os . unlink ( f )
Send packets at layer 2 using tcpreplay for performance
    pps:  packets per second
    mpbs: MBits per second
    realtime: use packet's timestamp, bending time with realtime value
    loop: number of times to process the packet list
    file_cache: cache packets in RAM instead of reading from disk at each iteration
    iface: output interface
    verbose: if False, discard tcpreplay output