Skip to content

Commit

Permalink
Fix TCP sequence number in multiple consecutive non-ACKed data packets.
Browse files Browse the repository at this point in the history
whitequark committed Dec 27, 2016
1 parent 0c0ed84 commit 947e9eb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -662,6 +662,7 @@ impl<'a> TcpSocket<'a> {
// Send the extracted data.
net_trace!("tcp:{}:{}: tx buffer: peeking at {} octets (from {})",
self.local_endpoint, self.remote_endpoint, data.len(), offset);
repr.seq_number += offset;
repr.payload = data;
// Speculatively shrink the remote window. This will get updated the next
// time we receive a packet.
@@ -1035,6 +1036,25 @@ mod test {
assert_eq!(s.tx_buffer.len(), 0);
}

#[test]
fn test_established_send_no_ack_send() {
let mut s = socket_established();
s.tx_buffer.enqueue_slice(b"abcdef");
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}]);
s.tx_buffer.enqueue_slice(b"foobar");
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1 + 6,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"foobar"[..],
..RECV_TEMPL
}]);
}

#[test]
fn test_established_send_buf_gt_win() {
let mut s = socket_established();

0 comments on commit 947e9eb

Please sign in to comment.