From 71728fa264a2b803d808473becd3eb496994bbfe Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Mon, 7 Jun 2010 17:05:29 +0200 Subject: [PATCH] fixed bug 844 --- src/devices/wifi/yans-wifi-phy.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 24de83ecd..02d0b2545 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -726,7 +726,16 @@ YansWifiPhy::GetPowerDbm (uint8_t power) const { NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); NS_ASSERT (m_nTxPower > 0); - double dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / m_nTxPower; + double dbm; + if (m_nTxPower > 1) + { + dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1); + } + else + { + NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1"); + dbm = m_txPowerBaseDbm; + } return dbm; }