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/regular-wifi-mac.h"
33 #include "ns3/mesh-wifi-interface-mac-plugin.h"
34 #include "ns3/event-id.h"
35 
36 namespace ns3 {
37 
38 class UniformRandomVariable;
51 {
52 public:
57  static TypeId GetTypeId ();
61  virtual ~MeshWifiInterfaceMac ();
62 
63  // Inherited from WifiMac
64  virtual void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from);
65  virtual void Enqueue (Ptr<Packet> packet, Mac48Address to);
66  virtual bool SupportsSendFrom () const;
67  virtual void SetLinkUpCallback (Callback<void> linkUp);
68 
71 
82 
85 
89  void SetRandomStartDelay (Time interval);
94  void SetBeaconInterval (Time interval);
96  Time GetBeaconInterval () const;
103  Time GetTbtt () const;
112  void ShiftTbtt (Time shift);
114 
123 
124  /*
125  * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz),
126  * where Starting channel frequency is standard-dependent as defined in IEEE 802.11-2007 17.3.8.3.2.
127  *
128  * Number of channels to use must be limited elsewhere.
129  */
130 
135  uint16_t GetFrequencyChannel () const;
141  void SwitchFrequencyChannel (uint16_t new_id);
142 
149  void SendManagementFrame (Ptr<Packet> frame, const WifiMacHeader& hdr);
156  bool CheckSupportedRates (SupportedRates rates) const;
159 
162 
172  uint32_t GetLinkMetric (Mac48Address peerAddress);
174 
179  void Report (std::ostream & os) const;
181  void ResetStats ();
182 
188  void SetBeaconGeneration (bool enable);
194  virtual void ConfigureStandard (enum WifiStandard standard);
203  int64_t AssignStreams (int64_t stream);
204 private:
210  void Receive (Ptr<WifiMacQueueItem> mpdu);
218  void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
220  void SendBeacon ();
222  void ScheduleNextBeacon ();
228  bool GetBeaconGeneration () const;
230  virtual void DoDispose ();
231 
232 private:
233  typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin> > PluginList;
234 
235  virtual void DoInitialize ();
236 
248 
251 
257  struct Statistics
259  {
260  uint16_t recvBeacons;
261  uint32_t sentFrames;
262  uint32_t sentBytes;
263  uint32_t recvFrames;
264  uint32_t recvBytes;
265 
270  void Print (std::ostream & os) const;
272  Statistics ();
273  };
275 
278 
281 };
282 
283 } // namespace ns3
284 
285 #endif /* MESH_WIFI_INTERFACE_MAC_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::MeshWifiInterfaceMac::SetLinkUpCallback
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: mesh-wifi-interface-mac.cc:109
ns3::MeshWifiInterfaceMac::SetLinkMetricCallback
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > cb)
Set the link metric callback.
Definition: mesh-wifi-interface-mac.cc:490
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3::Callback< void >
ns3::MeshWifiInterfaceMac::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: mesh-wifi-interface-mac.cc:44
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MeshWifiInterfaceMac::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: mesh-wifi-interface-mac.cc:149
ns3::MeshWifiInterfaceMac::GetSupportedRates
SupportedRates GetSupportedRates() const
Definition: mesh-wifi-interface-mac.cc:301
ns3::MeshWifiInterfaceMac::Statistics
Statistics:
Definition: mesh-wifi-interface-mac.h:259
ns3::MeshWifiInterfaceMac::ConfigureStandard
virtual void ConfigureStandard(enum WifiStandard standard)
Finish configuration based on the WifiStandard being provided.
Definition: mesh-wifi-interface-mac.cc:541
ns3::MeshWifiInterfaceMac::SendManagementFrame
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
Definition: mesh-wifi-interface-mac.cc:265
ns3::MeshWifiInterfaceMac::SendBeacon
void SendBeacon()
Send beacon.
Definition: mesh-wifi-interface-mac.cc:389
ns3::MeshWifiInterfaceMac::SetBeaconInterval
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
Definition: mesh-wifi-interface-mac.cc:344
ns3::MeshWifiInterfaceMac::m_standard
WifiStandard m_standard
Current standard: needed to configure metric.
Definition: mesh-wifi-interface-mac.h:277
ns3::MeshWifiInterfaceMac::PluginList
std::vector< Ptr< MeshWifiInterfaceMacPlugin > > PluginList
PluginList typedef.
Definition: mesh-wifi-interface-mac.h:233
ns3::MeshWifiInterfaceMac::GetMeshPointAddress
Mac48Address GetMeshPointAddress() const
Get the mesh point address.
Definition: mesh-wifi-interface-mac.cc:500
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::MeshWifiInterfaceMac::Statistics::sentFrames
uint32_t sentFrames
sent frames
Definition: mesh-wifi-interface-mac.h:261
ns3::RegularWifiMac
base class for all MAC-level wifi objects.
Definition: regular-wifi-mac.h:51
ns3::MeshWifiInterfaceMac::m_beaconInterval
Time m_beaconInterval
Beaconing interval.
Definition: mesh-wifi-interface-mac.h:242
ns3::MeshWifiInterfaceMac::SupportsSendFrom
virtual bool SupportsSendFrom() const
Definition: mesh-wifi-interface-mac.cc:104
ns3::MeshWifiInterfaceMac::m_linkMetricCallback
Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > m_linkMetricCallback
linkMetricCallback
Definition: mesh-wifi-interface-mac.h:256
ns3::MeshWifiInterfaceMac::m_stats
Statistics m_stats
statistics
Definition: mesh-wifi-interface-mac.h:274
ns3::MeshWifiInterfaceMac::ResetStats
void ResetStats()
Reset statistics function.
Definition: mesh-wifi-interface-mac.cc:535
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::SupportedRates
The Supported Rates Information Element.
Definition: supported-rates.h:96
ns3::Ptr< Packet >
ns3::MeshWifiInterfaceMac::GetBeaconInterval
Time GetBeaconInterval() const
Definition: mesh-wifi-interface-mac.cc:350
ns3::MeshWifiInterfaceMac::Statistics::recvBeacons
uint16_t recvBeacons
receive beacons
Definition: mesh-wifi-interface-mac.h:260
ns3::MeshWifiInterfaceMac::Statistics::Print
void Print(std::ostream &os) const
Print statistics.
Definition: mesh-wifi-interface-mac.cc:514
ns3::MeshWifiInterfaceMac::~MeshWifiInterfaceMac
virtual ~MeshWifiInterfaceMac()
D-tor.
Definition: mesh-wifi-interface-mac.cc:84
ns3::MeshWifiInterfaceMac::Statistics::recvFrames
uint32_t recvFrames
receive frames
Definition: mesh-wifi-interface-mac.h:263
ns3::MeshWifiInterfaceMac::Statistics::sentBytes
uint32_t sentBytes
sent bytes
Definition: mesh-wifi-interface-mac.h:262
ns3::MeshWifiInterfaceMac::MeshWifiInterfaceMac
MeshWifiInterfaceMac()
C-tor.
Definition: mesh-wifi-interface-mac.cc:75
ns3::MeshWifiInterfaceMac::DoDispose
virtual void DoDispose()
Real d-tor.
Definition: mesh-wifi-interface-mac.cc:120
ns3::MeshWifiInterfaceMac::Statistics::recvBytes
uint32_t recvBytes
receive bytes
Definition: mesh-wifi-interface-mac.h:264
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::MeshWifiInterfaceMac::GetFrequencyChannel
uint16_t GetFrequencyChannel() const
Current channel Id.
Definition: mesh-wifi-interface-mac.cc:176
ns3::MeshWifiInterfaceMac::DoInitialize
virtual void DoInitialize()
Initialize() implementation.
Definition: mesh-wifi-interface-mac.cc:129
ns3::MeshWifiInterfaceMac::Statistics::Statistics
Statistics()
constructor
Definition: mesh-wifi-interface-mac.cc:505
ns3::MeshWifiInterfaceMac::SetBeaconGeneration
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
Definition: mesh-wifi-interface-mac.cc:355
ns3::MeshWifiInterfaceMac::m_randomStart
Time m_randomStart
Maximum delay before first beacon.
Definition: mesh-wifi-interface-mac.h:244
ns3::MeshWifiInterfaceMac::m_beaconSendEvent
EventId m_beaconSendEvent
"Timer" for the next beacon
Definition: mesh-wifi-interface-mac.h:253
ns3::MeshWifiInterfaceMac::SwitchFrequencyChannel
void SwitchFrequencyChannel(uint16_t new_id)
Switch frequency channel.
Definition: mesh-wifi-interface-mac.cc:184
ns3::MeshWifiInterfaceMac::ShiftTbtt
void ShiftTbtt(Time shift)
Shift TBTT.
Definition: mesh-wifi-interface-mac.cc:371
ns3::MeshWifiInterfaceMac::m_beaconEnable
bool m_beaconEnable
Beaconing interval.
Definition: mesh-wifi-interface-mac.h:240
ns3::MeshWifiInterfaceMac::GetLinkMetric
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
Definition: mesh-wifi-interface-mac.cc:480
ns3::MeshWifiInterfaceMac::m_coefficient
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Definition: mesh-wifi-interface-mac.h:280
ns3::MeshWifiInterfaceMac::ScheduleNextBeacon
void ScheduleNextBeacon()
Schedule next beacon.
Definition: mesh-wifi-interface-mac.cc:383
ns3::MeshWifiInterfaceMac::m_tbtt
Time m_tbtt
Time for the next frame.
Definition: mesh-wifi-interface-mac.h:246
ns3::MeshWifiInterfaceMac::InstallPlugin
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin.
Definition: mesh-wifi-interface-mac.cc:165
ns3::MeshWifiInterfaceMac::ForwardDown
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
Definition: mesh-wifi-interface-mac.cc:207
ns3::MeshWifiInterfaceMac::SetMeshPointAddress
void SetMeshPointAddress(Mac48Address addr)
Set the mesh point address.
Definition: mesh-wifi-interface-mac.cc:495
ns3::WifiStandard
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
Definition: wifi-standards.h:126
ns3::MeshWifiInterfaceMac::Receive
void Receive(Ptr< WifiMacQueueItem > mpdu)
Frame receive handler.
Definition: mesh-wifi-interface-mac.cc:409
ns3::MeshWifiInterfaceMac::SetRandomStartDelay
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
Definition: mesh-wifi-interface-mac.cc:338
ns3::MeshWifiInterfaceMac::Report
void Report(std::ostream &os) const
Report statistics.
Definition: mesh-wifi-interface-mac.cc:525
ns3::MeshWifiInterfaceMac::Enqueue
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
Definition: mesh-wifi-interface-mac.cc:92
ns3::MeshWifiInterfaceMac::GetTbtt
Time GetTbtt() const
Next beacon frame time.
Definition: mesh-wifi-interface-mac.cc:366
ns3::MeshWifiInterfaceMac::m_mpAddress
Mac48Address m_mpAddress
Mesh point address.
Definition: mesh-wifi-interface-mac.h:250
ns3::MeshWifiInterfaceMac::CheckSupportedRates
bool CheckSupportedRates(SupportedRates rates) const
Check supported rates.
Definition: mesh-wifi-interface-mac.cc:321
ns3::MeshWifiInterfaceMac::GetBeaconGeneration
bool GetBeaconGeneration() const
Get current beaconing status.
Definition: mesh-wifi-interface-mac.cc:361
ns3::MeshWifiInterfaceMac
Basic MAC of mesh point Wi-Fi interface.
Definition: mesh-wifi-interface-mac.h:51
ns3::MeshWifiInterfaceMac::m_plugins
PluginList m_plugins
List of all installed plugins.
Definition: mesh-wifi-interface-mac.h:255