Before this CL, a message was identified by the triple (stream_id, is_unordered, MID) (and yes, the MID is always present in the send queue, even when interleaved message is not enabled.). So when a chunk was abandoned due to e.g. having reached the retransmission limit, all other chunks for that message in the retransmission queue, and all unsent chunks in the send queue were discarded as well. This works well, except for the fact that resetting a stream will result in the MID being set to zero again, which can result in two different messages having the same identifying triple. And due to the implementation, both messages would get abandoned. In WebRTC, an entire data channels is either reliable or unreliable, and for a message to be abandoned, the channel must be unreliable. So this means that in the case of stream resets - meaning that a channel was closed and then reopened, an abandoned message from the old (now closed) channel would result in abandoning another message sent on the re-opened data channel. This CL introduces a new internal property on messages while in the retransmission and send queue; The "outgoing message id". It's a monotonically increasing identifier - shared among all streams - that is never reset to zero in the event of a stream reset. And now a message is actually only identified by the outgoing message id, but often used together with the stream identifier, as all data in the send queue is partitioned by stream. This identifier is 32 bits wide, allowing at most four billion messages to be in-flight, which is not a limitation, as the TSN is also 32 bits wide. Bug: webrtc:14600 Change-Id: I33c23fb0e4bde95327b15d1999e76aa43f5fa7db Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/322603 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Victor Boivie <boivie@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40881}
61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_
|
|
#define NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/array_view.h"
|
|
#include "net/dcsctp/tx/send_queue.h"
|
|
#include "test/gmock.h"
|
|
|
|
namespace dcsctp {
|
|
|
|
class MockSendQueue : public SendQueue {
|
|
public:
|
|
MockSendQueue() {
|
|
ON_CALL(*this, Produce).WillByDefault([](TimeMs now, size_t max_size) {
|
|
return absl::nullopt;
|
|
});
|
|
}
|
|
|
|
MOCK_METHOD(absl::optional<SendQueue::DataToSend>,
|
|
Produce,
|
|
(TimeMs now, size_t max_size),
|
|
(override));
|
|
MOCK_METHOD(bool,
|
|
Discard,
|
|
(StreamID stream_id, OutgoingMessageId message_id),
|
|
(override));
|
|
MOCK_METHOD(void, PrepareResetStream, (StreamID stream_id), (override));
|
|
MOCK_METHOD(bool, HasStreamsReadyToBeReset, (), (const, override));
|
|
MOCK_METHOD(std::vector<StreamID>, GetStreamsReadyToBeReset, (), (override));
|
|
MOCK_METHOD(void, CommitResetStreams, (), (override));
|
|
MOCK_METHOD(void, RollbackResetStreams, (), (override));
|
|
MOCK_METHOD(void, Reset, (), (override));
|
|
MOCK_METHOD(size_t, buffered_amount, (StreamID stream_id), (const, override));
|
|
MOCK_METHOD(size_t, total_buffered_amount, (), (const, override));
|
|
MOCK_METHOD(size_t,
|
|
buffered_amount_low_threshold,
|
|
(StreamID stream_id),
|
|
(const, override));
|
|
MOCK_METHOD(void,
|
|
SetBufferedAmountLowThreshold,
|
|
(StreamID stream_id, size_t bytes),
|
|
(override));
|
|
MOCK_METHOD(void, EnableMessageInterleaving, (bool enabled), (override));
|
|
};
|
|
|
|
} // namespace dcsctp
|
|
|
|
#endif // NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_
|