Fix bug in TCP implementation (simulations).
The problem was that only ACKed packets were subtracted from in_flight_, but lost packets were never removed, which caused TCP to stop sending eventually. R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43239004 Cr-Commit-Position: refs/heads/master@{#9041}
This commit is contained in:
parent
e62202fedf
commit
5f92051f06
@ -295,10 +295,12 @@ void TcpSender::UpdateCongestionControl(const FeedbackPacket* fb) {
|
||||
DCHECK(!tcp_fb->acked_packets().empty());
|
||||
ack_received_ = true;
|
||||
|
||||
in_flight_ -= static_cast<int>(tcp_fb->acked_packets().size());
|
||||
DCHECK_GE(in_flight_, 0);
|
||||
uint16_t expected = tcp_fb->acked_packets().back() - last_acked_seq_num_;
|
||||
in_flight_ -= expected;
|
||||
uint16_t missing =
|
||||
expected - static_cast<uint16_t>(tcp_fb->acked_packets().size());
|
||||
|
||||
if (LossEvent(tcp_fb->acked_packets())) {
|
||||
if (missing > 0) {
|
||||
cwnd_ /= 2.0f;
|
||||
in_slow_start_ = false;
|
||||
} else if (in_slow_start_) {
|
||||
@ -311,12 +313,6 @@ void TcpSender::UpdateCongestionControl(const FeedbackPacket* fb) {
|
||||
LatestSequenceNumber(tcp_fb->acked_packets().back(), last_acked_seq_num_);
|
||||
}
|
||||
|
||||
bool TcpSender::LossEvent(const std::vector<uint16_t>& acked_packets) {
|
||||
uint16_t expected = acked_packets.back() - last_acked_seq_num_;
|
||||
uint16_t missing = expected - static_cast<uint16_t>(acked_packets.size());
|
||||
return missing > 0;
|
||||
}
|
||||
|
||||
Packets TcpSender::GeneratePackets(size_t num_packets) {
|
||||
Packets generated;
|
||||
for (size_t i = 0; i < num_packets; ++i) {
|
||||
|
@ -108,19 +108,20 @@ class TcpSender : public PacketSender {
|
||||
: PacketSender(listener, flow_id),
|
||||
now_ms_(0),
|
||||
in_slow_start_(false),
|
||||
cwnd_(1),
|
||||
cwnd_(10),
|
||||
in_flight_(0),
|
||||
ack_received_(false),
|
||||
last_acked_seq_num_(0),
|
||||
next_sequence_number_(0) {}
|
||||
|
||||
virtual ~TcpSender() {}
|
||||
|
||||
void RunFor(int64_t time_ms, Packets* in_out) override;
|
||||
int GetFeedbackIntervalMs() const override { return 10; }
|
||||
|
||||
private:
|
||||
void SendPackets(Packets* in_out);
|
||||
void UpdateCongestionControl(const FeedbackPacket* fb);
|
||||
bool LossEvent(const std::vector<uint16_t>& acked_packets);
|
||||
Packets GeneratePackets(size_t num_packets);
|
||||
|
||||
int64_t now_ms_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user