src/devices/wifi/aarf-mac-stations.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 03 Oct 2007 15:46:28 +0200
changeset 1905 235a146fc8ed
parent 1895 6c2d6a5631bc
child 1918 fee53ba3f388
permissions -rw-r--r--
add CrMacStations to build

/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2004,2005,2006 INRIA
 * All rights reserved.
 *
 * 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 "aarf-mac-stations.h"

#define Min(a,b) ((a<b)?a:b)
#define Max(a,b) ((a>b)?a:b)

namespace ns3 {

AarfMacStations::AarfMacStations (uint8_t nMode)
  : ArfMacStations (nMode)
{}
AarfMacStations::~AarfMacStations ()
{}
MacStation *
AarfMacStations::CreateStation (void)
{
  return new AarfMacStation (this, 2.0, 60, 2.0);
}




AarfMacStation::AarfMacStation (AarfMacStations *stations,   
                                double successK,
                                int maxSuccessThreshold,
                                double timerK)
  : ArfMacStation (stations, 15, 10),
    m_successK (successK),
    m_maxSuccessThreshold (maxSuccessThreshold),
    m_timerK (timerK)
{}


AarfMacStation::~AarfMacStation ()
{}

void 
AarfMacStation::ReportRecoveryFailure (void)
{
  SetSuccessThreshold ((int)(Min (GetSuccessThreshold () * m_successK,
                                  m_maxSuccessThreshold)));
  SetTimerTimeout ((int)(Max (GetMinTimerTimeout (),
                              GetSuccessThreshold () * m_timerK)));
}

void 
AarfMacStation::ReportFailure (void)
{
  SetTimerTimeout (GetMinTimerTimeout ());
  SetSuccessThreshold (GetMinSuccessThreshold ());
}

}; // namespace ns3