我正在尝试与从互联网上下载的服务器进行握手。但是,当客户端收到[SYN,ACK]时,它将发回[RST]。不知道发生了什么事。已经检查了确认和序列号,但是一切正常。
在wireshark中,我得到了:
这里是握手客户端源代码:
from scapy.all import *
src_ip = "192.168.43.34"
dst_ip = "192.168.43.115"
src_port = random.randint(1024, 65535)
dst_port = 502
seq_nr = random.randint(444, 8765432)
ack_nr = 0
# Create SYN packet
ip = IP (src = src_ip, dst = dst_ip)
syn = TCP(sport = src_port, dport = dst_port, flags='S', seq = seq_nr, ack = ack_nr)
pkt_syn = ip / syn
pkt_syn.show()
# send SYN packet and receive SYN/ACK packet
print('Sending SYN')
pkt_syn_ack = sr1(pkt_syn)
print('ACK received')
pkt_syn_ack.show()
# Create the ACK packet
ack_nr = pkt_syn_ack.seq + 1
seq_nr = seq_nr + 1
ack = TCP(sport = src_port, dport = dst_port, flags = 'A', seq = seq_nr, ack = ack_nr)
send(ip / ack)
...
[它发送回[RST]-服务器可能已崩溃,并且由于当前未在侦听该端口,而OS使用RST
响应了任何传入的TCP段。