src/devices/wifi/cr-mac-stations.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 03 Oct 2007 15:46:28 +0200
changeset 1905 235a146fc8ed
child 1906 c0901f40bd7e
permissions -rw-r--r--
add CrMacStations to build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1905
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2004,2005 INRIA
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * In addition, as a special exception, the copyright holders of
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 * this module give you permission to Combine (via static or
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
 * dynamic linking) this module with free software programs or
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
 * libraries that are released under the GNU LGPL and with code
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
 * included in the standard release of ns-2 under the Apache 2.0
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
 * license or under otherwise-compatible licenses with advertising
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
 * Requirements (or modified versions of such code, with unchanged
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
 * license).  You may copy and distribute such a system following the
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
 * terms of the GNU GPL for this module and the licenses of the
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
 * other code concerned, provided that you include the source code of
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
 * that other code when and as the GNU GPL requires distribution of
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
 * source code.
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
 * Note that people who make modified versions of this module
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
 * are not obligated to grant this special exception for their
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
 * modified versions; it is their choice whether to do so.  The GNU
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
 * General Public License gives permission to release a modified
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
 * version without this exception; this exception also makes it
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
 * possible to release a modified version which carries forward this
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
 * exception.
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
 *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
 */
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
#include "mac-stations.h"
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
#include "mac-station.h"
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
#include "cr-mac-stations.h"
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
#include <cassert>
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
namespace ns3 {
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
CrMacStation::CrMacStation (CrMacStations *stations)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
  : m_stations (stations)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
CrMacStation::~CrMacStation ()
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
void 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
CrMacStation::ReportRtsFailed (void)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
void 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
CrMacStation::ReportDataFailed (void)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
void 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
CrMacStation::ReportRxOk (double SNR, uint8_t mode)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
void CrMacStation::ReportRtsOk (double ctsSNR, uint8_t ctsMode, uint8_t rtsSnr)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  assert (rtsSnr == 0);
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
void CrMacStation::ReportDataOk (double ackSNR, uint8_t ackMode, uint8_t dataSnr)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  assert (dataSnr == 0);
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
uint8_t
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
CrMacStation::GetDataMode (int size)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  return m_stations->GetDataMode ();
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
uint8_t
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
CrMacStation::GetRtsMode (void)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
  return m_stations->GetCtlMode ();
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
uint8_t 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
CrMacStation::SnrToSnr (double snr)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  return 0;
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
CrMacStations::CrMacStations (uint8_t dataMode, uint8_t ctlMode)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  : MacStations (),
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
    m_dataMode (dataMode),
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
    m_ctlMode (ctlMode)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
CrMacStations::~CrMacStations ()
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
{}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
uint8_t 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
CrMacStations::GetDataMode (void) const
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
  return m_dataMode;
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
uint8_t 
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
CrMacStations::GetCtlMode (void) const
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
  return m_ctlMode;
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
MacStation *
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
CrMacStations::CreateStation (void)
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
{
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
  return new CrMacStation (this);
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
}
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
235a146fc8ed add CrMacStations to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
}; // namespace ns3