00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "aarf-wifi-manager.h"
00022
00023 #include "ns3/double.h"
00024 #include "ns3/uinteger.h"
00025
00026 #define Min(a,b) ((a<b)?a:b)
00027 #define Max(a,b) ((a>b)?a:b)
00028
00029 namespace ns3 {
00030
00031 NS_OBJECT_ENSURE_REGISTERED (AarfWifiManager);
00032
00033 TypeId
00034 AarfWifiManager::GetTypeId (void)
00035 {
00036 static TypeId tid = TypeId ("ns3::AarfWifiManager")
00037 .SetParent<ArfWifiManager> ()
00038 .AddConstructor<AarfWifiManager> ()
00039 .AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.",
00040 DoubleValue (2.0),
00041 MakeDoubleAccessor (&AarfWifiManager::m_successK),
00042 MakeDoubleChecker<double> ())
00043 .AddAttribute ("TimerK",
00044 "Multiplication factor for the timer threshold in the AARF algorithm.",
00045 DoubleValue (2.0),
00046 MakeDoubleAccessor (&AarfWifiManager::m_timerK),
00047 MakeDoubleChecker<double> ())
00048 .AddAttribute ("MaxSuccessThreshold",
00049 "Maximum value of the success threshold in the AARF algorithm.",
00050 UintegerValue (60),
00051 MakeUintegerAccessor (&AarfWifiManager::m_maxSuccessThreshold),
00052 MakeUintegerChecker<uint32_t> ())
00053 .AddAttribute ("MinTimerThreshold",
00054 "The minimum value for the 'timer' threshold in the AARF algorithm.",
00055 UintegerValue (15),
00056 MakeUintegerAccessor (&AarfWifiManager::m_minTimerThreshold),
00057 MakeUintegerChecker<uint32_t> ())
00058 .AddAttribute ("MinSuccessThreshold",
00059 "The minimum value for the success threshold in the AARF algorithm.",
00060 UintegerValue (10),
00061 MakeUintegerAccessor (&AarfWifiManager::m_minSuccessThreshold),
00062 MakeUintegerChecker<uint32_t> ())
00063 ;
00064 return tid;
00065 }
00066
00067 AarfWifiManager::AarfWifiManager ()
00068 {}
00069 AarfWifiManager::~AarfWifiManager ()
00070 {}
00071 WifiRemoteStation *
00072 AarfWifiManager::CreateStation (void)
00073 {
00074 return new AarfWifiRemoteStation (this, m_minTimerThreshold,
00075 m_minSuccessThreshold,
00076 m_successK,
00077 m_maxSuccessThreshold,
00078 m_timerK);
00079 }
00080
00081
00082
00083
00084 AarfWifiRemoteStation::AarfWifiRemoteStation (Ptr<AarfWifiManager> stations,
00085 uint32_t minTimerThreshold,
00086 uint32_t minSuccessThreshold,
00087 double successK,
00088 uint32_t maxSuccessThreshold,
00089 double timerK)
00090 : ArfWifiRemoteStation (stations, minTimerThreshold, minSuccessThreshold),
00091 m_successK (successK),
00092 m_maxSuccessThreshold (maxSuccessThreshold),
00093 m_timerK (timerK)
00094 {}
00095
00096
00097 AarfWifiRemoteStation::~AarfWifiRemoteStation ()
00098 {}
00099
00100 void
00101 AarfWifiRemoteStation::ReportRecoveryFailure (void)
00102 {
00103 SetSuccessThreshold ((int)(Min (GetSuccessThreshold () * m_successK,
00104 m_maxSuccessThreshold)));
00105 SetTimerTimeout ((int)(Max (GetMinTimerTimeout (),
00106 GetSuccessThreshold () * m_timerK)));
00107 }
00108
00109 void
00110 AarfWifiRemoteStation::ReportFailure (void)
00111 {
00112 SetTimerTimeout (GetMinTimerTimeout ());
00113 SetSuccessThreshold (GetMinSuccessThreshold ());
00114 }
00115
00116 }