diff -r d5cfe99001f0 src/devices/mesh/dot11s/airtime-metric.cc --- a/src/devices/mesh/dot11s/airtime-metric.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/mesh/dot11s/airtime-metric.cc Fri Jul 23 17:28:11 2010 +0200 @@ -86,7 +86,7 @@ */ NS_ASSERT (!peerAddress.IsGroup ()); //obtain current rate: - WifiMode mode = mac->GetStationManager ()->GetDataMode (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()); + WifiMode mode = mac->GetStationManager ()->GetDataTxVector (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()).mode; //obtain frame error rate: double failAvg = mac->GetStationManager ()->GetInfo (peerAddress).GetFrameErrorRate (); NS_ASSERT (failAvg < 1.0); diff -r d5cfe99001f0 src/devices/wifi/aarf-wifi-manager.cc --- a/src/devices/wifi/aarf-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/aarf-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -200,19 +200,19 @@ AarfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) {} -WifiMode -AarfWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +AarfWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { AarfWifiRemoteStation *station = (AarfWifiRemoteStation *) st; - return GetSupported (station, station->m_rate); + return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel ()); } -WifiMode -AarfWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +AarfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { // XXX: we could/should implement the Aarf algorithm for // RTS only by picking a single rate within the BasicRateSet. AarfWifiRemoteStation *station = (AarfWifiRemoteStation *) st; - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/aarf-wifi-manager.h --- a/src/devices/wifi/aarf-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/aarf-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -51,8 +51,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; uint32_t m_minTimerThreshold; diff -r d5cfe99001f0 src/devices/wifi/aarfcd-wifi-manager.cc --- a/src/devices/wifi/aarfcd-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/aarfcd-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -279,19 +279,19 @@ AarfcdWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) {} -WifiMode -AarfcdWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +AarfcdWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; - return GetSupported (station, station->m_rate); + return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel ()); } -WifiMode -AarfcdWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +AarfcdWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { // XXX: we could/should implement the Aarf algorithm for // RTS only by picking a single rate within the BasicRateSet. AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/aarfcd-wifi-manager.h --- a/src/devices/wifi/aarfcd-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/aarfcd-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -54,8 +54,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool DoNeedRts (WifiRemoteStation *station, Ptr packet, bool normally); virtual bool IsLowLatency (void) const; diff -r d5cfe99001f0 src/devices/wifi/amrr-wifi-manager.cc --- a/src/devices/wifi/amrr-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/amrr-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -245,8 +245,8 @@ ResetCnt (station); } } -WifiMode -AmrrWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +AmrrWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st; UpdateMode (station); @@ -290,15 +290,15 @@ } } - return GetSupported (station, rateIndex); + return WifiTxVector (GetSupported (station, rateIndex), GetDefaultTxPowerLevel ()); } -WifiMode -AmrrWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +AmrrWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st; UpdateMode (station); // XXX: can we implement something smarter ? - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } diff -r d5cfe99001f0 src/devices/wifi/amrr-wifi-manager.h --- a/src/devices/wifi/amrr-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/amrr-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -55,8 +55,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; void UpdateRetry (AmrrWifiRemoteStation *station); diff -r d5cfe99001f0 src/devices/wifi/arf-wifi-manager.cc --- a/src/devices/wifi/arf-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/arf-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -172,19 +172,19 @@ ArfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) {} -WifiMode -ArfWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +ArfWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; - return GetSupported (station, station->m_rate); + return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel ()); } -WifiMode -ArfWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +ArfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { // XXX: we could/should implement the Arf algorithm for // RTS only by picking a single rate within the BasicRateSet. ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/arf-wifi-manager.h --- a/src/devices/wifi/arf-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/arf-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -58,8 +58,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; uint32_t m_timerThreshold; diff -r d5cfe99001f0 src/devices/wifi/cara-wifi-manager.cc --- a/src/devices/wifi/cara-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/cara-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -148,19 +148,19 @@ CaraWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) {} -WifiMode -CaraWifiManager::DoGetDataMode (WifiRemoteStation *st, +WifiTxVector +CaraWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { CaraWifiRemoteStation *station = (CaraWifiRemoteStation *) st; - return GetSupported (station, station->m_rate); + return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel ()); } -WifiMode -CaraWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +CaraWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { // XXX: we could/should implement the Arf algorithm for // RTS only by picking a single rate within the BasicRateSet. - return GetSupported (st, 0); + return WifiTxVector (GetSupported (st, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/cara-wifi-manager.h --- a/src/devices/wifi/cara-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/cara-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -54,8 +54,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool DoNeedRts (WifiRemoteStation *station, Ptr packet, bool normally); virtual bool IsLowLatency (void) const; diff -r d5cfe99001f0 src/devices/wifi/constant-rate-wifi-manager.cc --- a/src/devices/wifi/constant-rate-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/constant-rate-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -86,15 +86,15 @@ ConstantRateWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) {} -WifiMode -ConstantRateWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +ConstantRateWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { - return m_dataMode; + return WifiTxVector (m_dataMode, GetDefaultTxPowerLevel ()); } -WifiMode -ConstantRateWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +ConstantRateWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { - return m_ctlMode; + return WifiTxVector (m_ctlMode, GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/constant-rate-wifi-manager.h --- a/src/devices/wifi/constant-rate-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/constant-rate-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -52,8 +52,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; WifiMode m_dataMode; diff -r d5cfe99001f0 src/devices/wifi/ideal-wifi-manager.cc --- a/src/devices/wifi/ideal-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/ideal-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -125,8 +125,8 @@ IdealWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) {} -WifiMode -IdealWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) +WifiTxVector +IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; // We search within the Supported rate set the mode with the @@ -145,10 +145,10 @@ maxMode = mode; } } - return maxMode; + return WifiTxVector (maxMode, GetDefaultTxPowerLevel ()); } -WifiMode -IdealWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +IdealWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; // We search within the Basic rate set the mode with the highest @@ -167,7 +167,7 @@ maxMode = mode; } } - return maxMode; + return WifiTxVector (maxMode, GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/ideal-wifi-manager.h --- a/src/devices/wifi/ideal-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/ideal-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -63,8 +63,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; // return the min snr needed to successfully transmit diff -r d5cfe99001f0 src/devices/wifi/mac-low.cc --- a/src/devices/wifi/mac-low.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/mac-low.cc Fri Jul 23 17:28:11 2010 +0200 @@ -913,6 +913,11 @@ MacLow::GetAckDuration (Mac48Address to, WifiMode dataTxMode) const { WifiMode ackMode = GetAckTxModeForData (to, dataTxMode); + return GetAckDuration (ackMode); +} +Time +MacLow::GetAckDuration (WifiMode ackMode) const +{ return m_phy->CalculateTxDuration (GetAckSize (), ackMode, WIFI_PREAMBLE_LONG); } Time @@ -932,8 +937,15 @@ MacLow::GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const { WifiMode ctsMode = GetCtsTxModeForRts (to, rtsTxMode); + return GetCtsDuration (ctsMode); +} + +Time +MacLow::GetCtsDuration (WifiMode ctsMode) const +{ return m_phy->CalculateTxDuration (GetCtsSize (), ctsMode, WIFI_PREAMBLE_LONG); } + uint32_t MacLow::GetCtsSize (void) const { @@ -948,72 +960,48 @@ return packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); } -WifiMode -MacLow::GetRtsTxMode (Ptr packet, const WifiMacHeader *hdr) const +WifiTxVector +MacLow::GetRtsTxVector (Ptr packet, const WifiMacHeader *hdr) const { Mac48Address to = hdr->GetAddr1 (); - return m_stationManager->GetRtsMode (to, hdr, packet); + return m_stationManager->GetRtsTxVector (to, hdr, packet); } -WifiMode -MacLow::GetDataTxMode (Ptr packet, const WifiMacHeader *hdr) const +WifiTxVector +MacLow::GetDataTxVector (Ptr packet, const WifiMacHeader *hdr) const { Mac48Address to = hdr->GetAddr1 (); WifiMacTrailer fcs; uint32_t size = packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); - return m_stationManager->GetDataMode (to, hdr, packet, size); + return m_stationManager->GetDataTxVector (to, hdr, packet, size); +} +WifiTxVector +MacLow::GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const +{ + return m_stationManager->GetCtsTxVector (to, rtsTxMode); +} +WifiTxVector +MacLow::GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const +{ + return m_stationManager->GetAckTxVector (to, dataTxMode); +} +WifiTxVector +MacLow::GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const +{ + return m_stationManager->GetBlockAckTxVector (to, dataTxMode); } WifiMode MacLow::GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const { - return m_stationManager->GetCtsMode (to, rtsTxMode); + return GetCtsTxVector (to, rtsTxMode).mode; } WifiMode MacLow::GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const { - return m_stationManager->GetAckMode (to, dataTxMode); + return GetAckTxVector (to, dataTxMode).mode; } -Time -MacLow::CalculateOverallTxTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters& params) const -{ - Time txTime = Seconds (0); - WifiMode rtsMode = GetRtsTxMode (packet, hdr); - WifiMode dataMode = GetDataTxMode (packet, hdr); - if (params.MustSendRts ()) - { - txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsMode, WIFI_PREAMBLE_LONG); - txTime += GetCtsDuration (hdr->GetAddr1 (), rtsMode); - txTime += GetSifs () * Scalar (2); - } - uint32_t dataSize = GetSize (packet, hdr); - txTime += m_phy->CalculateTxDuration (dataSize, dataMode, WIFI_PREAMBLE_LONG); - if (params.MustWaitAck ()) - { - txTime += GetSifs (); - txTime += GetAckDuration (hdr->GetAddr1 (), dataMode); - } - return txTime; -} - -Time -MacLow::CalculateTransmissionTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters& params) const -{ - Time txTime = CalculateOverallTxTime (packet, hdr, params); - if (params.HasNextPacket ()) - { - WifiMode dataMode = GetDataTxMode (packet, hdr); - txTime += GetSifs (); - txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataMode, WIFI_PREAMBLE_LONG); - } - return txTime; -} - void MacLow::NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble) { @@ -1126,16 +1114,17 @@ void MacLow::ForwardDown (Ptr packet, const WifiMacHeader* hdr, - WifiMode txMode) + WifiTxVector txVector) { - NS_LOG_FUNCTION (this << packet << hdr << txMode); + NS_LOG_FUNCTION (this << packet << hdr << txVector); NS_LOG_DEBUG ("send " << hdr->GetTypeString () << - ", to=" << hdr->GetAddr1 () << - ", size=" << packet->GetSize () << - ", mode=" << txMode << - ", duration=" << hdr->GetDuration () << - ", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec); - m_phy->SendPacket (packet, txMode, WIFI_PREAMBLE_LONG, 0); + ", to=" << hdr->GetAddr1 () << + ", size=" << packet->GetSize () << + ", mode=" << txVector.mode << + ", pwrlvl=" << (uint16_t) txVector.txPowerLevel << + ", duration=" << hdr->GetDuration () << + ", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec); + m_phy->SendPacket (packet, txVector.mode, WIFI_PREAMBLE_LONG, txVector.txPowerLevel); } void @@ -1225,7 +1214,7 @@ rts.SetNoMoreFragments (); rts.SetAddr1 (m_currentHdr.GetAddr1 ()); rts.SetAddr2 (m_self); - WifiMode rtsTxMode = GetRtsTxMode (m_currentPacket, &m_currentHdr); + WifiTxVector rtsTxVector = GetRtsTxVector (m_currentPacket, &m_currentHdr); Time duration = Seconds (0); if (m_txParams.HasDurationId ()) { @@ -1233,18 +1222,18 @@ } else { - WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); + WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); duration += GetSifs (); - duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxMode); + duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector.mode); duration += GetSifs (); duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), - dataTxMode, WIFI_PREAMBLE_LONG); + dataTxVector.mode, WIFI_PREAMBLE_LONG); duration += GetSifs (); - duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); + duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); } rts.SetDuration (duration); - Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxMode, WIFI_PREAMBLE_LONG); + Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector.mode, WIFI_PREAMBLE_LONG); Time timerDelay = txDuration + GetCtsTimeout (); NS_ASSERT (m_ctsTimeoutEvent.IsExpired ()); @@ -1256,13 +1245,12 @@ WifiMacTrailer fcs; packet->AddTrailer (fcs); - ForwardDown (packet, &rts, rtsTxMode); + ForwardDown (packet, &rts, rtsTxVector); } void -MacLow::StartDataTxTimers (void) +MacLow::StartDataTxTimers (WifiMode dataTxMode) { - WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxMode, WIFI_PREAMBLE_LONG); if (m_txParams.MustWaitNormalAck ()) { @@ -1316,9 +1304,10 @@ { NS_LOG_FUNCTION (this); /* send this packet directly. No RTS is needed. */ - StartDataTxTimers (); - WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); + WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); + StartDataTxTimers (dataTxVector.mode); + Time duration = Seconds (0.0); if (m_txParams.HasDurationId ()) { @@ -1329,27 +1318,27 @@ if (m_txParams.MustWaitBasicBlockAck ()) { duration += GetSifs (); - duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxMode, BASIC_BLOCK_ACK); + duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode, BASIC_BLOCK_ACK); } else if (m_txParams.MustWaitCompressedBlockAck ()) { duration += GetSifs (); - duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxMode, COMPRESSED_BLOCK_ACK); + duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode, COMPRESSED_BLOCK_ACK); } else if (m_txParams.MustWaitAck ()) { duration += GetSifs (); - duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); + duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); } if (m_txParams.HasNextPacket ()) { duration += GetSifs (); duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (), - dataTxMode, WIFI_PREAMBLE_LONG); + dataTxVector.mode, WIFI_PREAMBLE_LONG); if (m_txParams.MustWaitAck ()) { duration += GetSifs (); - duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); + duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); } } } @@ -1359,7 +1348,7 @@ WifiMacTrailer fcs; m_currentPacket->AddTrailer (fcs); - ForwardDown (m_currentPacket, &m_currentHdr, dataTxMode); + ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector); m_currentPacket = 0; } @@ -1383,7 +1372,7 @@ /* send a CTS when you receive a RTS * right after SIFS. */ - WifiMode ctsTxMode = GetCtsTxModeForRts (source, rtsTxMode); + WifiTxVector ctsTxVector = GetCtsTxVector (source, rtsTxMode); WifiMacHeader cts; cts.SetType (WIFI_MAC_CTL_CTS); cts.SetDsNotFrom (); @@ -1391,7 +1380,7 @@ cts.SetNoMoreFragments (); cts.SetNoRetry (); cts.SetAddr1 (source); - duration -= GetCtsDuration (source, rtsTxMode); + duration -= GetCtsDuration (ctsTxVector.mode); duration -= GetSifs (); NS_ASSERT (duration >= MicroSeconds (0)); cts.SetDuration (duration); @@ -1405,25 +1394,26 @@ tag.Set (rtsSnr); packet->AddPacketTag (tag); - ForwardDown (packet, &cts, ctsTxMode); + ForwardDown (packet, &cts, ctsTxVector); } void -MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode) +MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode ctsTxMode) { NS_LOG_FUNCTION (this); /* send the third step in a * RTS/CTS/DATA/ACK hanshake */ NS_ASSERT (m_currentPacket != 0); - StartDataTxTimers (); + WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); + StartDataTxTimers (dataTxVector.mode); - WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); + Time newDuration = Seconds (0); newDuration += GetSifs (); - newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); + newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), - dataTxMode, WIFI_PREAMBLE_LONG); + dataTxVector.mode, WIFI_PREAMBLE_LONG); duration -= txDuration; duration -= GetSifs (); @@ -1435,7 +1425,7 @@ WifiMacTrailer fcs; m_currentPacket->AddTrailer (fcs); - ForwardDown (m_currentPacket, &m_currentHdr, dataTxMode); + ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector); m_currentPacket = 0; } @@ -1462,7 +1452,7 @@ /* send an ACK when you receive * a packet after SIFS. */ - WifiMode ackTxMode = GetAckTxModeForData (source, dataTxMode); + WifiTxVector ackTxVector = GetAckTxVector (source, dataTxMode); WifiMacHeader ack; ack.SetType (WIFI_MAC_CTL_ACK); ack.SetDsNotFrom (); @@ -1473,6 +1463,7 @@ duration -= GetAckDuration (source, dataTxMode); duration -= GetSifs (); NS_ASSERT (duration >= MicroSeconds (0)); + NS_ASSERT (ack.IsMoreFragments () ^ (duration == MicroSeconds (0))); // Section 7.2.1.3 ACK frame format ack.SetDuration (duration); Ptr packet = Create (); @@ -1484,7 +1475,7 @@ tag.Set (dataSnr); packet->AddPacketTag (tag); - ForwardDown (packet, &ack, ackTxMode); + ForwardDown (packet, &ack, ackTxVector); } bool @@ -1539,7 +1530,7 @@ Time timeout = MicroSeconds (1024 * agreement.GetTimeout ()); AcIndex ac = QosUtilsMapTidToAc (agreement.GetTid ()); - + it->second.first.m_inactivityEvent = Simulator::Schedule (timeout, &MacLowBlockAckEventListener::BlockAckInactivityTimeout, m_edcaListeners[ac], @@ -1669,17 +1660,20 @@ m_currentPacket = packet; m_currentHdr = hdr; + + WifiTxVector blockAckTxVector = GetBlockAckTxVector (originator, blockAckReqTxMode); + if (immediate) { m_txParams.DisableAck (); duration -= GetSifs (); if (blockAck->IsBasic ()) { - duration -= GetBlockAckDuration (originator, blockAckReqTxMode, BASIC_BLOCK_ACK); + duration -= GetBlockAckDuration (originator, blockAckTxVector.mode, BASIC_BLOCK_ACK); } else if (blockAck->IsCompressed ()) { - duration -= GetBlockAckDuration (originator, blockAckReqTxMode, COMPRESSED_BLOCK_ACK); + duration -= GetBlockAckDuration (originator, blockAckTxVector.mode, COMPRESSED_BLOCK_ACK); } else if (blockAck->IsMultiTid ()) { @@ -1690,11 +1684,11 @@ { m_txParams.EnableAck (); duration += GetSifs (); - duration += GetAckDuration (originator, blockAckReqTxMode); + duration += GetAckDuration (originator, blockAckTxVector.mode); } m_txParams.DisableNextData (); - StartDataTxTimers (); + StartDataTxTimers (blockAckTxVector.mode); NS_ASSERT (duration >= MicroSeconds (0)); hdr.SetDuration (duration); @@ -1703,7 +1697,7 @@ packet->AddHeader (hdr); WifiMacTrailer fcs; packet->AddTrailer (fcs); - ForwardDown (packet, &hdr, blockAckReqTxMode); + ForwardDown (packet, &hdr, blockAckTxVector); m_currentPacket = 0; } diff -r d5cfe99001f0 src/devices/wifi/mac-low.h --- a/src/devices/wifi/mac-low.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/mac-low.h Fri Jul 23 17:28:11 2010 +0200 @@ -399,17 +399,17 @@ */ void RegisterDcfListener (MacLowDcfListener *listener); - /** - * \param packet to send (does not include the 802.11 MAC header and checksum) - * \param hdr header associated to the packet to send. - * \param parameters transmission parameters of packet. - * - * This transmission time includes the time required for - * the next packet transmission if one was selected. - */ - Time CalculateTransmissionTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters& parameters) const; + // /** + // * \param packet to send (does not include the 802.11 MAC header and checksum) + // * \param hdr header associated to the packet to send. + // * \param parameters transmission parameters of packet. + // * + // * This transmission time includes the time required for + // * the next packet transmission if one was selected. + // */ + // Time CalculateTransmissionTime (Ptr packet, + // const WifiMacHeader* hdr, + // const MacLowTransmissionParameters& parameters) const; /** * \param packet packet to send @@ -489,16 +489,19 @@ uint32_t GetSize (Ptr packet, const WifiMacHeader *hdr) const; Time NowUs (void) const; void ForwardDown (Ptr packet, const WifiMacHeader *hdr, - WifiMode txMode); - Time CalculateOverallTxTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters ¶ms) const; - WifiMode GetRtsTxMode (Ptr packet, const WifiMacHeader *hdr) const; - WifiMode GetDataTxMode (Ptr packet, const WifiMacHeader *hdr) const; + WifiTxVector txVector); + WifiTxVector GetRtsTxVector (Ptr packet, const WifiMacHeader *hdr) const; + WifiTxVector GetDataTxVector (Ptr packet, const WifiMacHeader *hdr) const; + WifiTxVector GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const; + WifiTxVector GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const; + WifiTxVector GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const; + WifiMode GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const; WifiMode GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const; + Time GetCtsDuration (WifiMode ctsTxMode) const; Time GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const; + Time GetAckDuration (WifiMode ackTxMode) const; Time GetAckDuration (Mac48Address to, WifiMode dataTxMode) const; Time GetBlockAckDuration (Mac48Address to, WifiMode blockAckReqTxMode, enum BlockAckType type) const; void NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble); @@ -518,15 +521,15 @@ void FastAckFailedTimeout (void); void BlockAckTimeout (void); void CtsTimeout (void); - void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr); - void SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, double rtsSnr); - void SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode); + void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode rtsTxMode, double rtsSnr); + void SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double rtsSnr); + void SendDataAfterCts (Mac48Address source, Time duration, WifiMode ctsTxMode); void WaitSifsAfterEndTx (void); void SendRtsForPacket (void); void SendDataPacket (void); void SendCurrentTxPacket (void); - void StartDataTxTimers (void); + void StartDataTxTimers (WifiMode dataTxMode); virtual void DoDispose (void); /** * \param originator Address of peer participating in Block Ack mechanism. diff -r d5cfe99001f0 src/devices/wifi/minstrel-wifi-manager.cc --- a/src/devices/wifi/minstrel-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/minstrel-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -425,8 +425,8 @@ station->m_longRetry = 0; } -WifiMode -MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st, +WifiTxVector +MinstrelWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; @@ -438,16 +438,16 @@ station->m_txrate = m_nsupported / 2; } UpdateStats (station); - return GetSupported (station, station->m_txrate); + return WifiTxVector (GetSupported (station, station->m_txrate), GetDefaultTxPowerLevel ()); } -WifiMode -MinstrelWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +MinstrelWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate); - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/minstrel-wifi-manager.h --- a/src/devices/wifi/minstrel-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/minstrel-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -109,8 +109,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; /// for estimating the TxTime of a packet with a given mode diff -r d5cfe99001f0 src/devices/wifi/onoe-wifi-manager.cc --- a/src/devices/wifi/onoe-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/onoe-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -195,8 +195,8 @@ } -WifiMode -OnoeWifiManager::DoGetDataMode (WifiRemoteStation *st, +WifiTxVector +OnoeWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st; @@ -240,15 +240,15 @@ rateIndex = station->m_txrate; } } - return GetSupported (station, rateIndex); + return WifiTxVector (GetSupported (station, rateIndex), GetDefaultTxPowerLevel ()); } -WifiMode -OnoeWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +OnoeWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { OnoeWifiRemoteStation *station = (OnoeWifiRemoteStation *)st; UpdateMode (station); // XXX: can we implement something smarter ? - return GetSupported (station, 0); + return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/onoe-wifi-manager.h --- a/src/devices/wifi/onoe-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/onoe-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -56,8 +56,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool IsLowLatency (void) const; void UpdateRetry (OnoeWifiRemoteStation *station); diff -r d5cfe99001f0 src/devices/wifi/rraa-wifi-manager.cc --- a/src/devices/wifi/rraa-wifi-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/rraa-wifi-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -261,8 +261,8 @@ RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) {} -WifiMode -RraaWifiManager::DoGetDataMode (WifiRemoteStation *st, +WifiTxVector +RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) { RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; @@ -270,12 +270,12 @@ { ResetCountersBasic (station); } - return GetSupported (station, station->m_rate); + return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel ()); } -WifiMode -RraaWifiManager::DoGetRtsMode (WifiRemoteStation *st) +WifiTxVector +RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) { - return GetSupported (st, 0); + return WifiTxVector (GetSupported (st, 0), GetDefaultTxPowerLevel ()); } bool diff -r d5cfe99001f0 src/devices/wifi/rraa-wifi-manager.h --- a/src/devices/wifi/rraa-wifi-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/rraa-wifi-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -65,8 +65,8 @@ double ackSnr, WifiMode ackMode, double dataSnr); virtual void DoReportFinalRtsFailed (WifiRemoteStation *station); virtual void DoReportFinalDataFailed (WifiRemoteStation *station); - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, uint32_t size); - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station); + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size); + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool DoNeedRts (WifiRemoteStation *st, Ptr packet, bool normally); virtual bool IsLowLatency (void) const; diff -r d5cfe99001f0 src/devices/wifi/wifi-remote-station-manager.cc --- a/src/devices/wifi/wifi-remote-station-manager.cc Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/wifi-remote-station-manager.cc Fri Jul 23 17:28:11 2010 +0200 @@ -39,13 +39,13 @@ namespace ns3 { -class TxModeTag : public Tag +class HighLatencyTxVectorTag : public Tag { public: - TxModeTag (); - TxModeTag (WifiMode rtsMode, WifiMode dataMode); - WifiMode GetRtsMode (void) const; - WifiMode GetDataMode (void) const; + HighLatencyTxVectorTag (); + HighLatencyTxVectorTag (WifiTxVector rtsTxVector, WifiTxVector dataTxVector); + WifiTxVector GetRtsTxVector (void) const; + WifiTxVector GetDataTxVector (void) const; static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; @@ -54,71 +54,61 @@ virtual void Deserialize (TagBuffer i); virtual void Print (std::ostream &os) const; private: - WifiMode m_rtsMode; - WifiMode m_dataMode; + WifiTxVector m_rtsTxVector; + WifiTxVector m_dataTxVector; }; -TxModeTag::TxModeTag () +HighLatencyTxVectorTag::HighLatencyTxVectorTag () {} -TxModeTag::TxModeTag (WifiMode rtsMode, WifiMode dataMode) - : m_rtsMode (rtsMode), - m_dataMode (dataMode) +HighLatencyTxVectorTag::HighLatencyTxVectorTag (WifiTxVector rtsTxVector, WifiTxVector dataTxVector) + : m_rtsTxVector (rtsTxVector), + m_dataTxVector (dataTxVector) {} -WifiMode -TxModeTag::GetRtsMode (void) const +WifiTxVector +HighLatencyTxVectorTag::GetRtsTxVector (void) const { - return m_rtsMode; + return m_rtsTxVector; } -WifiMode -TxModeTag::GetDataMode (void) const +WifiTxVector +HighLatencyTxVectorTag::GetDataTxVector (void) const { - return m_dataMode; + return m_dataTxVector; } TypeId -TxModeTag::GetTypeId (void) +HighLatencyTxVectorTag::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::TxModeTag") + static TypeId tid = TypeId ("ns3::HighLatencyTxVectorTag") .SetParent () - .AddConstructor () - .AddAttribute ("RtsTxMode", - "Tx mode of rts to use later", - EmptyAttributeValue (), - MakeWifiModeAccessor (&TxModeTag::GetRtsMode), - MakeWifiModeChecker ()) - .AddAttribute ("DataTxMode", - "Tx mode of data to use later", - EmptyAttributeValue (), - MakeWifiModeAccessor (&TxModeTag::GetDataMode), - MakeWifiModeChecker ()) + .AddConstructor () ; return tid; } TypeId -TxModeTag::GetInstanceTypeId (void) const +HighLatencyTxVectorTag::GetInstanceTypeId (void) const { return GetTypeId (); } uint32_t -TxModeTag::GetSerializedSize (void) const +HighLatencyTxVectorTag::GetSerializedSize (void) const { - return sizeof (WifiMode) * 2; + return sizeof (WifiTxVector) * 2; } void -TxModeTag::Serialize (TagBuffer i) const +HighLatencyTxVectorTag::Serialize (TagBuffer i) const { - i.Write ((uint8_t *)&m_rtsMode, sizeof (WifiMode)); - i.Write ((uint8_t *)&m_dataMode, sizeof (WifiMode)); + i.Write ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector)); + i.Write ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector)); } void -TxModeTag::Deserialize (TagBuffer i) +HighLatencyTxVectorTag::Deserialize (TagBuffer i) { - i.Read ((uint8_t *)&m_rtsMode, sizeof (WifiMode)); - i.Read ((uint8_t *)&m_dataMode, sizeof (WifiMode)); + i.Read ((uint8_t *)&m_rtsTxVector, sizeof (WifiTxVector)); + i.Read ((uint8_t *)&m_dataTxVector, sizeof (WifiTxVector)); } void -TxModeTag::Print (std::ostream &os) const +HighLatencyTxVectorTag::Print (std::ostream &os) const { - os << "Rts=" << m_rtsMode << ", Data=" << m_dataMode; + os << "Rts=" << m_rtsTxVector << ", Data=" << m_dataTxVector; } } // namespace ns3 @@ -166,6 +156,12 @@ WifiModeValue (), MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode), MakeWifiModeChecker ()) + .AddAttribute ("DefaultTxPowerLevel", "Default power level to be used for transmissions. " + "This is the power level that is used by all those WifiManagers that do not" + "implement TX power control.", + UintegerValue (0), + MakeUintegerAccessor (&WifiRemoteStationManager::m_defaultTxPowerLevel), + MakeUintegerChecker ()) .AddTraceSource ("MacTxRtsFailed", "The transmission of a RTS by the MAC layer has failed", MakeTraceSourceAccessor (&WifiRemoteStationManager::m_macTxRtsFailed)) @@ -339,47 +335,50 @@ return; } WifiRemoteStation *station = Lookup (address, header); - WifiMode rts = DoGetRtsMode (station); - WifiMode data = DoGetDataMode (station, fullPacketSize); - TxModeTag tag; + WifiTxVector rts = DoGetRtsTxVector (station); + WifiTxVector data = DoGetDataTxVector (station, fullPacketSize); + HighLatencyTxVectorTag tag; // first, make sure that the tag is not here anymore. ConstCast (packet)->RemovePacketTag (tag); - tag = TxModeTag (rts, data); + tag = HighLatencyTxVectorTag (rts, data); // and then, add it back packet->AddPacketTag (tag); } -WifiMode -WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader *header, +WifiTxVector +WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr packet, uint32_t fullPacketSize) { if (address.IsGroup ()) { - return GetNonUnicastMode (); + WifiTxVector v; + v.mode = GetNonUnicastMode (); + v.txPowerLevel = m_defaultTxPowerLevel; + return v; } if (!IsLowLatency ()) { - TxModeTag tag; + HighLatencyTxVectorTag tag; bool found; found = ConstCast (packet)->PeekPacketTag (tag); NS_ASSERT (found); - return tag.GetDataMode (); + return tag.GetDataTxVector (); } - return DoGetDataMode (Lookup (address, header), fullPacketSize); + return DoGetDataTxVector (Lookup (address, header), fullPacketSize); } -WifiMode -WifiRemoteStationManager::GetRtsMode (Mac48Address address, const WifiMacHeader *header, +WifiTxVector +WifiRemoteStationManager::GetRtsTxVector (Mac48Address address, const WifiMacHeader *header, Ptr packet) { NS_ASSERT (!address.IsGroup ()); if (!IsLowLatency ()) { - TxModeTag tag; + HighLatencyTxVectorTag tag; bool found; found = ConstCast (packet)->PeekPacketTag (tag); NS_ASSERT (found); - return tag.GetRtsMode (); + return tag.GetRtsTxVector (); } - return DoGetRtsMode (Lookup (address, header)); + return DoGetRtsTxVector (Lookup (address, header)); } void WifiRemoteStationManager::ReportRtsFailed (Mac48Address address, const WifiMacHeader *header) @@ -641,17 +640,54 @@ return mode; } -WifiMode -WifiRemoteStationManager::GetCtsMode (Mac48Address address, WifiMode rtsMode) +WifiTxVector +WifiRemoteStationManager::GetCtsTxVector (Mac48Address address, WifiMode rtsMode) { NS_ASSERT (!address.IsGroup ()); - return GetControlAnswerMode (address, rtsMode); + WifiTxVector v; + v.mode = GetControlAnswerMode (address, rtsMode); + v.txPowerLevel = DoGetCtsTxPowerLevel (address, v.mode); + return v; } -WifiMode -WifiRemoteStationManager::GetAckMode (Mac48Address address, WifiMode dataMode) +WifiTxVector +WifiRemoteStationManager::GetAckTxVector (Mac48Address address, WifiMode dataMode) { NS_ASSERT (!address.IsGroup ()); - return GetControlAnswerMode (address, dataMode); + WifiTxVector v; + v.mode = GetControlAnswerMode (address, dataMode); + v.txPowerLevel = DoGetCtsTxPowerLevel (address, v.mode); + return v; +} +WifiTxVector +WifiRemoteStationManager::GetBlockAckTxVector (Mac48Address address, WifiMode blockAckReqMode) +{ + NS_ASSERT (!address.IsGroup ()); + WifiTxVector v; + v.mode = GetControlAnswerMode (address, blockAckReqMode); + v.txPowerLevel = DoGetCtsTxPowerLevel (address, v.mode); + return v; +} + +uint8_t +WifiRemoteStationManager::DoGetCtsTxPowerLevel (Mac48Address address, WifiMode ctsMode) +{ + return m_defaultTxPowerLevel; +} +uint8_t +WifiRemoteStationManager::DoGetAckTxPowerLevel (Mac48Address address, WifiMode ackMode) +{ + return m_defaultTxPowerLevel; +} +uint8_t +WifiRemoteStationManager::DoGetBlockAckTxPowerLevel (Mac48Address address, WifiMode blockAckMode) +{ + return m_defaultTxPowerLevel; +} + +uint8_t +WifiRemoteStationManager::GetDefaultTxPowerLevel (void) const +{ + return m_defaultTxPowerLevel; } WifiRemoteStationInfo diff -r d5cfe99001f0 src/devices/wifi/wifi-remote-station-manager.h --- a/src/devices/wifi/wifi-remote-station-manager.h Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/wifi-remote-station-manager.h Fri Jul 23 17:28:11 2010 +0200 @@ -28,6 +28,7 @@ #include "ns3/object.h" #include "ns3/nstime.h" #include "wifi-mode.h" +#include "wifi-tx-vector.h" namespace ns3 { @@ -155,7 +156,7 @@ * \param fullPacketSize the size of the packet after its 802.11 MAC header has been added. * \returns the transmission mode to use to send this packet */ - WifiMode GetDataMode (Mac48Address address, const WifiMacHeader *header, + WifiTxVector GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr packet, uint32_t fullPacketSize); /** * \param address remote address @@ -164,7 +165,7 @@ * \returns the transmission mode to use to send the RTS prior to the * transmission of the data packet itself. */ - WifiMode GetRtsMode (Mac48Address address, const WifiMacHeader *header, + WifiTxVector GetRtsTxVector (Mac48Address address, const WifiMacHeader *header, Ptr packet); /** * Should be invoked whenever the RtsTimeout associated to a transmission @@ -280,14 +281,23 @@ * \returns the transmission mode to use for the CTS to complete the RTS/CTS * handshake. */ - WifiMode GetCtsMode (Mac48Address address, WifiMode rtsMode); + WifiTxVector GetCtsTxVector (Mac48Address address, WifiMode rtsMode); /** * \param address * \param dataMode the transmission mode used to send an ACK we just received * \returns the transmission mode to use for the ACK to complete the data/ACK * handshake. */ - WifiMode GetAckMode (Mac48Address address, WifiMode dataMode); + WifiTxVector GetAckTxVector (Mac48Address address, WifiMode dataMode); + /** + * \param address + * \param dataMode the transmission mode used to send an ACK we just received + * \returns the transmission mode to use for the ACK to complete the data/ACK + * handshake. + */ + WifiTxVector GetBlockAckTxVector (Mac48Address address, WifiMode dataMode); + + uint8_t GetDefaultTxPowerLevel (void) const; WifiRemoteStationInfo GetInfo (Mac48Address address); protected: @@ -366,7 +376,7 @@ * Note: This method is called before sending a unicast packet or a fragment * of a unicast packet to decide which transmission mode to use. */ - virtual WifiMode DoGetDataMode (WifiRemoteStation *station, + virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size) = 0; /** * \param station the station with which we need to communicate @@ -375,7 +385,32 @@ * Note: This method is called before sending an rts to a station * to decide which transmission mode to use for the rts. */ - virtual WifiMode DoGetRtsMode (WifiRemoteStation *station) = 0; + virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station) = 0; + + /** + * \param address the address of the recipient of the CTS + * \param ctsMode the mode to be used for the CTS + * + * \return the power level to be used to send the CTS + */ + virtual uint8_t DoGetCtsTxPowerLevel (Mac48Address address, WifiMode ctsMode); + + /** + * \param address the address of the recipient of the ACK + * \param ctsMode the mode to be used for the ACK + * + * \return the power level to be used to send the ACK + */ + virtual uint8_t DoGetAckTxPowerLevel (Mac48Address address, WifiMode ackMode); + + /** + * \param address the address of the recipient of the Block ACK + * \param ctsMode the mode to be used for the Block ACK + * + * \return the power level to be used to send the Block ACK + */ + virtual uint8_t DoGetBlockAckTxPowerLevel (Mac48Address address, WifiMode blockAckMode); + virtual void DoReportRtsFailed (WifiRemoteStation *station) = 0; virtual void DoReportDataFailed (WifiRemoteStation *station) = 0; virtual void DoReportRtsOk (WifiRemoteStation *station, @@ -426,6 +461,7 @@ uint32_t m_rtsCtsThreshold; uint32_t m_fragmentationThreshold; WifiMode m_nonUnicastMode; + uint8_t m_defaultTxPowerLevel; double m_avgSlrcCoefficient; /** * The trace source fired when the transmission of a single RTS has failed diff -r d5cfe99001f0 src/devices/wifi/wifi-tx-vector.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/devices/wifi/wifi-tx-vector.cc Fri Jul 23 17:28:11 2010 +0200 @@ -0,0 +1,41 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2010 CTTC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Nicola Baldo + */ + +#include "ns3/wifi-tx-vector.h" + +namespace ns3 { + +WifiTxVector::WifiTxVector () +{ +} + +WifiTxVector::WifiTxVector (WifiMode m, uint8_t l) + : mode (m), + txPowerLevel (l) +{ +} + +std::ostream & operator << (std::ostream & os, const WifiTxVector &v) +{ + os << "mode:" << v.mode << " txpwrlvl:" << v.txPowerLevel; + return os; +} + +} // namespace ns3 diff -r d5cfe99001f0 src/devices/wifi/wifi-tx-vector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/devices/wifi/wifi-tx-vector.h Fri Jul 23 17:28:11 2010 +0200 @@ -0,0 +1,63 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2010 CTTC + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Nicola Baldo + */ + +#ifndef WIFI_TX_VECTOR_H +#define WIFI_TX_VECTOR_H + +#include +#include + +namespace ns3 { + + +/** + * This class mimics the TXVECTOR which is to be + * passed to the PHY in order to define the parameters which are to be + * used for a transmission. See IEEE 802.11-2007 15.2.6 "Transmit PLCP", + * and also 15.4.4.2 "PMD_SAP peer-to-peer service primitive + * parameters". + * + * \note the above reference is valid for the DSSS PHY only (clause + * 15). TXVECTOR is defined also for the other PHYs, however they + * don't include the TXPWRLVL explicitly in the TXVECTOR. This is + * somewhat strange, since all PHYs actually have a + * PMD_TXPWRLVL.request primitive. We decide to include the power + * level in WifiTxVector for all PHYs, since it serves better our + * purposes, and furthermore it seems close to the way real devices + * work (e.g., madwifi). + */ +struct WifiTxVector +{ + WifiTxVector (); + WifiTxVector (WifiMode m, uint8_t l); + + WifiMode mode; /**< The DATARATE parameter in Table 15-4. + It is the value that will be passed + to PMD_RATE.request */ + uint8_t txPowerLevel; /**< The TXPWR_LEVEL parameter in Table 15-4. + It is the value that will be passed + to PMD_TXPWRLVL.request */ +}; + +std::ostream & operator << (std::ostream & os, const WifiTxVector &v); + +} // namespace ns3 + +#endif // WIFI_TX_VECTOR_H diff -r d5cfe99001f0 src/devices/wifi/wscript --- a/src/devices/wifi/wscript Tue Jul 20 07:34:14 2010 -0700 +++ b/src/devices/wifi/wscript Fri Jul 23 17:28:11 2010 +0200 @@ -65,6 +65,7 @@ 'block-ack-agreement.cc', 'block-ack-manager.cc', 'block-ack-test-suite.cc', + 'wifi-tx-vector.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'wifi' @@ -123,6 +124,7 @@ 'ctrl-headers.h', 'block-ack-agreement.h', 'block-ack-manager.h', + 'wifi-tx-vector.h', ] if bld.env['ENABLE_GSL']: