dcsctp: Fix incorrect merge conflict from last CL

A refactoring was lost after revision 3 of
https://webrtc-review.googlesource.com/c/src/+/377122
due to an incorrect merging/cherry-picking.

Reapplied it.

Bug: webrtc:396373001
Change-Id: Ice7a8e94ad984cb308eb9cab83df2e9ecca3d53c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/377283
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43912}
This commit is contained in:
Victor Boivie 2025-02-18 11:27:22 +01:00 committed by WebRTC LUCI CQ
parent f052c432fe
commit b9f8636c5a
2 changed files with 16 additions and 24 deletions

View File

@ -456,12 +456,23 @@ std::vector<std::pair<TSN, Data>> RetransmissionQueue::GetChunksToSend(
size_t old_unacked_packet_bytes = unacked_packet_bytes();
size_t old_rwnd = rwnd_;
// Calculate the bandwidth budget (how many bytes that is
// allowed to be sent), and fill that up first with chunks that are
// scheduled to be retransmitted. If there is still budget, send new chunks
// (which will have their TSN assigned here.)
// Calculate the bandwidth budget (how many bytes that is allowed to be sent).
size_t max_packet_bytes_allowed_by_cwnd =
old_unacked_packet_bytes >= cwnd_ ? 0 : cwnd_ - old_unacked_packet_bytes;
size_t max_packet_bytes_allowed_by_rwnd =
RoundUpTo4(rwnd() + data_chunk_header_size_);
if (outstanding_data_.unacked_items() == 0) {
// https://datatracker.ietf.org/doc/html/rfc4960#section-6.1
// ... However, regardless of the value of rwnd (including if it is 0), the
// data sender can always have one DATA chunk in flight to the receiver if
// allowed by cwnd (see rule B, below).
max_packet_bytes_allowed_by_rwnd = options_.mtu;
}
size_t max_bytes =
RoundDownTo4(std::min(max_bytes_to_send(), bytes_remaining_in_packet));
RoundDownTo4(std::min(std::min(max_packet_bytes_allowed_by_cwnd,
max_packet_bytes_allowed_by_rwnd),
bytes_remaining_in_packet));
to_be_sent = outstanding_data_.GetChunksToBeRetransmitted(max_bytes);
@ -544,21 +555,6 @@ bool RetransmissionQueue::ShouldSendForwardTsn(Timestamp now) {
return ret;
}
size_t RetransmissionQueue::max_bytes_to_send() const {
size_t left =
unacked_packet_bytes() >= cwnd_ ? 0 : cwnd_ - unacked_packet_bytes();
if (unacked_packet_bytes() == 0) {
// https://datatracker.ietf.org/doc/html/rfc4960#section-6.1
// ... However, regardless of the value of rwnd (including if it is 0), the
// data sender can always have one DATA chunk in flight to the receiver if
// allowed by cwnd (see rule B, below).
return left;
}
return std::min(rwnd(), left);
}
void RetransmissionQueue::PrepareResetStream(StreamID stream_id) {
// TODO(boivie): These calls are now only affecting the send queue. The
// packet buffer can also change behavior - for example draining the chunk

View File

@ -210,10 +210,6 @@ class RetransmissionQueue {
: CongestionAlgorithmPhase::kCongestionAvoidance;
}
// Returns the number of bytes that may be sent in a single packet according
// to the congestion control algorithm.
size_t max_bytes_to_send() const;
DcSctpSocketCallbacks& callbacks_;
const DcSctpOptions options_;
// If the peer supports RFC3758 - SCTP Partial Reliability Extension.