Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions scapy/sendrecv.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,24 +485,25 @@ 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

: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
Expand All @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion scapy/supersocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down