From 970f9aa99e1067f754cf1c1bd84f1f025ff15833 Mon Sep 17 00:00:00 2001 From: Daniel Kopacz Date: Tue, 22 Apr 2025 16:02:25 +0200 Subject: [PATCH] examples: Fix running wifi-spatial-reuse example with OBSS PD disabled --- examples/wireless/wifi-spatial-reuse.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index 356a5f6a4..a780d785d 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -345,17 +345,20 @@ main(int argc, char* argv[]) Config::Connect("/NodeList/*/ApplicationList/*/$ns3::PacketSocketServer/Rx", MakeCallback(&SocketRx)); - // Obtain pointers to the ObssPdAlgorithm objects and hook trace sinks - // to the Reset trace source on each STA. Note that this trace connection - // cannot be done through the Config path system, so pointers are used. - auto deviceA = staDeviceA.Get(0)->GetObject(); - auto hePhyA = DynamicCast(deviceA->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); - // Pass in the context string "1" to allow the trace to distinguish objects - hePhyA->GetObssPdAlgorithm()->TraceConnect("Reset", "1", MakeCallback(&ResetTrace)); - auto deviceB = staDeviceB.Get(0)->GetObject(); - auto hePhyB = DynamicCast(deviceB->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); - // Pass in the context string "2" to allow the trace to distinguish objects - hePhyB->GetObssPdAlgorithm()->TraceConnect("Reset", "2", MakeCallback(&ResetTrace)); + if (enableObssPd) + { + // Obtain pointers to the ObssPdAlgorithm objects and hook trace sinks + // to the Reset trace source on each STA. Note that this trace connection + // cannot be done through the Config path system, so pointers are used. + auto deviceA = staDeviceA.Get(0)->GetObject(); + auto hePhyA = DynamicCast(deviceA->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + // Pass in the context string "1" to allow the trace to distinguish objects + hePhyA->GetObssPdAlgorithm()->TraceConnect("Reset", "1", MakeCallback(&ResetTrace)); + auto deviceB = staDeviceB.Get(0)->GetObject(); + auto hePhyB = DynamicCast(deviceB->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + // Pass in the context string "2" to allow the trace to distinguish objects + hePhyB->GetObssPdAlgorithm()->TraceConnect("Reset", "2", MakeCallback(&ResetTrace)); + } Simulator::Stop(duration); Simulator::Run();