python中scapy进行fin扫描端口,返回值一直为none

兄弟们你们好,请问我使用scapy,进行fin扫描,但是扫描的结果一直是none,就算请求不存在的ip也是这样,请问你们知道是啥原因吗

环境是centos
代码如下


#FIN scanning
def fin_scan(ip,port):
    p=IP(dst=ip)/TCP(dport=int(port),flags="F")
    ans=sr1(p,timeout=1,verbose=1)
    if ans==None:
        print(ip,"port",port,"is open.")
    elif ans!=None and ans[TCP].flags=='RA':
        ans.display()
        print(ip,"port",port,"is closed.")

检测一下你的IP和端口是否正常连接设备,可以用系统指令查询端口占用情况,如果是windows,可以参考下
https://www.runoob.com/w3cnote/windows-finds-port-usage.html