MeshWifiBeacon class created
authorPavel Boyko <boyko@iitp.ru>
Tue, 17 Mar 2009 17:33:49 +0300
changeset 4822 55868bb52909
parent 4821 f0e58dcc7588
child 4823 7c2d9ff2d4ab
MeshWifiBeacon class created
src/devices/mesh/mesh-wifi-beacon.cc
src/devices/mesh/mesh-wifi-beacon.h
src/devices/mesh/wifi-information-element.cc
src/devices/mesh/wifi-information-element.h
src/devices/mesh/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/mesh-wifi-beacon.cc	Tue Mar 17 17:33:49 2009 +0300
@@ -0,0 +1,56 @@
+/* -*- 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: Pavel Boyko <boyko@iitp.ru>
+ */
+
+#include "ns3/mesh-wifi-beacon.h"
+#include <algorithm>
+
+namespace ns3 {
+  
+MeshWifiBeacon::MeshWifiBeacon(Ssid ssid, SupportedRates rates, uint64_t us)
+{
+  m_header.SetSsid (ssid);
+  m_header.SetSupportedRates (rates);
+  m_header.SetBeaconIntervalUs (us);
+}
+
+void MeshWifiBeacon::AddInformationElement(const WifiInformationElement * ie)
+{
+  m_elements.push_back(ie);
+}
+
+Ptr<Packet> MeshWifiBeacon::CreatePacket()
+{
+  Ptr<Packet> packet = Create<Packet> ();
+  
+  std::sort(m_elements.begin(), m_elements.end());
+  
+  std::vector<const WifiInformationElement *>::const_reverse_iterator i;
+  for(i = m_elements.rbegin(); i != m_elements.rend(); ++i)
+  {
+    packet->AddHeader(**i);
+  }
+  
+  packet->AddHeader(Header());
+  
+  return packet;
+}
+  
+} // namespace 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/mesh/mesh-wifi-beacon.h	Tue Mar 17 17:33:49 2009 +0300
@@ -0,0 +1,68 @@
+/* -*- 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: Pavel Boyko <boyko@iitp.ru>
+ */
+
+#ifndef MESHWIFIBEACON_H_
+#define MESHWIFIBEACON_H_
+
+#include "ns3/object.h"
+#include "ns3/packet.h"
+#include "ns3/wifi-information-element.h"
+#include "ns3/mgt-headers.h"        // from wifi module
+#include "ns3/ssid.h"
+
+#include <vector>
+
+namespace ns3 {
+
+/**
+ * \brief Beacon is beacon header + list of arbitrary information elements
+ * 
+ * It is supposed that distinct mesh protocols can use beacons to transport
+ * their own information elements.
+ */
+class MeshWifiBeacon
+{
+public:
+  /** 
+   * C-tor
+   * 
+   * \param ssid is SSID for beacon header
+   * \param rates is a set of supported rates
+   * \param us beacon interval in microseconds
+   */
+  MeshWifiBeacon(Ssid ssid, SupportedRates rates, uint64_t us);
+  /// Read standard Wifi beacon header
+  MgtBeaconHeader Header () const { return m_header; }
+  /// Add information element
+  void AddInformationElement (const WifiInformationElement * ie);
+  /// Create frame = { header + all information elements sorted by ElementId() }
+  Ptr<Packet> CreatePacket (); 
+  
+private:
+  /// Beacon header
+  MgtBeaconHeader m_header;
+  /// List of information elements added 
+  std::vector<const WifiInformationElement *> m_elements;
+};
+
+}
+
+
+#endif /* MESHWIFIBEACON_H_ */
--- a/src/devices/mesh/wifi-information-element.cc	Tue Mar 17 16:17:44 2009 +0300
+++ b/src/devices/mesh/wifi-information-element.cc	Tue Mar 17 17:33:49 2009 +0300
@@ -57,6 +57,12 @@
   PrintInformation(os);
   os << "</information_element>\n";
 }
+
+bool operator<(WifiInformationElement const & a, WifiInformationElement const & b)
+{
+  return (a.ElementId() < b.ElementId());
+}
+
   
 }
 
--- a/src/devices/mesh/wifi-information-element.h	Tue Mar 17 16:17:44 2009 +0300
+++ b/src/devices/mesh/wifi-information-element.h	Tue Mar 17 17:33:49 2009 +0300
@@ -141,7 +141,13 @@
   /// Print information
   virtual void PrintInformation (std::ostream &os) const = 0;
   //\}
+  
+  /// Compare information elements using Element ID
+  friend bool operator<(WifiInformationElement const & a, WifiInformationElement const & b);
 };
 
+/// Compare information elements using Element ID
+bool operator<(WifiInformationElement const & a, WifiInformationElement const & b);
+ 
 }  // namespace ns3
 #endif /* WIFIINFORMATIONELEMENT_H_ */
--- a/src/devices/mesh/wscript	Tue Mar 17 16:17:44 2009 +0300
+++ b/src/devices/mesh/wscript	Tue Mar 17 17:33:49 2009 +0300
@@ -7,6 +7,7 @@
         'mesh-point-device.cc',
         'mesh-l2-routing-protocol.cc',
         'wifi-information-element.cc',
+        'mesh-wifi-beacon.cc',
         # Not refactored
         'mesh-wifi-helper.cc',
         'mesh-wifi-mac-header.cc',
@@ -33,6 +34,7 @@
         'mesh-point-device.h',
         'mesh-l2-routing-protocol.h',
         'wifi-information-element.h',
+        'mesh-wifi-beacon.h',
         # Dirty
         'dot11s-codes.h',
         'mesh-wifi-rann-information-element.h',