src/devices/mesh/dot11s/peer-management-protocol-mac.h
changeset 5086 fccfd0073ea3
parent 5038 0b8f9da17a56
child 5129 5688b8da4526
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/dot11s/peer-management-protocol-mac.h	Thu Jun 18 18:07:22 2009 +0400
@@ -0,0 +1,131 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* 
+ * Copyright (c) 2009 IITP RAS
+ * 
+ * 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: Kirill Andreev <andreev@iitp.ru>
+ */
+
+#ifndef PEER_MANAGER_MAC_PLUGIN_H_
+#define PEER_MANAGER_MAC_PLUGIN_H_
+
+#include "ns3/mesh-wifi-interface-mac-plugin.h"
+
+namespace ns3 {
+class MeshWifiInterfaceMac;
+namespace dot11s {
+class PeerManagementProtocol;
+class IeConfiguration;
+class IePeerManagement;
+class PeerManagementProtocol;
+/**
+ * \ingroup dot11s
+ * 
+ * \brief This is plugin to Mesh WiFi MAC, which implements
+ * interface to dot11s peer management protocol: it takes proper
+ * frames from MAC-layer, extracts peer link management information
+ * element and mesh configuration element and passes it to main part
+ * of protocol
+ */
+class PeerManagementProtocolMac : public MeshWifiInterfaceMacPlugin
+{
+public:
+  PeerManagementProtocolMac (uint32_t interface, Ptr<PeerManagementProtocol> protocol);
+  ~PeerManagementProtocolMac ();
+  ///\name Inherited from plugin abstract class
+  ///\{
+  void SetParent (Ptr<MeshWifiInterfaceMac> parent);
+  bool Receive (Ptr<Packet> packet, const WifiMacHeader & header);
+  bool UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to);
+  void UpdateBeacon (MeshWifiBeacon & beacon) const;
+  ///\}
+  ///\name Statistics:
+  ///\{
+  void Report (std::ostream &) const;
+  void ResetStats ();
+  uint32_t GetLinkMetric (Mac48Address peerAddress);
+  ///\}
+private:
+  friend class PeerManagementProtocol;
+  friend class PeerLink; 
+  ///\name BCA functionallity:
+  ///\{
+  ///\brief Fills TBTT and beacon interval. Needed by BCA
+  ///functionallity
+  ///\param first in retval is TBTT
+  ///\param second in retval is beacon interval
+  std::pair<Time, Time> GetBeaconInfo() const;
+  void SetBeaconShift(Time shift);
+  ///\}
+  void SetPeerManagerProtcol(Ptr<PeerManagementProtocol> protocol);
+  void SendPeerLinkManagementFrame(
+      Mac48Address peerAddress,
+      Mac48Address peerMpAddress,
+      uint16_t aid,
+      IePeerManagement peerElement,
+      IeConfiguration meshConfig
+      );
+  ///\brief DUBUG only - to print established links
+  Mac48Address GetAddress () const;
+private:
+  ///\name Information about MAC and protocol:
+  ///\{
+  Ptr<MeshWifiInterfaceMac> m_parent;
+  uint32_t m_ifIndex;
+  Ptr<PeerManagementProtocol> m_protocol;
+   ///\}
+   ///\name Create peer link management frames:
+   ///\{
+  Ptr<Packet> CreatePeerLinkOpenFrame();
+  Ptr<Packet> CreatePeerLinkConfirmFrame();
+  Ptr<Packet> CreatePeerLinkCloseFrame();
+  ///This structure keeps all fields in peer link management frame,
+  ///which are not subclasses of WifiInformationElement
+  struct PlinkFrameStart {
+    uint8_t subtype;
+    uint16_t aid;
+    SupportedRates rates;
+    uint16_t qos;
+  };
+  /// \name Parses the start of the frame, where there are no
+  /// WifiInformationElements exist
+  PlinkFrameStart ParsePlinkFrame(Ptr<const Packet> packet);
+  ///\}
+  //Keeps statistics
+  struct Statistics {
+    uint16_t txOpen;
+    uint16_t txConfirm;
+    uint16_t txClose;
+    uint16_t rxOpen;
+    uint16_t rxConfirm;
+    uint16_t rxClose;
+    uint16_t dropped;
+    uint16_t brokenMgt;
+    uint16_t txMgt;
+    uint32_t txMgtBytes;
+    uint16_t rxMgt;
+    uint32_t rxMgtBytes;
+    uint16_t beaconShift;
+    
+    Statistics ();
+    void Print (std::ostream & os) const;
+  };
+  struct Statistics m_stats;
+};
+  
+} // namespace dot11s
+} //namespace ns3
+#endif
+