diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py index 5c7a5a2b3c5..c62ecc6901e 100644 --- a/scapy/sendrecv.py +++ b/scapy/sendrecv.py @@ -485,15 +485,16 @@ def sendp(x, # type: _PacketIterable @conf.commands.register -def sendpfast(x, # type: _PacketIterable - pps=None, # type: Optional[float] - mbps=None, # type: Optional[float] - realtime=False, # type: bool - loop=None, # type: Optional[int] - file_cache=False, # type: bool - iface=None, # type: Optional[_GlobInterfaceType] - replay_args=None, # type: Optional[List[str]] - parse_results=False, # type: bool +def sendpfast(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, ): # type: (...) -> Optional[Dict[str, Any]] """Send packets at layer 2 using tcpreplay for performance @@ -501,8 +502,8 @@ def sendpfast(x, # type: _PacketIterable :param pps: packets per second :param mbps: MBits per second :param realtime: use packet's timestamp, bending time with real-time value - :param loop: number of times to process the packet list. 0 implies - infinite loop + :param loop: send the packet indefinitely (default 0) + :param count: number of packets to send (default None=1) :param file_cache: cache packets in RAM instead of reading from disk at each iteration :param iface: output interface @@ -523,8 +524,11 @@ def sendpfast(x, # type: _PacketIterable else: argv.append("--topspeed") - if loop is not None: - argv.append("--loop=%i" % loop) + if count: + assert not loop, "Can't use loop and count at the same time in sendpfast" + argv.append("--loop=%i" % count) + elif loop: + argv.append("--loop=0") if file_cache: argv.append("--preload-pcap") diff --git a/scapy/supersocket.py b/scapy/supersocket.py index 06f7019a78f..0a05749f214 100644 --- a/scapy/supersocket.py +++ b/scapy/supersocket.py @@ -214,7 +214,7 @@ def close(self): def sr(self, *args, **kargs): # type: (Any, Any) -> Tuple[SndRcvList, PacketList] from scapy import sendrecv - ans, unans = sendrecv.sndrcv(self, *args, **kargs) # type: SndRcvList, PacketList # noqa: E501 + ans, unans = sendrecv.sndrcv(self, *args, **kargs) return ans, unans def sr1(self, *args, **kargs):