src/net/third_party/quiche/src/quic/core/quic_connection_test.cc
// This test verifies that the connection unmarks path as degrarding and spins
// the timer to detect future path degrading when forward progress is made
// after path has been marked degrading.
This test verifies that the connection unmarks path as degrarding and spins
the timer to detect future path degrading when forward progress is made
after path has been marked degrading.
This test verifies that the connection unmarks path as degrarding and spins the timer to detect future path degrading when forward progress is made after path has been marked degrading .
TEST_P(QuicConnectionTest, UnmarkPathDegradingOnForwardProgress) {
  EXPECT_TRUE(connection_.connected());
  EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
  EXPECT_FALSE(connection_.IsPathDegrading());
  const char data[] = "data";
  size_t data_size = strlen(data);
  QuicStreamOffset offset = 0;
  connection_.SendStreamDataWithString(1, data, offset, NO_FIN);
  offset += data_size;
  EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
  QuicTime::Delta delay = QuicConnectionPeer::GetSentPacketManager(&connection_)
                              ->GetPathDegradingDelay();
  if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
    EXPECT_EQ(delay, connection_.GetBlackholeDetectorAlarm()->deadline() -
                         clock_.ApproximateNow());
  } else {
    EXPECT_EQ(delay, connection_.GetPathDegradingAlarm()->deadline() -
                         clock_.ApproximateNow());
  }
  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
  QuicTime prev_deadline = connection_.GetPathDegradingAlarm()->deadline();
  if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
    prev_deadline = connection_.GetBlackholeDetectorAlarm()->deadline();
  }
  connection_.SendStreamDataWithString(1, data, offset, NO_FIN);
  offset += data_size;
  EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
  if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
    EXPECT_EQ(prev_deadline,
              connection_.GetBlackholeDetectorAlarm()->deadline());
  } else {
    EXPECT_EQ(prev_deadline, connection_.GetPathDegradingAlarm()->deadline());
  }
  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
  EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
  EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _));
  QuicAckFrame frame =
      InitAckFrame({{QuicPacketNumber(1u), QuicPacketNumber(2u)}});
  ProcessAckPacket(&frame);
  EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
  delay = QuicConnectionPeer::GetSentPacketManager(&connection_)
              ->GetPathDegradingDelay();
  if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
    EXPECT_EQ(delay, connection_.GetBlackholeDetectorAlarm()->deadline() -
                         clock_.ApproximateNow());
  } else {
    EXPECT_EQ(delay, connection_.GetPathDegradingAlarm()->deadline() -
                         clock_.ApproximateNow());
  }
  clock_.AdvanceTime(delay);
  EXPECT_CALL(visitor_, OnPathDegrading()).Times(1);
  connection_.PathDegradingTimeout();
  EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
  EXPECT_TRUE(connection_.IsPathDegrading());
  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
  EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
  connection_.SendStreamDataWithString(1, data, offset, NO_FIN);
  offset += data_size;
  EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
  EXPECT_TRUE(connection_.IsPathDegrading());
  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
  EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _));
  frame = InitAckFrame({{QuicPacketNumber(2), QuicPacketNumber(3)}});
  ProcessAckPacket(&frame);
  EXPECT_FALSE(connection_.IsPathDegrading());
  EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
}
TEST_P ( QuicConnectionTest , UnmarkPathDegradingOnForwardProgress ) { EXPECT_TRUE ( connection_ . connected ( ) ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; EXPECT_FALSE ( connection_ . IsPathDegrading ( ) ) ; const char data [ ] = " " ; size_t data_size = strlen ( data ) ; QuicStreamOffset offset = 0 ; connection_ . SendStreamDataWithString ( 1 , data , offset , NO_FIN ) ; offset += data_size ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; QuicTime :: Delta delay = QuicConnectionPeer :: GetSentPacketManager ( & connection_ ) -> GetPathDegradingDelay ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( delay , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } else { EXPECT_EQ ( delay , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; QuicTime prev_deadline = connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { prev_deadline = connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) ; } connection_ . SendStreamDataWithString ( 1 , data , offset , NO_FIN ) ; offset += data_size ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( prev_deadline , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) ) ; } else { EXPECT_EQ ( prev_deadline , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) ) ; } clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; EXPECT_CALL ( visitor_ , OnSuccessfulVersionNegotiation ( _ ) ) ; EXPECT_CALL ( * send_algorithm_ , OnCongestionEvent ( true , _ , _ , _ , _ ) ) ; QuicAckFrame frame = InitAckFrame ( { { QuicPacketNumber ( 1u ) , QuicPacketNumber ( 2u ) } } ) ; ProcessAckPacket ( & frame ) ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; delay = QuicConnectionPeer :: GetSentPacketManager ( & connection_ ) -> GetPathDegradingDelay ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( delay , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } else { EXPECT_EQ ( delay , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } clock_ . AdvanceTime ( delay ) ; EXPECT_CALL ( visitor_ , OnPathDegrading ( ) ) . Times ( 1 ) ; connection_ . PathDegradingTimeout ( ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; EXPECT_TRUE ( connection_ . IsPathDegrading ( ) ) ; clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; connection_ . SendStreamDataWithString ( 1 , data , offset , NO_FIN ) ; offset += data_size ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; EXPECT_TRUE ( connection_ . IsPathDegrading ( ) ) ; clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; EXPECT_CALL ( * send_algorithm_ , OnCongestionEvent ( true , _ , _ , _ , _ ) ) ; frame = InitAckFrame ( { { QuicPacketNumber ( 2 ) , QuicPacketNumber ( 3 ) } } ) ; ProcessAckPacket ( & frame ) ; EXPECT_FALSE ( connection_ . IsPathDegrading ( ) ) ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; }
This test verifies that the connection unmarks path as degrarding and spins
the timer to detect future path degrading when forward progress is made
after path has been marked degrading.
This test verifies that the connection unmarks path as degrarding and spins the timer to detect future path degrading when forward progress is made after path has been marked degrading .
// Send the first packet. Now there's a retransmittable packet on the wire, so // the path degrading alarm should be set. // Check the deadline of the path degrading alarm. // Send a second packet. The path degrading alarm's deadline should remain // the same. // Now receive an ACK of the first packet. This should advance the path // degrading alarm's deadline since forward progress has been made. // Check the deadline of the path degrading alarm. // Advance time to the path degrading alarm's deadline and simulate // firing the alarm. // Send a third packet. The path degrading alarm is no longer set but path // should still be marked as degrading. // Now receive an ACK of the second packet. This should unmark the path as // degrading. And will set a timer to detect new path degrading.