src/wave/helper/wifi-80211p-helper.cc
changeset 10459 f2e90c12a44f
child 11107 647dbdb894d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/wave/helper/wifi-80211p-helper.cc	Tue Dec 03 11:25:59 2013 -0800
@@ -0,0 +1,117 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 INRIA
+ * Copyright (c) 2009 MIRKO BANCHI
+ * Copyright (c) 2013 Dalian University of Technology
+ *
+ * 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>
+ * Author: Mirko Banchi <mk.banchi@gmail.com>
+ * Author: Junling Bu <linlinjavaer@gmail.com>
+ */
+#include "ns3/string.h"
+#include "ns3/log.h"
+#include <typeinfo>
+#include "wave-mac-helper.h"
+#include "wifi-80211p-helper.h"
+
+namespace ns3 {
+
+Wifi80211pHelper::Wifi80211pHelper ()
+{
+}
+
+Wifi80211pHelper::~Wifi80211pHelper ()
+{
+}
+
+Wifi80211pHelper
+Wifi80211pHelper::Default (void)
+{
+  Wifi80211pHelper helper;
+  helper.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
+  helper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
+                                  "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"),
+                                  "ControlMode",StringValue ("OfdmRate6MbpsBW10MHz"));
+  return helper;
+}
+
+void
+Wifi80211pHelper::SetStandard (enum WifiPhyStandard standard)
+{
+  if ((standard == WIFI_PHY_STANDARD_80211a) || (standard == WIFI_PHY_STANDARD_80211_10MHZ))
+    {
+      WifiHelper::SetStandard (standard);
+    }
+  else
+    {
+      NS_FATAL_ERROR ("802.11p only use 802.11 standard with 10MHz or 20MHz");
+    }
+}
+
+
+void
+Wifi80211pHelper::EnableLogComponents (void)
+{
+  WifiHelper::EnableLogComponents ();
+
+  LogComponentEnable ("OcbWifiMac", LOG_LEVEL_ALL);
+  LogComponentEnable ("VendorSpecificAction", LOG_LEVEL_ALL);
+}
+
+NetDeviceContainer
+Wifi80211pHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const
+{
+  bool isWaveMacHelper = false;
+  try
+    {
+      const QosWaveMacHelper& qosMac = dynamic_cast<const QosWaveMacHelper&> (macHelper);
+      isWaveMacHelper = true;
+      // below check will never fail, just used for survive from
+      // gcc warn "-Wunused-but-set-variable"
+      if (&qosMac == 0)
+        {
+          NS_FATAL_ERROR ("it could never get here");
+        }
+    }
+  catch (const std::bad_cast &)
+    {
+
+    }
+
+  try
+    {
+      const NqosWaveMacHelper& nqosMac = dynamic_cast<const NqosWaveMacHelper&> (macHelper);
+      isWaveMacHelper = true;
+      if (&nqosMac == 0)
+        {
+          NS_FATAL_ERROR ("it could never get here");
+        }
+    }
+  catch (const std::bad_cast &)
+    {
+
+    }
+
+  if (!isWaveMacHelper)
+    {
+      NS_FATAL_ERROR ("the macHelper should be either QosWaveMacHelper or NqosWaveMacHelper"
+                      ", or should be the subclass of QosWaveMacHelper or NqosWaveMacHelper");
+    }
+
+  return WifiHelper::Install (phyHelper, macHelper, c);
+}
+
+} // namespace ns3