src/net/third_party/quiche/src/quic/core/quic_connection_test.cc
// Receive a path probe request at the server side, i.e.,
// in non-IETF version: receive a padded PING packet with a peer addess change;
// in IETF version: receive a packet contains PATH CHALLENGE with peer address
// change.
Receive a path probe request at the server side, i.e.,
in non-IETF version: receive a padded PING packet with a peer addess change;
in IETF version: receive a packet contains PATH CHALLENGE with peer address
change.
Receive a path probe request at the server side i . e . in non - IETF version : receive a padded PING packet with a peer addess change ; in IETF version : receive a packet contains PATH CHALLENGE with peer address change .
TEST_P(QuicConnectionTest, ReceivePathProbingAtServer) {
  set_perspective(Perspective::IS_SERVER);
  QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false);
  EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective());
  QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress());
  QuicConnectionPeer::SetEffectivePeerAddress(&connection_,
                                              QuicSocketAddress());
  EXPECT_FALSE(connection_.effective_peer_address().IsInitialized());
  QuicFrame frame;
  if (QuicVersionUsesCryptoFrames(connection_.transport_version())) {
    frame = QuicFrame(&crypto_frame_);
    EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber());
  } else {
    frame = QuicFrame(QuicStreamFrame(
        QuicUtils::GetCryptoStreamId(connection_.transport_version()), false,
        0u, quiche::QuicheStringPiece()));
    EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber());
  }
  ProcessFramePacketWithAddresses(frame, kSelfAddress, kPeerAddress);
  EXPECT_EQ(kPeerAddress, connection_.peer_address());
  EXPECT_EQ(kPeerAddress, connection_.effective_peer_address());
  EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0);
  if (!GetParam().version.HasIetfQuicFrames()) {
    EXPECT_CALL(visitor_,
                OnPacketReceived(_, _, true))
        .Times(1);
  } else {
    EXPECT_CALL(visitor_, OnPacketReceived(_, _, _)).Times(0);
  }
  const QuicSocketAddress kNewPeerAddress =
      QuicSocketAddress(QuicIpAddress::Loopback6(), 23456);
  OwningSerializedPacketPointer probing_packet = ConstructProbingPacket();
  std::unique_ptr<QuicReceivedPacket> received(ConstructReceivedPacket(
      QuicEncryptedPacket(probing_packet->encrypted_buffer,
                          probing_packet->encrypted_length),
      clock_.Now()));
  uint64_t num_probing_received =
      connection_.GetStats().num_connectivity_probing_received;
  ProcessReceivedPacket(kSelfAddress, kNewPeerAddress, *received);
  EXPECT_EQ(num_probing_received + 1,
            connection_.GetStats().num_connectivity_probing_received);
  EXPECT_EQ(kPeerAddress, connection_.peer_address());
  EXPECT_EQ(kPeerAddress, connection_.effective_peer_address());
  EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0);
  ProcessFramePacketWithAddresses(frame, kSelfAddress, kPeerAddress);
  EXPECT_EQ(kPeerAddress, connection_.peer_address());
  EXPECT_EQ(kPeerAddress, connection_.effective_peer_address());
}
TEST_P ( QuicConnectionTest , ReceivePathProbingAtServer ) { set_perspective ( Perspective :: IS_SERVER ) ; QuicPacketCreatorPeer :: SetSendVersionInPacket ( creator_ , false ) ; EXPECT_EQ ( Perspective :: IS_SERVER , connection_ . perspective ( ) ) ; QuicConnectionPeer :: SetDirectPeerAddress ( & connection_ , QuicSocketAddress ( ) ) ; QuicConnectionPeer :: SetEffectivePeerAddress ( & connection_ , QuicSocketAddress ( ) ) ; EXPECT_FALSE ( connection_ . effective_peer_address ( ) . IsInitialized ( ) ) ; QuicFrame frame ; if ( QuicVersionUsesCryptoFrames ( connection_ . transport_version ( ) ) ) { frame = QuicFrame ( & crypto_frame_ ) ; EXPECT_CALL ( visitor_ , OnCryptoFrame ( _ ) ) . Times ( AnyNumber ( ) ) ; } else { frame = QuicFrame ( QuicStreamFrame ( QuicUtils :: GetCryptoStreamId ( connection_ . transport_version ( ) ) , false , 0u , quiche :: QuicheStringPiece ( ) ) ) ; EXPECT_CALL ( visitor_ , OnStreamFrame ( _ ) ) . Times ( AnyNumber ( ) ) ; } ProcessFramePacketWithAddresses ( frame , kSelfAddress , kPeerAddress ) ; EXPECT_EQ ( kPeerAddress , connection_ . peer_address ( ) ) ; EXPECT_EQ ( kPeerAddress , connection_ . effective_peer_address ( ) ) ; EXPECT_CALL ( visitor_ , OnConnectionMigration ( PORT_CHANGE ) ) . Times ( 0 ) ; if ( ! GetParam ( ) . version . HasIetfQuicFrames ( ) ) { EXPECT_CALL ( visitor_ , OnPacketReceived ( _ , _ , true ) ) . Times ( 1 ) ; } else { EXPECT_CALL ( visitor_ , OnPacketReceived ( _ , _ , _ ) ) . Times ( 0 ) ; } const QuicSocketAddress kNewPeerAddress = QuicSocketAddress ( QuicIpAddress :: Loopback6 ( ) , 23456 ) ; OwningSerializedPacketPointer probing_packet = ConstructProbingPacket ( ) ; std :: unique_ptr < QuicReceivedPacket > received ( ConstructReceivedPacket ( QuicEncryptedPacket ( probing_packet -> encrypted_buffer , probing_packet -> encrypted_length ) , clock_ . Now ( ) ) ) ; uint64_t num_probing_received = connection_ . GetStats ( ) . num_connectivity_probing_received ; ProcessReceivedPacket ( kSelfAddress , kNewPeerAddress , * received ) ; EXPECT_EQ ( num_probing_received + 1 , connection_ . GetStats ( ) . num_connectivity_probing_received ) ; EXPECT_EQ ( kPeerAddress , connection_ . peer_address ( ) ) ; EXPECT_EQ ( kPeerAddress , connection_ . effective_peer_address ( ) ) ; EXPECT_CALL ( visitor_ , OnConnectionMigration ( PORT_CHANGE ) ) . Times ( 0 ) ; ProcessFramePacketWithAddresses ( frame , kSelfAddress , kPeerAddress ) ; EXPECT_EQ ( kPeerAddress , connection_ . peer_address ( ) ) ; EXPECT_EQ ( kPeerAddress , connection_ . effective_peer_address ( ) ) ; }
Receive a path probe request at the server side, i.e.,
in non-IETF version: receive a padded PING packet with a peer addess change;
in IETF version: receive a packet contains PATH CHALLENGE with peer address
change.
Receive a path probe request at the server side i . e . in non - IETF version : receive a padded PING packet with a peer addess change ; in IETF version : receive a packet contains PATH CHALLENGE with peer address change .
// Clear direct_peer_address. // Clear effective_peer_address, it is the same as direct_peer_address for // this test. /*is_connectivity_probe=*/ // Process a padded PING packet from a new peer address on server side // is effectively receiving a connectivity probing. /*port=*/ // Process another packet with the old peer address on server side will not // start peer migration.