A Discrete-Event Network Simulator
API
mesh-wifi-interface-mac.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Kirill Andreev <andreev@iitp.ru>
19  * Pavel Boyko <boyko@iitp.ru>
20  */
21 
22 #ifndef MESH_WIFI_INTERFACE_MAC_H
23 #define MESH_WIFI_INTERFACE_MAC_H
24 
25 #include <stdint.h>
26 #include <map>
27 #include "ns3/mac48-address.h"
28 #include "ns3/mgt-headers.h"
29 #include "ns3/callback.h"
30 #include "ns3/packet.h"
31 #include "ns3/nstime.h"
32 #include "ns3/wifi-remote-station-manager.h"
33 #include "ns3/regular-wifi-mac.h"
34 #include "ns3/mesh-wifi-interface-mac-plugin.h"
35 #include "ns3/event-id.h"
36 #include "qos-utils.h"
37 
38 namespace ns3 {
39 
40 class WifiMacHeader;
41 class DcaTxop;
42 class UniformRandomVariable;
55 {
56 public:
61  static TypeId GetTypeId ();
65  virtual ~MeshWifiInterfaceMac ();
66 
67  // Inherited from WifiMac
68  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
69  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);
70  virtual bool SupportsSendFrom () const;
71  virtual void SetLinkUpCallback (Callback<void> linkUp);
73  // \{
76  // \}
78  // \{
80  void SetRandomStartDelay (Time interval);
82  void SetBeaconInterval (Time interval);
84  Time GetBeaconInterval () const;
91  Time GetTbtt () const;
100  void ShiftTbtt (Time shift);
101  // \}
102 
111 
112  /*
113  * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz),
114  * where Starting channel frequency is standard-dependent as defined in IEEE 802.11-2007 17.3.8.3.2.
115  *
116  * Number of channels to use must be limited elsewhere.
117  */
118 
123  uint16_t GetFrequencyChannel () const;
129  void SwitchFrequencyChannel (uint16_t new_id);
130 
144  bool CheckSupportedRates (SupportedRates rates) const;
148  // \{
150  uint32_t GetLinkMetric (Mac48Address peerAddress);
151  // \}
153  void Report (std::ostream &) const;
155  void ResetStats ();
161  void SetBeaconGeneration (bool enable);
173  virtual void FinishConfigureStandard (enum WifiPhyStandard standard);
182  int64_t AssignStreams (int64_t stream);
183 private:
190  void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
198  void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
200  void SendBeacon ();
202  void ScheduleNextBeacon ();
208  bool GetBeaconGeneration () const;
210  virtual void DoDispose ();
211 
212 private:
213  typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin> > PluginList;
214 
215  virtual void DoInitialize ();
216 
218  // \{
227  // \}
228 
231 
235  PluginList m_plugins;
237  struct Statistics
239  {
240  uint16_t recvBeacons;
241  uint32_t sentFrames;
242  uint32_t sentBytes;
243  uint32_t recvFrames;
244  uint32_t recvBytes;
245 
250  void Print (std::ostream & os) const;
252  Statistics ();
253  };
255 
258 
261 };
262 
263 } // namespace ns3
264 
265 #endif /* MESH_WIFI_INTERFACE_MAC_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
bool m_beaconEnable
whether beaconing is enabled
SupportedRates GetSupportedRates() const
WifiPhyStandard GetPhyStandard() const
Get phy standard in use.
bool CheckSupportedRates(SupportedRates rates) const
Check supported rates.
virtual void DoDispose()
Real d-tor.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > cb)
std::vector< Ptr< MeshWifiInterfaceMacPlugin > > PluginList
PluginList typedef.
void SwitchFrequencyChannel(uint16_t new_id)
Switch frequency channel.
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
WifiPhyStandard m_standard
Current PHY standard: needed to configure metric.
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to, Mac48Address from)
Time GetTbtt() const
Next beacon frame time.
void ResetStats()
Reset statistics.
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
void ScheduleNextBeacon()
Schedule next beacon.
virtual void DoInitialize()
Initialize() implementation.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
base class for all MAC-level wifi objects.
uint16_t GetFrequencyChannel() const
Current channel Id.
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)
Finish configuration based on the WifiPhyStandard being provided.
bool GetBeaconGeneration() const
Get current beaconing status.
uint32_t GetLinkMetric(Mac48Address peerAddress)
PluginList m_plugins
List of all installed plugins.
Mac48Address GetMeshPointAddress() const
virtual bool SupportsSendFrom() const
Mac48Address m_mpAddress
Mesh point address.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_beaconInterval
Beaconing interval.
an EUI-48 address
Definition: mac48-address.h:43
void Receive(Ptr< Packet > packet, WifiMacHeader const *hdr)
Frame receive handler.
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
virtual void SetLinkUpCallback(Callback< void > linkUp)
Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > m_linkMetricCallback
linkMetricCallback
void ForwardDown(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
An identifier for simulation events.
Definition: event-id.h:53
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin.
void Report(std::ostream &) const
Statistics:
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
EventId m_beaconSendEvent
"Timer" for the next beacon
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
void Print(std::ostream &os) const
Print statistics.
Time m_tbtt
Time for the next frame.
void ShiftTbtt(Time shift)
Shift TBTT.
a unique identifier for an interface.
Definition: type-id.h:58
Basic MAC of mesh point Wi-Fi interface.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Implements the IEEE 802.11 MAC header.