more renamed files
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 03 Mar 2008 05:10:12 +0100
changeset 2546 3fc951966b1b
parent 2545 7a38029a2e5b
child 2547 88a22bc766a1
more renamed files
src/devices/wifi/mac-high-adhoc.cc
src/devices/wifi/mac-high-adhoc.h
src/devices/wifi/mac-high-nqap.cc
src/devices/wifi/mac-high-nqap.h
src/devices/wifi/mac-high-nqsta.cc
src/devices/wifi/mac-high-nqsta.h
--- a/src/devices/wifi/mac-high-adhoc.cc	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- *
- * 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 "mac-high-adhoc.h"
-#include "dca-txop.h"
-#include "wifi-net-device.h"
-#include "mac-stations.h"
-#include "wifi-phy.h"
-#include "ns3/packet.h"
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("MacHighAdhoc");
-
-namespace ns3 {
-
-MacHighAdhoc::MacHighAdhoc ()
-{}
-MacHighAdhoc::~MacHighAdhoc ()
-{
-  m_phy = 0;
-}
-
-void
-MacHighAdhoc::SetDevice (WifiNetDevice *device)
-{
-  m_device = device;
-
-}
-void 
-MacHighAdhoc::SetForwardCallback (ForwardCallback callback)
-{
-  m_callback = callback;
-}
-void
-MacHighAdhoc::SetDcaTxop (Ptr<DcaTxop> dca)
-{
-  m_dca = dca;
-}
-void 
-MacHighAdhoc::SetStations (MacStations *stations)
-{
-  m_stations = stations;
-}
-void 
-MacHighAdhoc::SetPhy (Ptr<WifiPhy> phy)
-{
-  m_phy = phy;
-}
-
-Mac48Address 
-MacHighAdhoc::GetBssid (void) const
-{
-  // XXX the bssid should be generated by the procedure
-  // described in ieee802.11 section 11.1.3
-  return Mac48Address::GetBroadcast ();
-}
-
-void 
-MacHighAdhoc::Enqueue (Ptr<const Packet> packet, Mac48Address to)
-{
-  NS_LOG_DEBUG ("enqueue size="<<packet->GetSize ()<<", to="<<to);
-  WifiMacHeader hdr;
-  hdr.SetType (WIFI_MAC_DATA);
-  hdr.SetAddr1 (to);
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (m_device->GetBssid ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-
-  MacStation *destination = m_stations->Lookup (to);
-  if (destination->IsBrandNew ())
-    {
-      // in adhoc mode, we assume that every destination
-      // supports all the rates we support.
-      for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
-        {
-          destination->AddSupportedMode (m_phy->GetMode (i));
-        }
-      destination->RecordDisassociated ();
-    }
-
-  m_dca->Queue (packet, hdr);
-}
-
-void 
-MacHighAdhoc::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
-{
-  NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 ());
-  if (hdr->GetAddr1 ().IsBroadcast () || hdr->GetAddr1 () == m_device->GetSelfAddress ())
-    {
-      m_callback (packet, hdr->GetAddr2 ());
-    }
-}
-
-} // namespace ns3
--- a/src/devices/wifi/mac-high-adhoc.h	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- *
- * 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>
- */
-#ifndef MAC_HIGH_ADHOC_H
-#define MAC_HIGH_ADHOC_H
-
-#include "ns3/mac48-address.h"
-#include "ns3/callback.h"
-#include "ns3/packet.h"
-
-namespace ns3 {
-
-class DcaTxop;
-class Packet;
-class WifiNetDevice;
-class WifiMacHeader;
-class MacStations;
-class WifiPhy;
-
-/**
- * \brief the Adhoc state machine
- *
- * For now, this class is really empty but it should contain
- * the code for the distributed generation of beacons in an adhoc 
- * network.
- */
-class MacHighAdhoc {
-public:
-  typedef Callback<void, Ptr<Packet>, const Mac48Address &> ForwardCallback;
-
-  MacHighAdhoc ();
-  ~MacHighAdhoc ();
-
-  void SetDevice (WifiNetDevice *device);
-  void SetForwardCallback (ForwardCallback callback);
-  void SetDcaTxop (Ptr<DcaTxop> dca);
-  void SetStations (MacStations *stations);
-  void SetPhy (Ptr<WifiPhy> phy);
-
-  Mac48Address GetBssid (void) const;
-
-  void Enqueue (Ptr<const Packet> packet, Mac48Address to);
-
-  /* invoked by the MacLows. */
-  void Receive (Ptr<Packet> packet, WifiMacHeader const*hdr);
-private:
-  Ptr<DcaTxop> m_dca;
-  WifiNetDevice *m_device;
-  ForwardCallback m_callback;
-  MacStations *m_stations;
-  Ptr<WifiPhy> m_phy;
-};
-
-} // namespace ns3
-
-#endif /* MAC_HIGH_ADHOC_H */
--- a/src/devices/wifi/mac-high-nqap.cc	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,340 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 INRIA
- *
- * 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 "mac-high-nqap.h"
-#include "mac-stations.h"
-#include "dca-txop.h"
-#include "wifi-net-device.h"
-#include "wifi-mac-header.h"
-#include "wifi-default-parameters.h"
-#include "mgt-headers.h"
-#include "wifi-phy.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/node.h"
-
-NS_LOG_COMPONENT_DEFINE ("MacHighNqap");
-
-#define TRACE(x) \
-  NS_LOG_DEBUG(Simulator::Now () << " " << m_phy->GetDevice ()->GetNode ()->GetId () << ":" << \
-               m_phy->GetDevice ()->GetIfIndex () << " " << x);
-
-namespace ns3 {
-
-MacHighNqap::MacHighNqap ()
-  : m_beaconInterval (WifiDefaultParameters::GetApBeaconInterval ())
-{}
-MacHighNqap::~MacHighNqap ()
-{
-  m_phy = 0;
-}
-
-void 
-MacHighNqap::SetDcaTxop (Ptr<DcaTxop> dca)
-{
-  m_dca = dca;
-  m_dca->SetTxOkCallback (MakeCallback (&MacHighNqap::TxOk, this));
-  m_dca->SetTxFailedCallback (MakeCallback (&MacHighNqap::TxFailed, this));
-}
-void 
-MacHighNqap::SetBeaconDcaTxop (Ptr<DcaTxop> dca)
-{
-  // we do not need to be notified when a beacon has been transmitted
-  // successfully or not.
-  m_beaconDca = dca;
-}
-void 
-MacHighNqap::SetDevice (WifiNetDevice *device)
-{
-  m_device = device;
-}
-void 
-MacHighNqap::SetStations (MacStations *stations)
-{
-  m_stations = stations;
-}
-void
-MacHighNqap::SetPhy (Ptr<WifiPhy> phy)
-{
-  m_phy = phy;
-}
-void 
-MacHighNqap::SetForwardCallback (ForwardCallback callback)
-{
-  m_forwardUp = callback;
-}
-void 
-MacHighNqap::SetBeaconInterval (Time interval)
-{
-  m_beaconInterval = interval;
-}
-void
-MacHighNqap::StartBeaconing (void)
-{
-  SendOneBeacon ();
-}
-void 
-MacHighNqap::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
-{
-  WifiMacHeader hdr;
-  hdr.SetTypeData ();
-  hdr.SetAddr1 (to);
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (from);
-  hdr.SetDsFrom ();
-  hdr.SetDsNotTo ();
-  m_dca->Queue (packet, hdr);  
-}
-void 
-MacHighNqap::Queue (Ptr<const Packet> packet, Mac48Address to)
-{
-  ForwardDown (packet, m_device->GetSelfAddress (), to);
-}
-SupportedRates
-MacHighNqap::GetSupportedRates (void) const
-{
-  // send the set of supported rates and make sure that we indicate
-  // the Basic Rate set in this set of supported rates.
-  SupportedRates rates;
-  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
-    {
-      WifiMode mode = m_phy->GetMode (i);
-      rates.AddSupportedRate (mode.GetDataRate ());
-    }
-  // set the basic rates
-  for (uint32_t j = 0; j < m_stations->GetNBasicModes (); j++)
-    {
-      WifiMode mode = m_stations->GetBasicMode (j);
-      rates.SetBasicRate (mode.GetDataRate ());
-    }
-  return rates;
-}
-void
-MacHighNqap::SendProbeResp (Mac48Address to)
-{
-  TRACE ("send probe response to="<<to);
-  WifiMacHeader hdr;
-  hdr.SetProbeResp ();
-  hdr.SetAddr1 (to);
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (m_device->GetSelfAddress ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-  Ptr<Packet> packet = Create<Packet> ();
-  MgtProbeResponseHeader probe;
-  probe.SetSsid (m_device->GetSsid ());
-  probe.SetSupportedRates (GetSupportedRates ());
-  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
-  packet->AddHeader (probe);
-
-  m_dca->Queue (packet, hdr);
-}
-void
-MacHighNqap::SendAssocResp (Mac48Address to, bool success)
-{
-  TRACE ("send assoc response to="<<to);
-  WifiMacHeader hdr;
-  hdr.SetAssocResp ();
-  hdr.SetAddr1 (to);
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (m_device->GetSelfAddress ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-  Ptr<Packet> packet = Create<Packet> ();
-  MgtAssocResponseHeader assoc;
-  StatusCode code;
-  if (success)
-    {
-      code.SetSuccess ();
-    }
-  else
-    {
-      code.SetFailure ();
-    }
-  assoc.SetSupportedRates (GetSupportedRates ());
-  assoc.SetStatusCode (code);
-  packet->AddHeader (assoc);
-  
-  m_dca->Queue (packet, hdr);
-}
-void
-MacHighNqap::SendOneBeacon (void)
-{
-  TRACE ("send beacon to="<<Mac48Address::GetBroadcast ());
-  WifiMacHeader hdr;
-  hdr.SetBeacon ();
-  hdr.SetAddr1 (Mac48Address::GetBroadcast ());
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (m_device->GetSelfAddress ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-  Ptr<Packet> packet = Create<Packet> ();
-  MgtBeaconHeader beacon;
-  beacon.SetSsid (m_device->GetSsid ());
-  beacon.SetSupportedRates (GetSupportedRates ());
-  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
-  packet->AddHeader (beacon);
-
-  m_beaconDca->Queue (packet, hdr);
-  Simulator::Schedule (m_beaconInterval, &MacHighNqap::SendOneBeacon, this);
-}
-void 
-MacHighNqap::TxOk (WifiMacHeader const &hdr)
-{
-  MacStation *station = m_stations->Lookup (hdr.GetAddr1 ());
-  if (hdr.IsAssocResp () && 
-      station->IsWaitAssocTxOk ()) 
-    {
-      TRACE ("associated with sta="<<hdr.GetAddr1 ());
-      station->RecordGotAssocTxOk ();
-    }
-}
-void 
-MacHighNqap::TxFailed (WifiMacHeader const &hdr)
-{
-  MacStation *station = m_stations->Lookup (hdr.GetAddr1 ());
-  if (hdr.IsAssocResp () && 
-      station->IsWaitAssocTxOk ()) 
-    {
-      TRACE ("assoc failed with sta="<<hdr.GetAddr1 ());
-      station->RecordGotAssocTxFailed ();
-    }
-}
-void 
-MacHighNqap::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
-{
-  MacStation *station = m_stations->Lookup (hdr->GetAddr2 ());
-
-  if (hdr->IsData ()) 
-    {
-      if (!hdr->IsFromDs () && 
-          hdr->IsToDs () &&
-          hdr->GetAddr1 () == m_device->GetSelfAddress () &&
-          station->IsAssociated ()) 
-        {
-          if (hdr->GetAddr3 () == m_device->GetSelfAddress ()) 
-            {
-              TRACE ("frame for me from="<<hdr->GetAddr2 ());
-              m_forwardUp (packet, hdr->GetAddr2 ());
-            } 
-          else 
-            {
-              TRACE ("forwarding frame from="<<hdr->GetAddr2 ()<<", to="<<hdr->GetAddr3 ());
-              Ptr<Packet> copy = packet->Copy ();
-              ForwardDown (packet,
-                           hdr->GetAddr2 (), 
-                           hdr->GetAddr3 ());
-              m_forwardUp (copy, hdr->GetAddr2 ());
-            }
-        } 
-      else if (hdr->IsFromDs () &&
-               hdr->IsToDs ()) 
-        {
-          // this is an AP-to-AP frame
-          // we ignore for now.
-        } 
-      else 
-        {
-          // we can ignore these frames since 
-          // they are not targeted at the AP
-        }
-    } 
-  else if (hdr->IsMgt ()) 
-    {
-      if (hdr->IsProbeReq ()) 
-        {
-          NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
-          SendProbeResp (hdr->GetAddr2 ());
-        } 
-      else if (hdr->GetAddr1 () == m_device->GetSelfAddress ()) 
-        {
-          if (hdr->IsAssocReq ()) 
-            {
-              // first, verify that the the station's supported
-              // rate set is compatible with our Basic Rate set
-              MgtAssocRequestHeader assocReq;
-              packet->RemoveHeader (assocReq);
-              SupportedRates rates = assocReq.GetSupportedRates ();
-              bool problem = false;
-              for (uint32_t i = 0; i < m_stations->GetNBasicModes (); i++)
-                {
-                  WifiMode mode = m_stations->GetBasicMode (i);
-                  if (!rates.IsSupportedRate (mode.GetDataRate ()))
-                    {
-                      problem = true;
-                      break;
-                    }
-                }
-              if (problem)
-                {
-                  // one of the Basic Rate set mode is not
-                  // supported by the station. So, we return an assoc
-                  // response with an error status.
-                  SendAssocResp (hdr->GetAddr2 (), false);
-                }
-              else
-                {
-                  // station supports all rates in Basic Rate Set.
-                  // record all its supported modes in its associated MacStation
-                  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
-                    {
-                      WifiMode mode = m_phy->GetMode (j);
-                      if (rates.IsSupportedRate (mode.GetDataRate ()))
-                        {
-                          station->AddSupportedMode (mode);
-                        }
-                    }
-                  station->RecordWaitAssocTxOk ();
-                  // send assoc response with success status.
-                  SendAssocResp (hdr->GetAddr2 (), true);
-                }
-            } 
-          else if (hdr->IsDisassociation ()) 
-            {
-              station->RecordDisassociated ();
-            } 
-          else if (hdr->IsReassocReq ()) 
-            {
-              /* we don't support reassoc frames for now */
-            } 
-          else if (hdr->IsAuthentication () ||
-                   hdr->IsDeauthentication ()) 
-            {
-              /*
-               */
-            } 
-          else 
-            {
-              /* unknown mgt frame
-               */
-            }
-        }
-    } 
-  else 
-    {
-    /* damn, what could this be ? a control frame ?
-     * control frames should never reach the MacHigh so,
-     * this is likely to be a bug. assert.
-     */
-      NS_ASSERT (false);
-    }  
-}
-
-} // namespace ns3
--- a/src/devices/wifi/mac-high-nqap.h	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 INRIA
- *
- * 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>
- */
-#ifndef MAC_HIGH_NQAP_H
-#define MAC_HIGH_NQAP_H
-
-#include <stdint.h>
-#include "ns3/mac48-address.h"
-#include "ns3/callback.h"
-#include "ns3/packet.h"
-#include "ns3/nstime.h"
-#include "supported-rates.h"
-
-namespace ns3 {
-
-class WifiMacHeader;
-class WifiNetDevice;
-class DcaTxop;
-class MacStations;
-class WifiPhy;
-
-/**
- * \brief non-QoS AP state machine
- *
- * Handle association, dis-association and authentication,
- * of STAs within an IBSS.
- * This class uses two output queues, each of which is server by
- * a single DCF
- *   - the highest priority DCF serves the queue which contains
- *     only beacons.
- *   - the lowest priority DCF serves the queue which contains all
- *     other frames, including user data frames.
- */
-class MacHighNqap {
-public:
-  typedef Callback<void, Ptr<Packet>, const Mac48Address &> ForwardCallback;
-
-  MacHighNqap ();
-  ~MacHighNqap ();
-
-  void SetDcaTxop (Ptr<DcaTxop> dca);
-  void SetBeaconDcaTxop (Ptr<DcaTxop> dca);
-  void SetDevice (WifiNetDevice *device);
-  void SetStations (MacStations *stations);
-  void SetPhy (Ptr<WifiPhy> phy);
-  void SetForwardCallback (ForwardCallback callback);
-  void SetBeaconInterval (Time interval);
-
-  void Queue (Ptr<const Packet> packet, Mac48Address to);
-
-  /**
-   * Start beacon transmission immediately.
-   */
-  void StartBeaconing (void);
-
-  void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
-private:
-  void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
-  void TxOk (WifiMacHeader const &hdr);
-  void TxFailed (WifiMacHeader const &hdr);
-  void SendProbeResp (Mac48Address to);
-  void SendAssocResp (Mac48Address to, bool success);
-  void SendOneBeacon (void);
-  SupportedRates GetSupportedRates (void) const;
-
-  Ptr<DcaTxop> m_dca;
-  Ptr<DcaTxop> m_beaconDca;
-  WifiNetDevice *m_device;
-  MacStations *m_stations;
-  Ptr<WifiPhy> m_phy;
-  ForwardCallback m_forwardUp;
-  Time m_beaconInterval;
-};
-
-} // namespace ns3
-
-
-#endif /* MAC_HIGH_NQAP_H */
--- a/src/devices/wifi/mac-high-nqsta.cc	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,414 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 INRIA
- *
- * 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 "ns3/packet.h"
-#include "ns3/simulator.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/node.h"
-
-#include "mac-high-nqsta.h"
-#include "wifi-mac-header.h"
-#include "wifi-net-device.h"
-#include "mgt-headers.h"
-#include "wifi-phy.h"
-#include "dca-txop.h"
-#include "mac-stations.h"
-
-NS_LOG_COMPONENT_DEFINE ("MacHighNqsta");
-
-#define TRACE(x) \
-  NS_LOG_DEBUG (Simulator::Now () << " " << m_phy->GetDevice ()->GetNode ()->GetId () << ":" << \
-                m_phy->GetDevice ()->GetIfIndex () << " " << x);
-
-/*
- * The state machine for this NQSTA is:
- --------------            -----------
- | Associated |   <--------------------      ------->    | Refused |
- --------------      \    /      -----------
-    \           \  /
-     \    -----------------     -----------------------------
-      \-> | Beacon Missed | --> | Wait Association Response |
-    -----------------     -----------------------------
-    \           ^
-     \          |
-      \    -----------------------
-       \-> | Wait Probe Response |
-           -----------------------
- */
-
-
-namespace ns3 {
-
-MacHighNqsta::MacHighNqsta ()
-  : m_state (BEACON_MISSED),
-    m_probeRequestTimeout (Seconds (0.5)),
-    m_assocRequestTimeout (Seconds (0.5)),
-    m_probeRequestEvent (),
-    m_assocRequestEvent (),
-    m_beaconWatchdogEnd (Seconds (0.0))
-{
-  // this is the default value for the number of beacons missed 
-  // before attempting to reassociate.
-  m_maxMissedBeacons = 10;
-}
-
-MacHighNqsta::~MacHighNqsta ()
-{
-  m_phy = 0;
-}
-
-void 
-MacHighNqsta::SetDcaTxop (Ptr<DcaTxop> dca)
-{
-  m_dca = dca;
-}
-void 
-MacHighNqsta::SetDevice (WifiNetDevice *device)
-{
-  m_device = device;
-}
-void 
-MacHighNqsta::SetForwardCallback (ForwardCallback callback)
-{
-  m_forward = callback;
-}
-void 
-MacHighNqsta::SetAssociatedCallback (AssociatedCallback callback)
-{
-  m_associatedCallback = callback;
-}
-void 
-MacHighNqsta::SetDisAssociatedCallback (DisAssociatedCallback callback)
-{
-  m_disAssociatedCallback = callback;
-}
-void 
-MacHighNqsta::SetPhy (Ptr<WifiPhy> phy)
-{
-  m_phy = phy;
-}
-void 
-MacHighNqsta::SetStations (MacStations *stations)
-{
-  m_stations = stations;
-}
-
-void 
-MacHighNqsta::SetMaxMissedBeacons (uint32_t missed)
-{
-  m_maxMissedBeacons = missed;
-}
-void 
-MacHighNqsta::SetProbeRequestTimeout (Time timeout)
-{
-  m_probeRequestTimeout = timeout;
-}
-void 
-MacHighNqsta::SetAssocRequestTimeout (Time timeout)
-{
-  m_assocRequestTimeout = timeout;
-}
-
-Mac48Address 
-MacHighNqsta::GetBssid (void) const
-{
-  return m_bssid;
-}
-void 
-MacHighNqsta::SetBssid (Mac48Address bssid)
-{
-  m_bssid = bssid;
-
-}
-void 
-MacHighNqsta::StartActiveAssociation (void)
-{
-  TryToEnsureAssociated ();
-}
-
-Mac48Address
-MacHighNqsta::GetBroadcastBssid (void)
-{
-  return Mac48Address::GetBroadcast ();
-}
-
-void
-MacHighNqsta::SendProbeRequest (void)
-{
-  TRACE ("send probe request");
-  WifiMacHeader hdr;
-  hdr.SetProbeReq ();
-  hdr.SetAddr1 (GetBroadcastBssid ());
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (GetBroadcastBssid ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-  Ptr<Packet> packet = Create<Packet> ();
-  MgtProbeRequestHeader probe;
-  probe.SetSsid (m_device->GetSsid ());
-  probe.SetSupportedRates (GetSupportedRates ());
-  packet->AddHeader (probe);
-  
-  m_dca->Queue (packet, hdr);
-
-  m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout,
-                                             &MacHighNqsta::ProbeRequestTimeout, this);
-}
-
-void
-MacHighNqsta::SendAssociationRequest (void)
-{
-  TRACE ("send assoc request to=" << GetBssid ());
-  WifiMacHeader hdr;
-  hdr.SetAssocReq ();
-  hdr.SetAddr1 (GetBssid ());
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (GetBssid ());
-  hdr.SetDsNotFrom ();
-  hdr.SetDsNotTo ();
-  Ptr<Packet> packet = Create<Packet> ();
-  MgtAssocRequestHeader assoc;
-  assoc.SetSsid (m_device->GetSsid ());
-  assoc.SetSupportedRates (GetSupportedRates ());
-  packet->AddHeader (assoc);
-  
-  m_dca->Queue (packet, hdr);
-
-  m_assocRequestEvent = Simulator::Schedule (m_assocRequestTimeout,
-                                             &MacHighNqsta::AssocRequestTimeout, this);
-}
-void
-MacHighNqsta::TryToEnsureAssociated (void)
-{
-  switch (m_state) {
-  case ASSOCIATED:
-    return;
-    break;
-  case WAIT_PROBE_RESP:
-    /* we have sent a probe request earlier so we
-       do not need to re-send a probe request immediately.
-       We just need to wait until probe-request-timeout
-       or until we get a probe response
-     */
-    break;
-  case BEACON_MISSED:
-    /* we were associated but we missed a bunch of beacons
-     * so we should assume we are not associated anymore.
-     * We try to initiate a probe request now.
-     */
-    m_disAssociatedCallback ();
-    m_state = WAIT_PROBE_RESP;
-    SendProbeRequest ();
-    break;
-  case WAIT_ASSOC_RESP:
-    /* we have sent an assoc request so we do not need to
-       re-send an assoc request right now. We just need to
-       wait until either assoc-request-timeout or until
-       we get an assoc response.
-     */
-    break;
-  case REFUSED:
-    /* we have sent an assoc request and received a negative
-       assoc resp. We wait until someone restarts an 
-       association with a given ssid.
-     */
-    break;
-  }
-}
-
-void
-MacHighNqsta::AssocRequestTimeout (void)
-{
-  TRACE ("assoc request timeout");
-  m_state = WAIT_ASSOC_RESP;
-  SendAssociationRequest ();
-}
-void
-MacHighNqsta::ProbeRequestTimeout (void)
-{
-  TRACE ("probe request timeout");
-  m_state = WAIT_PROBE_RESP;
-  SendProbeRequest ();
-}
-void 
-MacHighNqsta::MissedBeacons (void)
-{
-  if (m_beaconWatchdogEnd > Simulator::Now ())
-    {
-      m_beaconWatchdog = Simulator::Schedule (m_beaconWatchdogEnd - Simulator::Now (),
-                                              &MacHighNqsta::MissedBeacons, this);
-      return;
-    }
-  TRACE ("beacon missed");
-  m_state = BEACON_MISSED;
-  TryToEnsureAssociated ();
-}
-void 
-MacHighNqsta::RestartBeaconWatchdog (Time delay)
-{
-  m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd);
-  if (Simulator::GetDelayLeft (m_beaconWatchdog) < delay &&
-      m_beaconWatchdog.IsExpired ())
-    {
-      m_beaconWatchdog = Simulator::Schedule (delay, &MacHighNqsta::MissedBeacons, this);
-    }
-}
-bool
-MacHighNqsta::IsAssociated (void)
-{
-  return (m_state == ASSOCIATED)?true:false;
-}
-
-void 
-MacHighNqsta::Queue (Ptr<const Packet> packet, Mac48Address to)
-{
-  if (!IsAssociated ()) 
-    {
-      TryToEnsureAssociated ();
-      return;
-    }
-  //TRACE ("enqueue size="<<packet->GetSize ()<<", to="<<to);
-  WifiMacHeader hdr;
-  hdr.SetTypeData ();
-  hdr.SetAddr1 (GetBssid ());
-  hdr.SetAddr2 (m_device->GetSelfAddress ());
-  hdr.SetAddr3 (to);
-  hdr.SetDsNotFrom ();
-  hdr.SetDsTo ();
-  m_dca->Queue (packet, hdr);
-}
-
-void 
-MacHighNqsta::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
-{
-  NS_ASSERT (!hdr->IsCtl ());
-  if (hdr->GetAddr1 () != m_device->GetSelfAddress () &&
-      !hdr->GetAddr1 ().IsBroadcast ()) 
-    {
-      // packet is not for us
-    } 
-  else if (hdr->IsData ()) 
-    {
-      m_forward (packet, hdr->GetAddr2 ());
-    } 
-  else if (hdr->IsProbeReq () ||
-           hdr->IsAssocReq ()) 
-    {
-      /* this is a frame aimed at an AP.
-       * so we can safely ignore it.
-       */
-    } 
-  else if (hdr->IsBeacon ()) 
-    {
-      MgtBeaconHeader beacon;
-      packet->RemoveHeader (beacon);
-      bool goodBeacon = false;
-      if (m_device->GetSsid ().IsBroadcast () ||
-          beacon.GetSsid ().IsEqual (m_device->GetSsid ()))
-        {
-          Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons);
-          RestartBeaconWatchdog (delay);
-          goodBeacon = true;
-        }
-      if (goodBeacon) 
-        {
-          SetBssid (hdr->GetAddr3 ());
-        }
-      if (goodBeacon && m_state == BEACON_MISSED) 
-        {
-          m_state = WAIT_ASSOC_RESP;
-          SendAssociationRequest ();
-        }
-  } 
-  else if (hdr->IsProbeResp ()) 
-    {
-      if (m_state == WAIT_PROBE_RESP) 
-        {
-          MgtProbeResponseHeader probeResp;
-          packet->RemoveHeader (probeResp);
-          if (!probeResp.GetSsid ().IsEqual (m_device->GetSsid ()))
-            {
-              //not a probe resp for our ssid.
-              return;
-            }
-          SetBssid (hdr->GetAddr3 ());
-          Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons);
-          RestartBeaconWatchdog (delay);
-          if (m_probeRequestEvent.IsRunning ()) 
-            {
-              m_probeRequestEvent.Cancel ();
-            }
-          m_state = WAIT_ASSOC_RESP;
-          SendAssociationRequest ();
-        }
-    } 
-  else if (hdr->IsAssocResp ()) 
-    {
-      if (m_state == WAIT_ASSOC_RESP) 
-        {
-          MgtAssocResponseHeader assocResp;
-          packet->RemoveHeader (assocResp);
-          if (m_assocRequestEvent.IsRunning ()) 
-            {
-              m_assocRequestEvent.Cancel ();
-            }
-          if (assocResp.GetStatusCode ().IsSuccess ()) 
-            {
-              m_state = ASSOCIATED;
-              TRACE ("assoc completed"); 
-              SupportedRates rates = assocResp.GetSupportedRates ();
-              MacStation *ap = m_stations->Lookup (hdr->GetAddr2 ());
-              for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
-                {
-                  WifiMode mode = m_phy->GetMode (i);
-                  if (rates.IsSupportedRate (mode.GetDataRate ()))
-                    {
-                      ap->AddSupportedMode (mode);
-                      if (rates.IsBasicRate (mode.GetDataRate ()))
-                        {
-                          m_stations->AddBasicMode (mode);
-                        }
-                    }
-                }
-              m_associatedCallback ();
-            } 
-          else 
-            {
-              TRACE ("assoc refused");
-              m_state = REFUSED;
-            }
-        }
-    }
-}
-
-SupportedRates
-MacHighNqsta::GetSupportedRates (void) const
-{
-  SupportedRates rates;
-  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
-    {
-      WifiMode mode = m_phy->GetMode (i);
-      rates.AddSupportedRate (mode.GetDataRate ());
-    }
-  return rates;
-}
-
-} // namespace ns3
--- a/src/devices/wifi/mac-high-nqsta.h	Mon Mar 03 04:42:16 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 INRIA
- *
- * 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>
- */
-#ifndef MAC_HIGH_NQSTA_H
-#define MAC_HIGH_NQSTA_H
-
-#include <stdint.h>
-
-#include "ns3/mac48-address.h"
-#include "ns3/callback.h"
-#include "ns3/event-id.h"
-#include "ns3/packet.h"
-#include "ns3/nstime.h"
-
-#include "supported-rates.h"
-
-namespace ns3 {
-
-class WifiMacHeader;
-class WifiNetDevice;
-class DcaTxop;
-class WifiPhy;
-class MacStations;
-
-/**
- * \brief a non-QoS STA state machine
- *
- * This state machine handles association, disassociation,
- * authentication and beacon monitoring. It does not perform
- * channel scanning.
- * If the station detects a certain number of missed beacons
- * while associated, it automatically attempts a new association
- * sequence.
- */
-class MacHighNqsta {
-public:
-  typedef Callback<void, Ptr<Packet>, const Mac48Address &> ForwardCallback;
-  typedef Callback<void> AssociatedCallback;
-  typedef Callback<void> DisAssociatedCallback;
-
-  MacHighNqsta ();
-  ~MacHighNqsta ();
-
-  void SetDcaTxop (Ptr<DcaTxop> dca);
-  void SetDevice (WifiNetDevice *device);
-  void SetForwardCallback (ForwardCallback callback);
-  void SetAssociatedCallback (AssociatedCallback callback);
-  void SetDisAssociatedCallback (DisAssociatedCallback callback);
-  void SetPhy (Ptr<WifiPhy> phy);
-  void SetStations (MacStations *stations);
-
-  /**
-   * \param missed the number of beacons which must be missed
-   * before a new association sequence is started.
-   */
-  void SetMaxMissedBeacons (uint32_t missed);
-  /**
-   * \param timeout
-   *
-   * If no probe response is received within the specified
-   * timeout, the station sends a new probe request.
-   */
-  void SetProbeRequestTimeout (Time timeout);
-  /**
-   * \param timeout
-   *
-   * If no association response is received within the specified
-   * timeout, the station sends a new association request.
-   */
-  void SetAssocRequestTimeout (Time timeout);
-
-  Mac48Address GetBssid (void) const;
-
-  /**
-   * Start an active association sequence immediately.
-   */
-  void StartActiveAssociation (void);
-
-  void Queue (Ptr<const Packet> packet, Mac48Address to);
-
-  void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
-private:
-  void SetBssid (Mac48Address bssid);
-  Mac48Address GetBroadcastBssid (void);
-  void SendProbeRequest (void);
-  void SendAssociationRequest (void);
-  void TryToEnsureAssociated (void);
-  void AssocRequestTimeout (void);
-  void ProbeRequestTimeout (void);
-  bool IsAssociated (void);
-  void MissedBeacons (void);
-  void RestartBeaconWatchdog (Time delay);
-  SupportedRates GetSupportedRates (void) const;
-  enum {
-    ASSOCIATED,
-    WAIT_PROBE_RESP,
-    WAIT_ASSOC_RESP,
-    BEACON_MISSED,
-    REFUSED
-  } m_state;
-  Time m_probeRequestTimeout;
-  Time m_assocRequestTimeout;
-  EventId m_probeRequestEvent;
-  EventId m_assocRequestEvent;
-  WifiNetDevice *m_device;
-  ForwardCallback m_forward;
-  AssociatedCallback m_associatedCallback;
-  DisAssociatedCallback m_disAssociatedCallback;
-  Ptr<DcaTxop> m_dca;
-  EventId m_beaconWatchdog;
-  Time m_beaconWatchdogEnd;
-  Mac48Address m_bssid;
-  uint32_t m_maxMissedBeacons;
-  Ptr<WifiPhy> m_phy;
-  MacStations *m_stations;
-};
-
-} // namespace ns3
-
-
-#endif /* MAC_HIGH_NQSTA_H */