Fix TCP sequence number in multiple consecutive non-ACKed data packets.

This commit is contained in:
whitequark 2016-12-27 20:39:46 +00:00
parent 17f96ba929
commit feaef0d7c4
1 changed files with 20 additions and 0 deletions

View File

@ -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();