Skip to content

Commit

Permalink
Merge pull request #1449 from microsoft/bugfix-inetstack-close-corout…
Browse files Browse the repository at this point in the history
…ines

Bug Fix: Retransmit FIN on close
  • Loading branch information
iyzhang authored Nov 1, 2024
2 parents bf69f14 + f7be6ef commit ffeda7a
Show file tree
Hide file tree
Showing 7 changed files with 468 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// Receive ACK on data packet.
+.1 TCP < . seq 1(0) ack 1001 win 65535 <nop>

// Send FIN again since no ack on it yet.
+.0 TCP > F. seq 1001(0) ack 1 win 65535 <nop>

// Send completes
+.0 wait(500, ...) = 9

Expand Down
38 changes: 38 additions & 0 deletions network_simulator/input/tcp/close/close-remote-retransmission.pkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Tests for remote close.

// Establish a connection.
+.0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 500
+.2 connect(500, ..., ...) = 0

// Send SYN segment.
+.0 TCP > S seq 0(0) win 65535 <mss 1450, wscale 0>
// Receive SYN-ACK segment.
+.1 TCP < S. seq 0(0) ack 1 win 65535 <mss 1450, wscale 0>
// Send ACK on SYN-ACK segment.
+.0 TCP > . seq 1(0) ack 1 win 65535 <nop>

// Succeed to establish connection.
+.0 wait(500, ...) = 0

// Receive FIN segment.
+.1 TCP < F. seq 1(0) ack 1 win 65535 <nop>
// Send ACK on FIN segment.
+.0 TCP > . seq 1(0) ack 2 win 65534 <nop>

// Close connection.
+.2 close(500) = 0

// Send FIN segment.
+.0 TCP > F. seq 1(0) ack 2 win 65534 <nop>

// Re-send FIN segment.
+1 TCP > F. seq 1(0) ack 2 win 65534 <nop>

// Re-send FIN segment.
+3 TCP > F. seq 1(0) ack 2 win 65534 <nop>

// Receive ACK on FIN segment.
+.1 TCP < . seq 2(0) ack 2 win 65535 <nop>

// Succeed to close connection immediately.
+.0 wait(500, ...) = 0
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ pub async fn background(cb: SharedControlBlock, _dead_socket_tx: mpsc::Unbounded
let receiver = async_timer!("tcp::established::background::receiver", cb2.poll()).fuse();
pin_mut!(receiver);

let r = futures::select_biased! {
r = receiver => r,
r = acknowledger => r,
r = retransmitter => r,
r = sender => r,
};
let r = futures::join!(receiver, acknowledger, retransmitter, sender);
error!("Connection terminated: {:?}", r);
}
Loading

0 comments on commit ffeda7a

Please sign in to comment.