A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wave-mac-low.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  * Copyright (c) 2013 Dalian University of Technology
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Junling Bu <linlinjavaer@gmail.com>
21  */
22 #include "ns3/log.h"
23 #include "wave-mac-low.h"
24 #include "higher-tx-tag.h"
25 
26 NS_LOG_COMPONENT_DEFINE ("WaveMacLow");
27 
28 namespace ns3 {
29 
30 NS_OBJECT_ENSURE_REGISTERED (WaveMacLow);
31 
32 TypeId
34 {
35  static TypeId tid = TypeId ("ns3::WaveMacLow")
36  .SetParent<MacLow> ()
37  .AddConstructor<WaveMacLow> ()
38  ;
39  return tid;
40 }
42 {
43  NS_LOG_FUNCTION (this);
44 }
46 {
47  NS_LOG_FUNCTION (this);
48 }
49 
52 {
53  NS_LOG_FUNCTION (this << packet << *hdr);
54  HigherDataTxVectorTag datatag;
55  bool found;
56  found = ConstCast<Packet> (packet)->PeekPacketTag (datatag);
57  if (!found)
58  {
59  return MacLow::GetDataTxVector (packet, hdr);
60  }
61 
62  if (!datatag.IsAdapter ())
63  {
64  return datatag.GetDataTxVector ();
65  }
66 
67  WifiTxVector txHigher = datatag.GetDataTxVector ();
68  WifiTxVector txMac = MacLow::GetDataTxVector (packet, hdr);
69  WifiTxVector txAdapter;
70  // if adapter is true, DataRate set by higher layer is the minimum data rate
71  // that sets the lower bound for the actual data rate.
72  if (txHigher.GetMode ().GetDataRate () > txMac.GetMode ().GetDataRate ())
73  {
74  txAdapter.SetMode (txHigher.GetMode ());
75  }
76  else
77  {
78  txAdapter.SetMode (txMac.GetMode ());
79  }
80 
81  // if adapter is true, TxPwr_Level set by higher layer is the maximum
82  // transmit power that sets the upper bound for the actual transmit power;
83  txAdapter.SetTxPowerLevel (std::min (txHigher.GetTxPowerLevel (), txMac.GetTxPowerLevel ()));
84  return txAdapter;
85 }
86 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
static TypeId GetTypeId(void)
Definition: wave-mac-low.cc:33
uint8_t GetTxPowerLevel(void) const
This tag will be used to support higher layer control data rate and tx power level.
Definition: higher-tx-tag.h:35
WifiTxVector GetDataTxVector(void) const
virtual WifiTxVector GetDataTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the DATA frame given the destination.
Definition: wave-mac-low.cc:51
virtual ~WaveMacLow(void)
Definition: wave-mac-low.cc:45
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
virtual WifiTxVector GetDataTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Return a TXVECTOR for the DATA frame given the destination.
Definition: mac-low.cc:1026
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:411
NS_LOG_COMPONENT_DEFINE("WaveMacLow")
WifiMode GetMode(void) const
a unique identifier for an interface.
Definition: type-id.h:49
uint64_t GetDataRate(void) const
Definition: wifi-mode.cc:79
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
bool IsAdapter(void) const
Implements the IEEE 802.11 MAC header.