21 #include "airtime-metric.h"
22 #include "ns3/wifi-remote-station-manager.h"
23 #include "ns3/wifi-mode.h"
26 NS_OBJECT_ENSURE_REGISTERED (AirtimeLinkMetricCalculator);
28 AirtimeLinkMetricCalculator::GetTypeId ()
30 static TypeId tid = TypeId (
"ns3::dot11s::AirtimeLinkMetricCalculator")
32 .AddConstructor<AirtimeLinkMetricCalculator> ()
33 .AddAttribute (
"TestLength",
34 "Rate should be estimated using test length.",
36 MakeUintegerAccessor (
37 &AirtimeLinkMetricCalculator::SetTestLength),
38 MakeUintegerChecker<uint16_t> (1)
40 .AddAttribute (
"Dot11MetricTid",
41 "TID used to calculate metric (data rate)",
43 MakeUintegerAccessor (
44 &AirtimeLinkMetricCalculator::SetHeaderTid),
45 MakeUintegerChecker<uint8_t> (0)
47 .AddAttribute (
"Dot11sMeshHeaderLength",
48 "Length of the mesh header",
50 MakeUintegerAccessor (
52 MakeUintegerChecker<uint16_t> (0)
57 AirtimeLinkMetricCalculator::AirtimeLinkMetricCalculator () :
62 AirtimeLinkMetricCalculator::SetHeaderTid (uint8_t tid)
64 m_testHeader.SetDsFrom ();
65 m_testHeader.SetDsTo ();
66 m_testHeader.SetTypeData ();
67 m_testHeader.SetQosTid (tid);
70 AirtimeLinkMetricCalculator::SetTestLength (uint16_t testLength)
72 m_testFrame = Create<Packet> (testLength + 6 + 36 );
75 AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, Ptr<MeshWifiInterfaceMac> mac)
89 WifiMode mode = mac->GetWifiRemoteStationManager ()->GetDataMode (peerAddress, &m_testHeader, m_testFrame, m_testFrame->
GetSize ());
91 double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).GetFrameErrorRate ();
95 return (uint32_t)0xffffffff;
99 uint32_t metric = (uint32_t)((
double)(
100 mac->GetPifs () + mac->GetSlot () + mac->GetEifsNoDifs () +
101 mac->GetWifiPhy ()->CalculateTxDuration (m_testFrame->
GetSize (), mode, WIFI_PREAMBLE_LONG)
102 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)));
#define NS_ASSERT(condition)
uint32_t GetSize(void) const
uint16_t m_meshHeaderLength
meshHeader length (minimum 6 octets)