A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mesh-wifi-interface-mac.h
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:
58  static TypeId GetTypeId ();
62  virtual ~MeshWifiInterfaceMac ();
63 
65  // \{
66  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
67  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);
68  virtual bool SupportsSendFrom () const;
69  virtual void SetLinkUpCallback (Callback<void> linkUp);
70  // \}
72  // \{
73  void SetMeshPointAddress (Mac48Address);
74  Mac48Address GetMeshPointAddress () const;
75  // \}
77  // \{
79  void SetRandomStartDelay (Time interval);
81  void SetBeaconInterval (Time interval);
83  Time GetBeaconInterval () const;
89  Time GetTbtt () const;
97  void ShiftTbtt (Time shift);
98  // \}
99 
101  // \{
104  // \}
105 
113  // \{
115  uint16_t GetFrequencyChannel () const;
117  void SwitchFrequencyChannel (uint16_t new_id);
118  // \}
119 
121  void SendManagementFrame (Ptr<Packet> frame, const WifiMacHeader& hdr);
123  bool CheckSupportedRates (SupportedRates rates) const;
127  // \{
128  void SetLinkMetricCallback (Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > cb);
129  uint32_t GetLinkMetric (Mac48Address peerAddress);
130  // \}
132  void Report (std::ostream &) const;
133  void ResetStats ();
135  void SetBeaconGeneration (bool enable);
136  WifiPhyStandard GetPhyStandard () const;
137  virtual void FinishConfigureStandard (enum WifiPhyStandard standard);
146  int64_t AssignStreams (int64_t stream);
147 private:
149  void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
151  void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
153  void SendBeacon ();
155  void ScheduleNextBeacon ();
157  bool GetBeaconGeneration () const;
159  virtual void DoDispose ();
160 
161 private:
162  typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin> > PluginList;
163 
164  virtual void DoInitialize ();
165 
167  // \{
176  // \}
177 
180 
184  PluginList m_plugins;
187  // \{
188  struct Statistics
189  {
190  uint16_t recvBeacons;
191  uint32_t sentFrames;
192  uint32_t sentBytes;
193  uint32_t recvFrames;
194  uint32_t recvBytes;
195  void
196  Print (std::ostream & os) const;
197  Statistics ();
198  };
199  Statistics m_stats;
200  // \}
203 
206 };
207 
208 } // namespace ns3
209 
210 #endif /* MESH_WIFI_INTERFACE_MAC_H */
keep track of time unit.
Definition: nstime.h:149
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
bool m_beaconEnable
whether beaconing is enabled
SupportedRates GetSupportedRates() const
bool CheckSupportedRates(SupportedRates rates) const
virtual void DoDispose()
Real d-tor.
void SwitchFrequencyChannel(uint16_t new_id)
Switch 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 SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
void ScheduleNextBeacon()
Schedule next beacon.
base class for all MAC-level wifi objects.This class encapsulates all the low-level MAC functionality...
uint16_t GetFrequencyChannel() const
Current channel Id.
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)
bool GetBeaconGeneration() const
Get current beaconing status.
PluginList m_plugins
List of all installed plugins.
Mac48Address m_mpAddress
Mesh point address.
Time m_beaconInterval
Beaconing interval.
an EUI-48 address
Definition: mac48-address.h:41
void Receive(Ptr< Packet > packet, WifiMacHeader const *hdr)
Frame receive handler.
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Never forget to support typeid.
virtual void SetLinkUpCallback(Callback< void > linkUp)
void ForwardDown(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Send frame. Frame is supposed to be tagged by routing information. TODO: clarify this point...
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
an identifier for simulation events.
Definition: event-id.h:46
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin. TODO return unique ID to allow unregister plugins.
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.
Time m_tbtt
Time for the next frame.
void ShiftTbtt(Time shift)
Shift TBTT.
a unique identifier for an interface.
Definition: type-id.h:44
Basic MAC of mesh point Wi-Fi interface. Its function is extendable through plugins mechanism...
int64_t AssignStreams(int64_t stream)