首先sr()
用於發送數據包和接收答案,而sr1()
是一種變體,它只返回發送數據包的第一個答案。你可以找到從蟒蛇的或Scapy的交互式控制檯通過鍵入help(sr1)
更多信息here,當然(或任何其他功能),您可以查看有關功能的詳細信息:
sr1(x, filter=None, iface=None, nofilter=0, *args, **kargs)
Send packets at layer 3 and return only the first answer
nofilter: put 1 to avoid use of bpf filters
retry: if positive, how many times to resend unanswered packets
if negative, how many times to retry when no more packets are answered
timeout: how much time to wait after the last packet has been sent
verbose: set verbosity level
multi: whether to accept multiple answers for the same stimulus
filter: provide a BPF filter
iface: listen answers only on the given interface
我們4次發送的數據包在一排並得到他們每個人的答案,你可以簡單地嘗試:
非常感謝你! – roye1233
@ roye1233,很高興幫助! – coder