1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  * Copyright (c) 2013 Dalian University of Technology
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation;
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21  * Author: Mirko Banchi <mk.banchi@gmail.com>
22  * Author: Junling Bu <linlinjavaer@gmail.com>
23  */
24 #include "ns3/string.h"
25 #include "ns3/log.h"
26 #include <typeinfo>
27 #include "wave-mac-helper.h"
28 #include "wifi-80211p-helper.h"
29 #include "ns3/unused.h"
30 
31 namespace ns3 {
32 
Wifi80211pHelper()33 Wifi80211pHelper::Wifi80211pHelper ()
34 {
35 }
36 
~Wifi80211pHelper()37 Wifi80211pHelper::~Wifi80211pHelper ()
38 {
39 }
40 
41 Wifi80211pHelper
Default(void)42 Wifi80211pHelper::Default (void)
43 {
44   Wifi80211pHelper helper;
45   helper.SetStandard (WIFI_STANDARD_80211p);
46   helper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
47                                   "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"),
48                                   "ControlMode",StringValue ("OfdmRate6MbpsBW10MHz"),
49                                   "NonUnicastMode", StringValue ("OfdmRate6MbpsBW10MHz"));
50   return helper;
51 }
52 
53 void
SetStandard(enum WifiStandard standard)54 Wifi80211pHelper::SetStandard (enum WifiStandard standard)
55 {
56   if (standard == WIFI_STANDARD_80211p)
57     {
58       WifiHelper::SetStandard (standard);
59     }
60   else
61     {
62       NS_FATAL_ERROR ("wrong standard selected!");
63     }
64 }
65 
66 void
EnableLogComponents(void)67 Wifi80211pHelper::EnableLogComponents (void)
68 {
69   WifiHelper::EnableLogComponents ();
70 
71   LogComponentEnable ("OcbWifiMac", LOG_LEVEL_ALL);
72   LogComponentEnable ("VendorSpecificAction", LOG_LEVEL_ALL);
73 }
74 
75 NetDeviceContainer
Install(const WifiPhyHelper & phyHelper,const WifiMacHelper & macHelper,NodeContainer c) const76 Wifi80211pHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const
77 {
78   QosWaveMacHelper const * qosMac = dynamic_cast <QosWaveMacHelper const *> (&macHelper);
79   if (qosMac == 0)
80     {
81       NqosWaveMacHelper const * nqosMac = dynamic_cast <NqosWaveMacHelper const *> (&macHelper);
82       if (nqosMac == 0)
83         {
84           NS_FATAL_ERROR ("the macHelper should be either QosWaveMacHelper or NqosWaveMacHelper"
85                           ", or should be the subclass of QosWaveMacHelper or NqosWaveMacHelper");
86         }
87       NS_UNUSED (nqosMac);
88     }
89 
90   NS_UNUSED (qosMac);
91   return WifiHelper::Install (phyHelper, macHelper, c);
92 }
93 
94 } // namespace ns3
95