From 9aca6aa4fd398628a537d020e093b08ac09155c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Thu, 22 Feb 2024 08:12:15 +0100 Subject: [PATCH] wifi: Add PHY index and channel number in PHY logs --- src/wifi/model/eht/eht-phy.cc | 3 +++ src/wifi/model/he/he-phy.cc | 3 +++ src/wifi/model/ht/ht-phy.cc | 3 +++ src/wifi/model/non-ht/dsss-phy.cc | 3 +++ src/wifi/model/non-ht/erp-ofdm-phy.cc | 3 +++ src/wifi/model/non-ht/ofdm-phy.cc | 3 +++ src/wifi/model/phy-entity.cc | 3 +++ src/wifi/model/spectrum-wifi-phy.cc | 3 +++ src/wifi/model/vht/vht-phy.cc | 3 +++ src/wifi/model/wifi-net-device.cc | 5 +++++ src/wifi/model/wifi-phy.cc | 19 +++++++++++++++++- src/wifi/model/wifi-phy.h | 28 +++++++++++++++++++++++++++ 12 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/wifi/model/eht/eht-phy.cc b/src/wifi/model/eht/eht-phy.cc index 4134c80c0..f6174302e 100644 --- a/src/wifi/model/eht/eht-phy.cc +++ b/src/wifi/model/eht/eht-phy.cc @@ -26,6 +26,9 @@ #include "ns3/wifi-psdu.h" #include "ns3/wifi-utils.h" +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index b42b31771..94cd5fb30 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -38,6 +38,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index bb232c478..88148a9b3 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -29,6 +29,9 @@ #include "ns3/wifi-psdu.h" #include "ns3/wifi-utils.h" +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index e2aa1193c..bed1a2d9f 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -32,6 +32,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/non-ht/erp-ofdm-phy.cc b/src/wifi/model/non-ht/erp-ofdm-phy.cc index 2e992c95c..4c8afc9bb 100644 --- a/src/wifi/model/non-ht/erp-ofdm-phy.cc +++ b/src/wifi/model/non-ht/erp-ofdm-phy.cc @@ -30,6 +30,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index 3f29daf68..8c823a55a 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -32,6 +32,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index f33adb409..ee567ee34 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -37,6 +37,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 683fd3dd7..522841a31 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -41,6 +41,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(Ptr(this)) + namespace ns3 { diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index 2e89b9594..68401f757 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -31,6 +31,9 @@ #include "ns3/wifi-psdu.h" #include "ns3/wifi-utils.h" +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy) + namespace ns3 { diff --git a/src/wifi/model/wifi-net-device.cc b/src/wifi/model/wifi-net-device.cc index d59ed8e97..d0f932668 100644 --- a/src/wifi/model/wifi-net-device.cc +++ b/src/wifi/model/wifi-net-device.cc @@ -254,6 +254,7 @@ WifiNetDevice::SetPhy(const Ptr phy) { m_phys.clear(); m_phys.push_back(phy); + phy->SetPhyId(0); m_linkUp = true; CompleteConfig(); } @@ -264,6 +265,10 @@ WifiNetDevice::SetPhys(const std::vector>& phys) NS_ABORT_MSG_IF(phys.size() > 1 && !m_ehtConfiguration, "Multiple PHYs only allowed for 11be multi-link devices"); m_phys = phys; + for (std::size_t id = 0; id < phys.size(); ++id) + { + m_phys.at(id)->SetPhyId(id); + } m_linkUp = true; CompleteConfig(); } diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 70b15398f..8cb7c3380 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -47,6 +47,9 @@ #include +#undef NS_LOG_APPEND_CONTEXT +#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(Ptr(this)) + namespace ns3 { @@ -348,7 +351,8 @@ WifiPhy::GetTypeId() } WifiPhy::WifiPhy() - : m_txMpduReferenceNumber(0xffffffff), + : m_phyId(0), + m_txMpduReferenceNumber(0xffffffff), m_rxMpduReferenceNumber(0xffffffff), m_endPhyRxEvent(), m_endTxEvent(), @@ -627,6 +631,19 @@ WifiPhy::GetMobility() const return m_mobility; } +void +WifiPhy::SetPhyId(uint8_t phyId) +{ + NS_LOG_FUNCTION(this << phyId); + m_phyId = phyId; +} + +uint8_t +WifiPhy::GetPhyId() const +{ + return m_phyId; +} + void WifiPhy::SetInterferenceHelper(const Ptr helper) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index f7fef23aa..ee40675ee 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -30,6 +30,18 @@ #include +#define WIFI_PHY_NS_LOG_APPEND_CONTEXT(phy) \ + { \ + if (DynamicCast(phy)) \ + { \ + std::clog << "[index=" << +phy->GetPhyId() << "][channel=" \ + << (phy->GetOperatingChannel().IsSet() \ + ? std::to_string(+phy->GetOperatingChannel().GetNumber()) \ + : "UNKNOWN") \ + << "][band=" << phy->GetPhyBand() << "] "; \ + } \ + } + namespace ns3 { @@ -986,6 +998,20 @@ class WifiPhy : public Object */ bool GetShortPhyPreambleSupported() const; + /** + * Set the index allocated to this PHY + * + * \param phyId the ID allocated to this PHY + */ + void SetPhyId(uint8_t phyId); + + /** + * Get the index allocated to this PHY + * + * \return the ID allocated to this PHY + */ + uint8_t GetPhyId() const; + /** * Sets the interference helper. * @@ -1256,6 +1282,8 @@ class WifiPhy : public Object */ void AddPhyEntity(WifiModulationClass modulation, Ptr phyEntity); + uint8_t m_phyId; //!< the index of the PHY in the vector of PHYs held by the WifiNetDevice + Ptr m_interference; //!< Pointer to a helper responsible for interference computations