LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Kirill Andreev <andreev@iitp.ru> | 18 * Authors: Kirill Andreev <andreev@iitp.ru> |
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 () |
29 { | 31 { |
30 static TypeId tid = TypeId ("ns3::dot11s::AirtimeLinkMetricCalculator") | 32 static TypeId tid = TypeId ("ns3::dot11s::AirtimeLinkMetricCalculator") |
31 .SetParent<Object> () | 33 .SetParent<Object> () |
32 .AddConstructor<AirtimeLinkMetricCalculator> () | 34 .AddConstructor<AirtimeLinkMetricCalculator> () |
33 .AddAttribute ( "TestLength", | 35 .AddAttribute ( "TestLength", |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 * airtime = (O + Bt/r) / (1 - frame error rate), where | 73 * airtime = (O + Bt/r) / (1 - frame error rate), where |
72 * o -- the PHY dependent channel access which includes frame headers, traini
ng sequences, | 74 * o -- the PHY dependent channel access which includes frame headers, traini
ng sequences, |
73 * access protocol frames, etc. | 75 * access protocol frames, etc. |
74 * bt -- the test packet length in bits (8192 by default), | 76 * bt -- the test packet length in bits (8192 by default), |
75 * r -- the current bitrate of the packet, | 77 * r -- the current bitrate of the packet, |
76 * | 78 * |
77 * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as require
d by 802.11s draft) | 79 * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as require
d by 802.11s draft) |
78 */ | 80 */ |
79 NS_ASSERT (!peerAddress.IsGroup ()); | 81 NS_ASSERT (!peerAddress.IsGroup ()); |
80 //obtain current rate: | 82 //obtain current rate: |
81 WifiMode mode = mac->GetWifiRemoteStationManager ()->GetDataMode (peerAddress,
&m_testHeader, m_testFrame, m_testFrame->GetSize ()); | 83 WifiMode mode = mac->GetWifiRemoteStationManager ()->GetDataTxVector (peerAddr
ess, &m_testHeader, m_testFrame, m_testFrame->GetSize ()).GetMode(); |
82 //obtain frame error rate: | 84 //obtain frame error rate: |
83 double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).Ge
tFrameErrorRate (); | 85 double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).Ge
tFrameErrorRate (); |
84 if (failAvg == 1) | 86 if (failAvg == 1) |
85 { | 87 { |
86 // Retrun max metric value when frame error rate equals to 1 | 88 // Retrun max metric value when frame error rate equals to 1 |
87 return (uint32_t)0xffffffff; | 89 return (uint32_t)0xffffffff; |
88 } | 90 } |
89 NS_ASSERT (failAvg < 1.0); | 91 NS_ASSERT (failAvg < 1.0); |
| 92 WifiTxVector txVector; |
| 93 txVector.SetMode (mode); |
90 //calculate metric | 94 //calculate metric |
91 uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/ | 95 uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/ |
92 mac->GetPifs () + mac->GetSlot () + mac->GetEif
sNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs | 96 mac->GetPifs () + mac->GetSlot () + mac->GetEif
sNoDifs () + //DIFS + SIFS + AckTxTime = PIFS + SLOT + EifsNoDifs |
93 mac->GetWifiPhy ()->CalculateTxDuration (m_test
Frame->GetSize (), mode, WIFI_PREAMBLE_LONG) | 97 mac->GetWifiPhy ()->CalculateTxDuration (m_test
Frame->GetSize (), txVector, WIFI_PREAMBLE_LONG) |
94 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)
)); | 98 ).GetMicroSeconds () / (10.24 * (1.0 - failAvg)
)); |
95 return metric; | 99 return metric; |
96 } | 100 } |
97 } // namespace dot11s | 101 } // namespace dot11s |
98 } // namespace ns3 | 102 } // namespace ns3 |
LEFT | RIGHT |