src/connectivity/bluetooth/core/bt-host/l2cap/enhanced_retransmission_mode_engines_unittest.cc
// This test that TxEngine sends I-Frames whose acknowledgement sequence numbers match the receive
// sequence number in RxEngine. This also tests that peer acknowledgement restarts our outbound data
// that was paused by hitting TxWindow. This mirrors the L2CAP Test Specification L2CAP/ERM/BV-06-C.
This test that TxEngine sends I-Frames whose acknowledgement sequence numbers match the receive
sequence number in RxEngine. This also tests that peer acknowledgement restarts our outbound data
that was paused by hitting TxWindow. This mirrors the L2CAP Test Specification L2CAP/ERM/BV-06-C.
This test that TxEngine sends I - Frames whose acknowledgement sequence numbers match the receive sequence number in RxEngine . This also tests that peer acknowledgement restarts our outbound data that was paused by hitting TxWindow . This mirrors the L2CAP Test Specification L2CAP / ERM / BV - 06 - C .
TEST_F(L2CAP_EnhancedRetransmissionModeEnginesTest,
       OutboundInformationFramesAcknowledgeReceivedInformationFrames) {
  int tx_count = 0;
  auto tx_callback = [&tx_count](ByteBufferPtr pdu) {
    ASSERT_TRUE(pdu);
    if (tx_count == 0) {
      ASSERT_LE(sizeof(SimpleInformationFrameHeader), pdu->size());
      ASSERT_TRUE(pdu->As<EnhancedControlField>().designates_information_frame());
      const auto& header = pdu->As<SimpleInformationFrameHeader>();
      EXPECT_EQ(0, header.tx_seq());
      EXPECT_EQ(0, header.receive_seq_num());
    } else if (tx_count == 2) {
      ASSERT_LE(sizeof(SimpleInformationFrameHeader), pdu->size());
      ASSERT_TRUE(pdu->As<EnhancedControlField>().designates_information_frame());
      const auto& header = pdu->As<SimpleInformationFrameHeader>();
      EXPECT_EQ(1, header.tx_seq());
      EXPECT_EQ(1, header.receive_seq_num());
    }
    tx_count++;
  };
  auto [rx_engine, tx_engine] = MakeLinkedEnhancedRetransmissionModeEngines(
      kTestChannelId, kDefaultMTU, kMaxTransmissions, 1, tx_callback,
      NoOpFailureCallback);
  ASSERT_TRUE(rx_engine);
  ASSERT_TRUE(tx_engine);
  tx_engine->QueueSdu(std::make_unique<DynamicByteBuffer>(StaticByteBuffer{'p', 'i', 'n', 'g'}));
  EXPECT_EQ(1, tx_count);
  auto info_frame = StaticByteBuffer(0, 1, 'p', 'o', 'n', 'g');
  EXPECT_TRUE(rx_engine->ProcessPdu(
      Fragmenter(kTestHandle)
          .BuildFrame(kTestChannelId, info_frame, FrameCheckSequenceOption::kIncludeFcs)));
  EXPECT_EQ(2, tx_count);
  tx_engine->QueueSdu(std::make_unique<DynamicByteBuffer>(StaticByteBuffer{'b', 'y', 'e', 'e'}));
  EXPECT_EQ(3, tx_count);
}
TEST_F ( L2CAP_EnhancedRetransmissionModeEnginesTest , OutboundInformationFramesAcknowledgeReceivedInformationFrames ) { int tx_count = 0 ; auto tx_callback = [ & tx_count ] ( ByteBufferPtr pdu ) { ASSERT_TRUE ( pdu ) ; if ( tx_count == 0 ) { ASSERT_LE ( sizeof ( SimpleInformationFrameHeader ) , pdu -> size ( ) ) ; ASSERT_TRUE ( pdu -> As < EnhancedControlField > ( ) . designates_information_frame ( ) ) ; const auto & header = pdu -> As < SimpleInformationFrameHeader > ( ) ; EXPECT_EQ ( 0 , header . tx_seq ( ) ) ; EXPECT_EQ ( 0 , header . receive_seq_num ( ) ) ; } else if ( tx_count == 2 ) { ASSERT_LE ( sizeof ( SimpleInformationFrameHeader ) , pdu -> size ( ) ) ; ASSERT_TRUE ( pdu -> As < EnhancedControlField > ( ) . designates_information_frame ( ) ) ; const auto & header = pdu -> As < SimpleInformationFrameHeader > ( ) ; EXPECT_EQ ( 1 , header . tx_seq ( ) ) ; EXPECT_EQ ( 1 , header . receive_seq_num ( ) ) ; } tx_count ++ ; } ; auto [ rx_engine , tx_engine ] = MakeLinkedEnhancedRetransmissionModeEngines ( kTestChannelId , kDefaultMTU , kMaxTransmissions , 1 , tx_callback , NoOpFailureCallback ) ; ASSERT_TRUE ( rx_engine ) ; ASSERT_TRUE ( tx_engine ) ; tx_engine -> QueueSdu ( std :: make_unique < DynamicByteBuffer > ( StaticByteBuffer { ' ' , ' ' , ' ' , ' ' } ) ) ; EXPECT_EQ ( 1 , tx_count ) ; auto info_frame = StaticByteBuffer ( 0 , 1 , ' ' , ' ' , ' ' , ' ' ) ; EXPECT_TRUE ( rx_engine -> ProcessPdu ( Fragmenter ( kTestHandle ) . BuildFrame ( kTestChannelId , info_frame , FrameCheckSequenceOption :: kIncludeFcs ) ) ) ; EXPECT_EQ ( 2 , tx_count ) ; tx_engine -> QueueSdu ( std :: make_unique < DynamicByteBuffer > ( StaticByteBuffer { ' ' , ' ' , ' ' , ' ' } ) ) ; EXPECT_EQ ( 3 , tx_count ) ; }
This test that TxEngine sends I-Frames whose acknowledgement sequence numbers match the receive
sequence number in RxEngine.
This test that TxEngine sends I - Frames whose acknowledgement sequence numbers match the receive sequence number in RxEngine .
// Unlike the Test Spec's sequence diagram, we respond to the peer's I-Frame with a Receiver // Ready (which is always allowed), so our subsequent I-Frame is actually the third outbound. // Acknowledges the I-Frame from the peer. /*n_frames_in_tx_window=*/ // Receive an I-frame containing an acknowledgment including the frame that we transmitted. // See Core Spec, v5, Vol 3, Part A, Section 3.3.2, I-Frame Enhanced Control Field.