MCPcopy Create free account
hub / github.com/secdev/scapy / sendpfast

Function sendpfast

scapy/sendrecv.py:535–612  ·  view source on GitHub ↗

Send packets at layer 2 using tcpreplay for performance :param pps: packets per second :param mbps: MBits per second :param realtime: use packet's timestamp, bending time with real-time value :param loop: send the packet indefinitely (default 0) :param count: number of packets

(x: _PacketIterable,
              pps: Optional[float] = None,
              mbps: Optional[float] = None,
              realtime: bool = False,
              count: Optional[int] = None,
              loop: int = 0,
              file_cache: bool = False,
              iface: Optional[_GlobInterfaceType] = None,
              replay_args: Optional[List[str]] = None,
              parse_results: bool = False,
              )

Source from the content-addressed store, hash-verified

533
534@conf.commands.register
535def sendpfast(x: _PacketIterable,
536 pps: Optional[float] = None,
537 mbps: Optional[float] = None,
538 realtime: bool = False,
539 count: Optional[int] = None,
540 loop: int = 0,
541 file_cache: bool = False,
542 iface: Optional[_GlobInterfaceType] = None,
543 replay_args: Optional[List[str]] = None,
544 parse_results: bool = False,
545 ):
546 # type: (...) -> Optional[Dict[str, Any]]
547 """Send packets at layer 2 using tcpreplay for performance
548
549 :param pps: packets per second
550 :param mbps: MBits per second
551 :param realtime: use packet's timestamp, bending time with real-time value
552 :param loop: send the packet indefinitely (default 0)
553 :param count: number of packets to send (default None=1)
554 :param file_cache: cache packets in RAM instead of reading from
555 disk at each iteration
556 :param iface: output interface
557 :param replay_args: List of additional tcpreplay args (List[str])
558 :param parse_results: Return a dictionary of information
559 outputted by tcpreplay (default=False)
560 :returns: stdout, stderr, command used
561 """
562 if iface is None:
563 iface = conf.iface
564 argv = [conf.prog.tcpreplay, "--intf1=%s" % network_name(iface)]
565 if pps is not None:
566 argv.append("--pps=%f" % pps)
567 elif mbps is not None:
568 argv.append("--mbps=%f" % mbps)
569 elif realtime is not None:
570 argv.append("--multiplier=%f" % realtime)
571 else:
572 argv.append("--topspeed")
573
574 if count:
575 assert not loop, "Can't use loop and count at the same time in sendpfast"
576 argv.append("--loop=%i" % count)
577 elif loop:
578 argv.append("--loop=0")
579 if file_cache:
580 argv.append("--preload-pcap")
581
582 # Check for any additional args we didn't cover.
583 if replay_args is not None:
584 argv.extend(replay_args)
585
586 f = get_temp_file()
587 argv.append(f)
588 wrpcap(f, x)
589 results = None
590 with ContextManagerSubprocess(conf.prog.tcpreplay):
591 try:
592 cmd = subprocess.Popen(argv, stdout=subprocess.PIPE,

Callers

nothing calls this directly

Calls 8

network_nameFunction · 0.90
get_temp_fileFunction · 0.90
wrpcapFunction · 0.90
_parse_tcpreplay_resultFunction · 0.85
extendMethod · 0.80
decodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…