AMRR rate control algorithm
This commit is contained in:
129
src/devices/wifi/amrr-mac-stations.cc
Normal file
129
src/devices/wifi/amrr-mac-stations.cc
Normal file
@@ -0,0 +1,129 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2003,2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "amrr-mac-stations.h"
|
||||
#include "ns3/default-value.h"
|
||||
#include "ns3/time-default-value.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("AmrrMacStation");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
static TimeDefaultValue g_updatePeriod
|
||||
("WifiAmrrUpdatePeriod",
|
||||
"The interval between decisions about rate control changes",
|
||||
Seconds (1.0));
|
||||
|
||||
AmrrMacStations::AmrrMacStations (WifiMode defaultTxMode)
|
||||
: MacStations (defaultTxMode),
|
||||
m_updatePeriod (g_updatePeriod.GetValue ())
|
||||
{}
|
||||
MacStation *
|
||||
AmrrMacStations::CreateStation (void)
|
||||
{
|
||||
return new AmrrMacStation (this);
|
||||
}
|
||||
|
||||
AmrrMacStation::AmrrMacStation (AmrrMacStations *stations)
|
||||
: m_stations (stations),
|
||||
m_nextModeUpdate (Simulator::Now () + stations->m_updatePeriod),
|
||||
m_shortRetry (0),
|
||||
m_longRetry (0),
|
||||
m_tx_ok (0),
|
||||
m_tx_err (0),
|
||||
m_tx_retr (0),
|
||||
m_tx_upper (0)
|
||||
{}
|
||||
AmrrMacStation::~AmrrMacStation ()
|
||||
{}
|
||||
|
||||
void
|
||||
AmrrMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
|
||||
{}
|
||||
void
|
||||
AmrrMacStation::ReportRtsFailed (void)
|
||||
{
|
||||
m_shortRetry++;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::ReportDataFailed (void)
|
||||
{
|
||||
m_longRetry++;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
|
||||
{}
|
||||
void
|
||||
AmrrMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
|
||||
{
|
||||
UpdateRetry ();
|
||||
m_tx_ok++;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::ReportFinalRtsFailed (void)
|
||||
{
|
||||
UpdateRetry ();
|
||||
m_tx_err++;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::ReportFinalDataFailed (void)
|
||||
{
|
||||
UpdateRetry ();
|
||||
m_tx_err++;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::UpdateRetry (void)
|
||||
{
|
||||
m_tx_retr += m_shortRetry + m_longRetry;
|
||||
m_shortRetry = 0;
|
||||
m_longRetry = 0;
|
||||
}
|
||||
void
|
||||
AmrrMacStation::UpdateMode (void)
|
||||
{
|
||||
if (Simulator::Now () < m_nextModeUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AmrrMacStations *
|
||||
AmrrMacStation::GetStations (void) const
|
||||
{
|
||||
return m_stations;
|
||||
}
|
||||
WifiMode
|
||||
AmrrMacStation::DoGetDataMode (uint32_t size)
|
||||
{
|
||||
UpdateMode ();
|
||||
//XXX
|
||||
return GetSupportedMode (0);
|
||||
}
|
||||
WifiMode
|
||||
AmrrMacStation::DoGetRtsMode (void)
|
||||
{
|
||||
UpdateMode ();
|
||||
// XXX: can we implement something smarter ?
|
||||
return GetSupportedMode (0);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
78
src/devices/wifi/amrr-mac-stations.h
Normal file
78
src/devices/wifi/amrr-mac-stations.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2003,2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef AMRR_MAC_STATIONS_H
|
||||
#define AMRR_MAC_STATIONS_H
|
||||
|
||||
#include "mac-stations.h"
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class AmrrMacStations : public MacStations
|
||||
{
|
||||
public:
|
||||
AmrrMacStations (WifiMode defaultTxMode);
|
||||
|
||||
private:
|
||||
friend class AmrrMacStation;
|
||||
virtual MacStation *CreateStation (void);
|
||||
|
||||
Time m_updatePeriod;
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class AmrrMacStation : public MacStation
|
||||
{
|
||||
public:
|
||||
AmrrMacStation (AmrrMacStations *stations);
|
||||
|
||||
virtual ~AmrrMacStation ();
|
||||
|
||||
virtual void ReportRxOk (double rxSnr, WifiMode txMode);
|
||||
virtual void ReportRtsFailed (void);
|
||||
virtual void ReportDataFailed (void);
|
||||
virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
|
||||
virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
|
||||
virtual void ReportFinalRtsFailed (void);
|
||||
virtual void ReportFinalDataFailed (void);
|
||||
|
||||
private:
|
||||
virtual AmrrMacStations *GetStations (void) const;
|
||||
virtual WifiMode DoGetDataMode (uint32_t size);
|
||||
virtual WifiMode DoGetRtsMode (void);
|
||||
|
||||
void UpdateRetry (void);
|
||||
void UpdateMode (void);
|
||||
|
||||
AmrrMacStations *m_stations;
|
||||
Time m_nextModeUpdate;
|
||||
uint32_t m_shortRetry;
|
||||
uint32_t m_longRetry;
|
||||
uint32_t m_tx_ok;
|
||||
uint32_t m_tx_err;
|
||||
uint32_t m_tx_retr;
|
||||
uint32_t m_tx_upper;
|
||||
uint32_t m_txrate;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* AMRR_MAC_STATIONS_H */
|
||||
@@ -65,6 +65,7 @@ static EnumDefaultValue<enum RateControlAlgorithm> g_rateControlAlgorithm
|
||||
AARF, "Aarf",
|
||||
IDEAL, "Ideal",
|
||||
ONOE, "Onoe",
|
||||
AMRR, "Amrr",
|
||||
0, (void *)0);
|
||||
|
||||
static NumericDefaultValue<uint32_t> g_arfSuccessThreshold
|
||||
|
||||
@@ -35,6 +35,7 @@ enum RateControlAlgorithm {
|
||||
ARF,
|
||||
AARF,
|
||||
ONOE,
|
||||
AMRR,
|
||||
IDEAL
|
||||
};
|
||||
enum PhyModeParameter {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "ideal-mac-stations.h"
|
||||
#include "cr-mac-stations.h"
|
||||
#include "onoe-mac-stations.h"
|
||||
#include "amrr-mac-stations.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -215,6 +216,9 @@ WifiNetDevice::Construct (void)
|
||||
case WifiDefaultParameters::ONOE: {
|
||||
m_stations = new OnoeMacStations (m_phy->GetMode (0));
|
||||
} break;
|
||||
case WifiDefaultParameters::AMRR: {
|
||||
m_stations = new AmrrMacStations (m_phy->GetMode (0));
|
||||
} break;
|
||||
default:
|
||||
// NOTREACHED
|
||||
NS_ASSERT (false);
|
||||
|
||||
@@ -35,6 +35,7 @@ def build(bld):
|
||||
'dcf-manager.cc',
|
||||
'dcf-manager-test.cc',
|
||||
'onoe-mac-stations.cc',
|
||||
'amrr-mac-stations.cc',
|
||||
]
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.source = [
|
||||
|
||||
Reference in New Issue
Block a user