mirror of https://github.com/dirtbags/netarch.git
Fix for packets with data and FIN
This commit is contained in:
parent
57aca02bd1
commit
61da8aeb8b
27
ip.py
27
ip.py
|
@ -240,6 +240,7 @@ class TCP_Resequence:
|
||||||
|
|
||||||
# Does this ACK after the last output sequence number?
|
# Does this ACK after the last output sequence number?
|
||||||
seq = self.lastack[idx]
|
seq = self.lastack[idx]
|
||||||
|
self.lastack[idx] = pkt.ack
|
||||||
if pkt.ack > seq:
|
if pkt.ack > seq:
|
||||||
pending = self.pending[xdi]
|
pending = self.pending[xdi]
|
||||||
# Get a sorted list of sequence numbers
|
# Get a sorted list of sequence numbers
|
||||||
|
@ -259,14 +260,13 @@ class TCP_Resequence:
|
||||||
if key >= pkt.ack:
|
if key >= pkt.ack:
|
||||||
# In the future
|
# In the future
|
||||||
break
|
break
|
||||||
if pkt.flags & (FIN | RST):
|
frame = pending[key]
|
||||||
seq += 1
|
if key > seq:
|
||||||
self.closed[idx] = True
|
# Dropped frame(s)
|
||||||
if self.closed == [True, True]:
|
gs.append(key - seq)
|
||||||
self.handle = self.handle_drop
|
seq = key
|
||||||
if key == seq:
|
if key == seq:
|
||||||
# Default
|
# Default
|
||||||
frame = pending[key]
|
|
||||||
gs.append(frame.payload)
|
gs.append(frame.payload)
|
||||||
seq += len(frame.payload)
|
seq += len(frame.payload)
|
||||||
del pending[key]
|
del pending[key]
|
||||||
|
@ -274,19 +274,14 @@ class TCP_Resequence:
|
||||||
# Hopefully just a retransmit. Anyway we've already
|
# Hopefully just a retransmit. Anyway we've already
|
||||||
# claimed to have data (or a drop) for this packet.
|
# claimed to have data (or a drop) for this packet.
|
||||||
del pending[key]
|
del pending[key]
|
||||||
continue
|
if frame.flags & (FIN | RST):
|
||||||
elif key > seq:
|
seq += 1
|
||||||
# Dropped frame(s)
|
self.closed[idx] = True
|
||||||
gs.append(key - seq)
|
if self.closed == [True, True]:
|
||||||
seq = key
|
self.handle = self.handle_drop
|
||||||
print (seq, pkt.ack, self.closed[idx], self.closed[xdi])
|
|
||||||
if self.closed[idx]:
|
|
||||||
# FIN increments the sequence number
|
|
||||||
seq += 1
|
|
||||||
if seq != pkt.ack:
|
if seq != pkt.ack:
|
||||||
# Drop at the end
|
# Drop at the end
|
||||||
gs.append(pkt.ack - seq)
|
gs.append(pkt.ack - seq)
|
||||||
self.lastack[idx] = pkt.ack
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue