From 3f19c111e3e7bb64e1aad7ecbe210cf40ed93c5e Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 11 Aug 2023 16:30:22 +0200 Subject: [PATCH] wifi: Have STA send packet to the AP in the channel switching test ...instead of having the AP send a packet to the STA. In fact, AP may flush the packets addressed to a STA when STA dissociates. --- src/wifi/test/wifi-channel-switching-test.cc | 33 ++++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/wifi/test/wifi-channel-switching-test.cc b/src/wifi/test/wifi-channel-switching-test.cc index dedbf6b93..7442983cc 100644 --- a/src/wifi/test/wifi-channel-switching-test.cc +++ b/src/wifi/test/wifi-channel-switching-test.cc @@ -45,9 +45,9 @@ NS_LOG_COMPONENT_DEFINE("WifiChannelSwitchingTest"); * * This test verifies that communication between an AP and a STA resumes * after that both switch channel and PHY band. The channel switch is - * scheduled to happen during the transmission of a frame sent by the AP - * to the STA. STA discards the frame, associates with the AP again and - * finally receives the frame successfully. + * scheduled to happen during the transmission of a frame sent by the STA + * to the AP. AP discards the frame, STA associates with the AP again and + * the AP finally receives the frame successfully. */ class WifiChannelSwitchingTest : public TestCase { @@ -69,7 +69,7 @@ class WifiChannelSwitchingTest : public TestCase void Associated(Mac48Address bssid); /** * Callback invoked when PHY receives a PSDU to transmit from the MAC. Tracks the - * number of times a QoS data frame is transmitted by the AP. + * number of times a QoS data frame is transmitted by the STA. * * \param psduMap the PSDU map * \param txVector the TX vector @@ -84,7 +84,7 @@ class WifiChannelSwitchingTest : public TestCase */ void L7Receive(Ptr p, const Address& addr); /** - * Send a packet from the AP to the STA through a packet socket + * Send a packet from the STA to the AP through a packet socket */ void SendPacket(); /** @@ -172,8 +172,8 @@ void WifiChannelSwitchingTest::SendPacket() { PacketSocketAddress socket; - socket.SetSingleDevice(m_apDevice.Get(0)->GetIfIndex()); - socket.SetPhysicalAddress(m_staDevice.Get(0)->GetAddress()); + socket.SetSingleDevice(m_staDevice.Get(0)->GetIfIndex()); + socket.SetPhysicalAddress(m_apDevice.Get(0)->GetAddress()); socket.SetProtocol(1); // give packet socket powers to nodes. @@ -181,18 +181,18 @@ WifiChannelSwitchingTest::SendPacket() packetSocket.Install(m_staNode); packetSocket.Install(m_apNode); - Ptr client = CreateObject(); + auto client = CreateObject(); client->SetAttribute("PacketSize", UintegerValue(m_payloadSize)); client->SetAttribute("MaxPackets", UintegerValue(1)); client->SetAttribute("Interval", TimeValue(MicroSeconds(0))); client->SetRemote(socket); - m_apNode.Get(0)->AddApplication(client); + m_staNode.Get(0)->AddApplication(client); client->SetStartTime(Seconds(0.5)); client->SetStopTime(Seconds(1.0)); - Ptr server = CreateObject(); + auto server = CreateObject(); server->SetLocal(socket); - m_staNode.Get(0)->AddApplication(server); + m_apNode.Get(0)->AddApplication(server); server->SetStartTime(Seconds(0.0)); server->SetStopTime(Seconds(1.0)); } @@ -229,11 +229,10 @@ WifiChannelSwitchingTest::DoRun() m_apNode.Create(1); m_staNode.Create(1); - Ptr spectrumChannel = CreateObject(); - Ptr lossModel = CreateObject(); + auto spectrumChannel = CreateObject(); + auto lossModel = CreateObject(); spectrumChannel->AddPropagationLossModel(lossModel); - Ptr delayModel = - CreateObject(); + auto delayModel = CreateObject(); spectrumChannel->SetPropagationDelayModel(delayModel); SpectrumWifiPhyHelper phy; @@ -293,10 +292,10 @@ WifiChannelSwitchingTest::DoRun() NS_TEST_EXPECT_MSG_EQ(+m_assocCount, 2, "STA did not associate twice"); NS_TEST_EXPECT_MSG_EQ(+m_txCount, 2, - "The QoS Data frame should have been transmitted twice by the AP"); + "The QoS Data frame should have been transmitted twice by the STA"); NS_TEST_EXPECT_MSG_EQ(m_rxBytes, m_payloadSize, - "The QoS Data frame should have been received once by the STA"); + "The QoS Data frame should have been received once by the AP"); NS_TEST_EXPECT_MSG_EQ(+m_channelSwitchCount[0], 1, "AP had to perform one channel switch"); NS_TEST_EXPECT_MSG_EQ(+m_channelSwitchCount[1], 1, "STA had to perform one channel switch");