wifi: Add new signal transmission and arrival traces
This commit is contained in:
@@ -17,6 +17,7 @@ Changes from ns-3.41 to ns-3-dev
|
||||
--------------------------------
|
||||
|
||||
### New API
|
||||
* (wifi) New trace sources `SpectrumWifiPhy::SignalTransmission`, `YansWifiPhy::SignalArrival`, and `YansWifiPhy::SignalTransmission`
|
||||
|
||||
* Objects now can be aggregated to multiple objects though the `Object::UnidirectionalAggregateObject` function. Objects aggregated in such a way can not use `GetObject` to access the objects they are aggregated to.
|
||||
* (network) Added `ApplicationHelper` helper class to create and install applications, removing
|
||||
|
||||
@@ -88,10 +88,11 @@ SpectrumWifiPhy::GetTypeId()
|
||||
DoubleValue(-40.0),
|
||||
MakeDoubleAccessor(&SpectrumWifiPhy::m_txMaskOuterBandMaximumRejection),
|
||||
MakeDoubleChecker<double>())
|
||||
.AddTraceSource("SignalArrival",
|
||||
"Signal arrival",
|
||||
MakeTraceSourceAccessor(&SpectrumWifiPhy::m_signalCb),
|
||||
"ns3::SpectrumWifiPhy::SignalArrivalCallback");
|
||||
.AddTraceSource(
|
||||
"SignalArrival",
|
||||
"Trace start of all signal arrivals, including weak and foreign signals",
|
||||
MakeTraceSourceAccessor(&SpectrumWifiPhy::m_signalCb),
|
||||
"ns3::SpectrumWifiPhy::SignalArrivalCallback");
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -478,7 +479,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
|
||||
DynamicCast<WifiSpectrumSignalParameters>(rxParams);
|
||||
|
||||
// Log the signal arrival to the trace source
|
||||
m_signalCb(bool(wifiRxParams), senderNodeId, WToDbm(totalRxPowerW), rxDuration);
|
||||
m_signalCb(rxParams, senderNodeId, WToDbm(totalRxPowerW), rxDuration);
|
||||
|
||||
if (!wifiRxParams)
|
||||
{
|
||||
@@ -571,6 +572,7 @@ void
|
||||
SpectrumWifiPhy::StartTx(Ptr<const WifiPpdu> ppdu)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << ppdu);
|
||||
m_signalTransmissionCb(ppdu, ppdu->GetTxVector());
|
||||
GetPhyEntity(ppdu->GetModulation())->StartTx(ppdu);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,12 +124,11 @@ class SpectrumWifiPhy : public WifiPhy
|
||||
/**
|
||||
* Callback invoked when the PHY model starts to process a signal
|
||||
*
|
||||
* \param signalType Whether signal is WiFi (true) or foreign (false)
|
||||
* \param senderNodeId Node Id of the sender of the signal
|
||||
* \param rxPower received signal power (dBm)
|
||||
* \param duration Signal duration
|
||||
*/
|
||||
typedef void (*SignalArrivalCallback)(bool signalType,
|
||||
typedef void (*SignalArrivalCallback)(Ptr<const SpectrumSignalParameters> signal,
|
||||
uint32_t senderNodeId,
|
||||
double rxPower,
|
||||
Time duration);
|
||||
@@ -286,7 +285,8 @@ class SpectrumWifiPhy : public WifiPhy
|
||||
bool m_trackSignalsInactiveInterfaces; //!< flag whether signals coming from inactive spectrum
|
||||
//!< PHY interfaces are tracked
|
||||
|
||||
TracedCallback<bool, uint32_t, double, Time> m_signalCb; //!< Signal callback
|
||||
TracedCallback<Ptr<const SpectrumSignalParameters>, uint32_t, double, Time>
|
||||
m_signalCb; //!< Signal callback
|
||||
|
||||
double m_txMaskInnerBandMinimumRejection; //!< The minimum rejection (in dBr) for the inner band
|
||||
//!< of the transmit spectrum mask
|
||||
|
||||
@@ -350,7 +350,11 @@ WifiPhy::GetTypeId()
|
||||
"Trace source simulating the capability of a wifi device "
|
||||
"in monitor mode to sniff all frames being transmitted",
|
||||
MakeTraceSourceAccessor(&WifiPhy::m_phyMonitorSniffTxTrace),
|
||||
"ns3::WifiPhy::MonitorSnifferTxTracedCallback");
|
||||
"ns3::WifiPhy::MonitorSnifferTxTracedCallback")
|
||||
.AddTraceSource("SignalTransmission",
|
||||
"Trace start of signal transmission",
|
||||
MakeTraceSourceAccessor(&WifiPhy::m_signalTransmissionCb),
|
||||
"ns3::SpectrumWifiPhy::SignalTransmissionCallback");
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
@@ -1233,6 +1233,15 @@ class WifiPhy : public Object
|
||||
*/
|
||||
uint32_t GetSubcarrierSpacing() const;
|
||||
|
||||
/**
|
||||
* Callback invoked when the PHY model starts to transmit a signal
|
||||
*
|
||||
* \param ppdu The PPDU being transmitted
|
||||
* \param txVector txVector used for transmitting the PPDU
|
||||
*/
|
||||
typedef void (*SignalTransmissionCallback)(Ptr<const WifiPpdu> ppdu,
|
||||
const WifiTxVector& txVector);
|
||||
|
||||
protected:
|
||||
void DoInitialize() override;
|
||||
void DoDispose() override;
|
||||
@@ -1325,6 +1334,9 @@ class WifiPhy : public Object
|
||||
*/
|
||||
std::map<WifiModulationClass, Ptr<PhyEntity>> m_phyEntities;
|
||||
|
||||
TracedCallback<Ptr<const WifiPpdu>, const WifiTxVector&>
|
||||
m_signalTransmissionCb; //!< Signal Transmission callback
|
||||
|
||||
private:
|
||||
/**
|
||||
* Configure WifiPhy with appropriate channel frequency and
|
||||
|
||||
@@ -135,6 +135,7 @@ YansWifiChannel::Receive(Ptr<YansWifiPhy> phy, Ptr<const WifiPpdu> ppdu, double
|
||||
{
|
||||
NS_LOG_FUNCTION(phy << ppdu << rxPowerDbm);
|
||||
const auto totalRxPowerDbm = rxPowerDbm + phy->GetRxGain();
|
||||
phy->TraceSignalArrival(ppdu, totalRxPowerDbm, ppdu->GetTxDuration());
|
||||
// Do no further processing if signal is too weak
|
||||
// Current implementation assumes constant RX power over the PPDU duration
|
||||
// Compare received TX power per MHz to normalized RX sensitivity
|
||||
|
||||
@@ -36,10 +36,15 @@ NS_OBJECT_ENSURE_REGISTERED(YansWifiPhy);
|
||||
TypeId
|
||||
YansWifiPhy::GetTypeId()
|
||||
{
|
||||
static TypeId tid = TypeId("ns3::YansWifiPhy")
|
||||
.SetParent<WifiPhy>()
|
||||
.SetGroupName("Wifi")
|
||||
.AddConstructor<YansWifiPhy>();
|
||||
static TypeId tid =
|
||||
TypeId("ns3::YansWifiPhy")
|
||||
.SetParent<WifiPhy>()
|
||||
.SetGroupName("Wifi")
|
||||
.AddConstructor<YansWifiPhy>()
|
||||
.AddTraceSource("SignalArrival",
|
||||
"Trace start of all signal arrivals, including weak signals",
|
||||
MakeTraceSourceAccessor(&YansWifiPhy::m_signalArrivalCb),
|
||||
"ns3::YansWifiPhy::SignalArrivalCallback");
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -89,9 +94,17 @@ YansWifiPhy::StartTx(Ptr<const WifiPpdu> ppdu)
|
||||
NS_LOG_FUNCTION(this << ppdu);
|
||||
NS_LOG_DEBUG("Start transmission: signal power before antenna gain="
|
||||
<< GetPowerDbm(ppdu->GetTxVector().GetTxPowerLevel()) << "dBm");
|
||||
m_signalTransmissionCb(ppdu, ppdu->GetTxVector());
|
||||
m_channel->Send(this, ppdu, GetTxPowerForTransmission(ppdu) + GetTxGain());
|
||||
}
|
||||
|
||||
void
|
||||
YansWifiPhy::TraceSignalArrival(Ptr<const WifiPpdu> ppdu, double rxPowerDbm, Time duration)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << ppdu);
|
||||
m_signalArrivalCb(ppdu, rxPowerDbm, ppdu->GetTxDuration());
|
||||
}
|
||||
|
||||
uint16_t
|
||||
YansWifiPhy::GetGuardBandwidth(uint16_t currentChannelWidth) const
|
||||
{
|
||||
|
||||
@@ -73,11 +73,35 @@ class YansWifiPhy : public WifiPhy
|
||||
*/
|
||||
void SetChannel(const Ptr<YansWifiChannel> channel);
|
||||
|
||||
/**
|
||||
* Logs the arrival of a PPDU, including its power and duration.
|
||||
* This will also trace PPDUs below WifiPhy::RxSensitivity
|
||||
*
|
||||
* \param [in] ppdu The PPDU being traced upon its arrival.
|
||||
* \param [in] rxPowerDbm The received power of the PPDU in dBm.
|
||||
* \param [in] duration The duration of the PPDU signal.
|
||||
*/
|
||||
void TraceSignalArrival(Ptr<const WifiPpdu> ppdu, double rxPowerDbm, Time duration);
|
||||
|
||||
/**
|
||||
* Callback invoked when the PHY model starts to process a signal
|
||||
*
|
||||
* \param ppdu The PPDU being processed
|
||||
* \param rxPowerDbm received signal power (dBm)
|
||||
* \param duration Signal duration
|
||||
*/
|
||||
typedef void (*SignalArrivalCallback)(Ptr<const WifiPpdu> ppdu,
|
||||
double rxPowerDbm,
|
||||
Time duration);
|
||||
|
||||
protected:
|
||||
void DoDispose() override;
|
||||
|
||||
private:
|
||||
Ptr<YansWifiChannel> m_channel; //!< YansWifiChannel that this YansWifiPhy is connected to
|
||||
|
||||
TracedCallback<Ptr<const WifiPpdu>, double, Time>
|
||||
m_signalArrivalCb; //!< Signal Arrival callback
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
Reference in New Issue
Block a user