19 */ |
19 */ |
20 |
20 |
21 #include "airtime-metric.h" |
21 #include "airtime-metric.h" |
22 #include "ns3/wifi-remote-station-manager.h" |
22 #include "ns3/wifi-remote-station-manager.h" |
23 #include "ns3/wifi-mode.h" |
23 #include "ns3/wifi-mode.h" |
|
24 #include "ns3/wifi-tx-vector.h" |
|
25 |
24 namespace ns3 { |
26 namespace ns3 { |
25 namespace dot11s { |
27 namespace dot11s { |
26 NS_OBJECT_ENSURE_REGISTERED (AirtimeLinkMetricCalculator); |
28 NS_OBJECT_ENSURE_REGISTERED (AirtimeLinkMetricCalculator); |
27 TypeId |
29 TypeId |
28 AirtimeLinkMetricCalculator::GetTypeId () |
30 AirtimeLinkMetricCalculator::GetTypeId () |
84 * |
86 * |
85 * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as required by 802.11s draft) |
87 * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as required by 802.11s draft) |
86 */ |
88 */ |
87 NS_ASSERT (!peerAddress.IsGroup ()); |
89 NS_ASSERT (!peerAddress.IsGroup ()); |
88 //obtain current rate: |
90 //obtain current rate: |
89 WifiMode mode = mac->GetWifiRemoteStationManager ()->GetDataMode (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()); |
91 WifiMode mode = mac->GetWifiRemoteStationManager ()->GetDataTxVector (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()).GetMode(); |
90 //obtain frame error rate: |
92 //obtain frame error rate: |
91 double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).GetFrameErrorRate (); |
93 double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).GetFrameErrorRate (); |
92 if (failAvg == 1) |
94 if (failAvg == 1) |
93 { |
95 { |
94 // Retrun max metric value when frame error rate equals to 1 |
96 // Retrun max metric value when frame error rate equals to 1 |
95 return (uint32_t)0xffffffff; |
97 return (uint32_t)0xffffffff; |
96 } |
98 } |
97 NS_ASSERT (failAvg < 1.0); |
99 NS_ASSERT (failAvg < 1.0); |
|
100 WifiTxVector txVector; |
|
101 txVector.SetMode (mode); |
98 //calculate metric |
102 //calculate metric |
99 uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/ |
103 uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/ |
100 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs |
104 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs |
101 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), mode, WIFI_PREAMBLE_LONG) |
105 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->GetSize (), txVector, WIFI_PREAMBLE_LONG) |
102 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg))); |
106 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg))); |
103 return metric; |
107 return metric; |
104 } |
108 } |
105 } // namespace dot11s |
109 } // namespace dot11s |
106 } // namespace ns3 |
110 } // namespace ns3 |