wifi: Add PHY index and channel number in PHY logs

This commit is contained in:
Sébastien Deronne
2024-02-22 08:12:15 +01:00
committed by Sébastien Deronne
parent 533bf013dc
commit 9aca6aa4fd
12 changed files with 78 additions and 1 deletions

View File

@@ -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
{

View File

@@ -38,6 +38,9 @@
#include <algorithm>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
namespace ns3
{

View File

@@ -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
{

View File

@@ -32,6 +32,9 @@
#include <array>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
namespace ns3
{

View File

@@ -30,6 +30,9 @@
#include <array>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
namespace ns3
{

View File

@@ -32,6 +32,9 @@
#include <array>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
namespace ns3
{

View File

@@ -37,6 +37,9 @@
#include <algorithm>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
namespace ns3
{

View File

@@ -41,6 +41,9 @@
#include <algorithm>
#undef NS_LOG_APPEND_CONTEXT
#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(Ptr(this))
namespace ns3
{

View File

@@ -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
{

View File

@@ -254,6 +254,7 @@ WifiNetDevice::SetPhy(const Ptr<WifiPhy> 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<Ptr<WifiPhy>>& 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();
}

View File

@@ -47,6 +47,9 @@
#include <algorithm>
#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<InterferenceHelper> helper)
{

View File

@@ -30,6 +30,18 @@
#include <limits>
#define WIFI_PHY_NS_LOG_APPEND_CONTEXT(phy) \
{ \
if (DynamicCast<const WifiPhy>(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> phyEntity);
uint8_t m_phyId; //!< the index of the PHY in the vector of PHYs held by the WifiNetDevice
Ptr<InterferenceHelper>
m_interference; //!< Pointer to a helper responsible for interference computations