src/net/third_party/quiche/src/quic/core/quic_connection_test.cc
// This test verifies that the connection marks path as degrading and does not
// spin timer to detect path degrading when a new packet is sent on the
// degraded path.
This test verifies that the connection marks path as degrading and does not
spin timer to detect path degrading when a new packet is sent on the
degraded path.
This test verifies that the connection marks path as degrading and does not spin timer to detect path degrading when a new packet is sent on the degraded path .
TEST_P(QuicConnectionTest, NoPathDegradingAlarmIfPathIsDegrading) {
  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());
}
TEST_P ( QuicConnectionTest , NoPathDegradingAlarmIfPathIsDegrading ) { 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 ( ) ) ; }
This test verifies that the connection marks path as degrading and does not
spin timer to detect path degrading when a new packet is sent on the
degraded path.
This test verifies that the connection marks path as degrading and does not spin timer to detect path degrading when a new packet is sent on the degraded path .
// 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 path degrading alarm. This path will be considered as // degrading. // Send a third packet. The path degrading alarm is no longer set but path // should still be marked as degrading.