src/wifi/model/amrr-wifi-manager.cc
changeset 9705 43fa2408aa05
parent 7385 10beb0e53130
child 9894 ac4e52a91d5d
equal deleted inserted replaced
9704:1db7690f8e8f 9705:43fa2408aa05
    79   return tid;
    79   return tid;
    80 }
    80 }
    81 
    81 
    82 AmrrWifiManager::AmrrWifiManager ()
    82 AmrrWifiManager::AmrrWifiManager ()
    83 {
    83 {
       
    84   NS_LOG_FUNCTION (this);
    84 }
    85 }
    85 
    86 
    86 WifiRemoteStation *
    87 WifiRemoteStation *
    87 AmrrWifiManager::DoCreateStation (void) const
    88 AmrrWifiManager::DoCreateStation (void) const
    88 {
    89 {
       
    90   NS_LOG_FUNCTION (this);
    89   AmrrWifiRemoteStation *station = new AmrrWifiRemoteStation ();
    91   AmrrWifiRemoteStation *station = new AmrrWifiRemoteStation ();
    90   station->m_nextModeUpdate = Simulator::Now () + m_updatePeriod;
    92   station->m_nextModeUpdate = Simulator::Now () + m_updatePeriod;
    91   station->m_tx_ok = 0;
    93   station->m_tx_ok = 0;
    92   station->m_tx_err = 0;
    94   station->m_tx_err = 0;
    93   station->m_tx_retr = 0;
    95   station->m_tx_retr = 0;
   102 
   104 
   103 void
   105 void
   104 AmrrWifiManager::DoReportRxOk (WifiRemoteStation *station,
   106 AmrrWifiManager::DoReportRxOk (WifiRemoteStation *station,
   105                                double rxSnr, WifiMode txMode)
   107                                double rxSnr, WifiMode txMode)
   106 {
   108 {
       
   109   NS_LOG_FUNCTION (this << station << rxSnr << txMode);
   107 }
   110 }
   108 void
   111 void
   109 AmrrWifiManager::DoReportRtsFailed (WifiRemoteStation *station)
   112 AmrrWifiManager::DoReportRtsFailed (WifiRemoteStation *station)
   110 {
   113 {
       
   114   NS_LOG_FUNCTION (this << station);
   111 }
   115 }
   112 void
   116 void
   113 AmrrWifiManager::DoReportDataFailed (WifiRemoteStation *st)
   117 AmrrWifiManager::DoReportDataFailed (WifiRemoteStation *st)
   114 {
   118 {
       
   119   NS_LOG_FUNCTION (this << st);
   115   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   120   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   116   station->m_retry++;
   121   station->m_retry++;
   117   station->m_tx_retr++;
   122   station->m_tx_retr++;
   118 }
   123 }
   119 void
   124 void
   120 AmrrWifiManager::DoReportRtsOk (WifiRemoteStation *st,
   125 AmrrWifiManager::DoReportRtsOk (WifiRemoteStation *st,
   121                                 double ctsSnr, WifiMode ctsMode, double rtsSnr)
   126                                 double ctsSnr, WifiMode ctsMode, double rtsSnr)
   122 {
   127 {
       
   128   NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr);
   123 }
   129 }
   124 void
   130 void
   125 AmrrWifiManager::DoReportDataOk (WifiRemoteStation *st,
   131 AmrrWifiManager::DoReportDataOk (WifiRemoteStation *st,
   126                                  double ackSnr, WifiMode ackMode, double dataSnr)
   132                                  double ackSnr, WifiMode ackMode, double dataSnr)
   127 {
   133 {
       
   134   NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr);
   128   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   135   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   129   station->m_retry = 0;
   136   station->m_retry = 0;
   130   station->m_tx_ok++;
   137   station->m_tx_ok++;
   131 }
   138 }
   132 void
   139 void
   133 AmrrWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station)
   140 AmrrWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station)
   134 {
   141 {
       
   142   NS_LOG_FUNCTION (this << station);
   135 }
   143 }
   136 void
   144 void
   137 AmrrWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
   145 AmrrWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
   138 {
   146 {
       
   147   NS_LOG_FUNCTION (this << st);
   139   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   148   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   140   station->m_retry = 0;
   149   station->m_retry = 0;
   141   station->m_tx_err++;
   150   station->m_tx_err++;
   142 }
   151 }
   143 bool
   152 bool
   144 AmrrWifiManager::IsMinRate (AmrrWifiRemoteStation *station) const
   153 AmrrWifiManager::IsMinRate (AmrrWifiRemoteStation *station) const
   145 {
   154 {
       
   155   NS_LOG_FUNCTION (this << station);
   146   return (station->m_txrate == 0);
   156   return (station->m_txrate == 0);
   147 }
   157 }
   148 bool
   158 bool
   149 AmrrWifiManager::IsMaxRate (AmrrWifiRemoteStation *station) const
   159 AmrrWifiManager::IsMaxRate (AmrrWifiRemoteStation *station) const
   150 {
   160 {
       
   161   NS_LOG_FUNCTION (this << station);
   151   NS_ASSERT (station->m_txrate + 1 <= GetNSupported (station));
   162   NS_ASSERT (station->m_txrate + 1 <= GetNSupported (station));
   152   return (station->m_txrate + 1 == GetNSupported (station));
   163   return (station->m_txrate + 1 == GetNSupported (station));
   153 }
   164 }
   154 bool
   165 bool
   155 AmrrWifiManager::IsSuccess (AmrrWifiRemoteStation *station) const
   166 AmrrWifiManager::IsSuccess (AmrrWifiRemoteStation *station) const
   156 {
   167 {
       
   168   NS_LOG_FUNCTION (this << station);
   157   return (station->m_tx_retr + station->m_tx_err) < station->m_tx_ok * m_successRatio;
   169   return (station->m_tx_retr + station->m_tx_err) < station->m_tx_ok * m_successRatio;
   158 }
   170 }
   159 bool
   171 bool
   160 AmrrWifiManager::IsFailure (AmrrWifiRemoteStation *station) const
   172 AmrrWifiManager::IsFailure (AmrrWifiRemoteStation *station) const
   161 {
   173 {
       
   174   NS_LOG_FUNCTION (this << station);
   162   return (station->m_tx_retr + station->m_tx_err) > station->m_tx_ok * m_failureRatio;
   175   return (station->m_tx_retr + station->m_tx_err) > station->m_tx_ok * m_failureRatio;
   163 }
   176 }
   164 bool
   177 bool
   165 AmrrWifiManager::IsEnough (AmrrWifiRemoteStation *station) const
   178 AmrrWifiManager::IsEnough (AmrrWifiRemoteStation *station) const
   166 {
   179 {
       
   180   NS_LOG_FUNCTION (this << station);
   167   return (station->m_tx_retr + station->m_tx_err + station->m_tx_ok) > 10;
   181   return (station->m_tx_retr + station->m_tx_err + station->m_tx_ok) > 10;
   168 }
   182 }
   169 void
   183 void
   170 AmrrWifiManager::ResetCnt (AmrrWifiRemoteStation *station)
   184 AmrrWifiManager::ResetCnt (AmrrWifiRemoteStation *station)
   171 {
   185 {
       
   186   NS_LOG_FUNCTION (this << station);
   172   station->m_tx_ok = 0;
   187   station->m_tx_ok = 0;
   173   station->m_tx_err = 0;
   188   station->m_tx_err = 0;
   174   station->m_tx_retr = 0;
   189   station->m_tx_retr = 0;
   175 }
   190 }
   176 void
   191 void
   177 AmrrWifiManager::IncreaseRate (AmrrWifiRemoteStation *station)
   192 AmrrWifiManager::IncreaseRate (AmrrWifiRemoteStation *station)
   178 {
   193 {
       
   194   NS_LOG_FUNCTION (this << station);
   179   station->m_txrate++;
   195   station->m_txrate++;
   180   NS_ASSERT (station->m_txrate < GetNSupported (station));
   196   NS_ASSERT (station->m_txrate < GetNSupported (station));
   181 }
   197 }
   182 void
   198 void
   183 AmrrWifiManager::DecreaseRate (AmrrWifiRemoteStation *station)
   199 AmrrWifiManager::DecreaseRate (AmrrWifiRemoteStation *station)
   184 {
   200 {
       
   201   NS_LOG_FUNCTION (this << station);
   185   station->m_txrate--;
   202   station->m_txrate--;
   186 }
   203 }
   187 
   204 
   188 void
   205 void
   189 AmrrWifiManager::UpdateMode (AmrrWifiRemoteStation *station)
   206 AmrrWifiManager::UpdateMode (AmrrWifiRemoteStation *station)
   190 {
   207 {
       
   208   NS_LOG_FUNCTION (this << station);
   191   if (Simulator::Now () < station->m_nextModeUpdate)
   209   if (Simulator::Now () < station->m_nextModeUpdate)
   192     {
   210     {
   193       return;
   211       return;
   194     }
   212     }
   195   station->m_nextModeUpdate = Simulator::Now () + m_updatePeriod;
   213   station->m_nextModeUpdate = Simulator::Now () + m_updatePeriod;
   250     }
   268     }
   251 }
   269 }
   252 WifiMode
   270 WifiMode
   253 AmrrWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size)
   271 AmrrWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size)
   254 {
   272 {
       
   273   NS_LOG_FUNCTION (this << st << size);
   255   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   274   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   256   UpdateMode (station);
   275   UpdateMode (station);
   257   NS_ASSERT (station->m_txrate < GetNSupported (station));
   276   NS_ASSERT (station->m_txrate < GetNSupported (station));
   258   uint32_t rateIndex;
   277   uint32_t rateIndex;
   259   if (station->m_retry < 1)
   278   if (station->m_retry < 1)
   297   return GetSupported (station, rateIndex);
   316   return GetSupported (station, rateIndex);
   298 }
   317 }
   299 WifiMode
   318 WifiMode
   300 AmrrWifiManager::DoGetRtsMode (WifiRemoteStation *st)
   319 AmrrWifiManager::DoGetRtsMode (WifiRemoteStation *st)
   301 {
   320 {
       
   321   NS_LOG_FUNCTION (this << st);
   302   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   322   AmrrWifiRemoteStation *station = (AmrrWifiRemoteStation *)st;
   303   UpdateMode (station);
   323   UpdateMode (station);
   304   // XXX: can we implement something smarter ?
   324   // XXX: can we implement something smarter ?
   305   return GetSupported (station, 0);
   325   return GetSupported (station, 0);
   306 }
   326 }
   307 
   327 
   308 
   328 
   309 bool
   329 bool
   310 AmrrWifiManager::IsLowLatency (void) const
   330 AmrrWifiManager::IsLowLatency (void) const
   311 {
   331 {
       
   332   NS_LOG_FUNCTION (this);
   312   return true;
   333   return true;
   313 }
   334 }
   314 
   335 
   315 } // namespace ns3
   336 } // namespace ns3