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-mac.h"
33#include "ns3/mesh-wifi-interface-mac-plugin.h"
34#include "ns3/event-id.h"
35
36namespace ns3 {
37
38class UniformRandomVariable;
51{
52public:
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 virtual bool CanForwardPacketsTo (Mac48Address to) const;
69
72
83
86
90 void SetRandomStartDelay (Time interval);
95 void SetBeaconInterval (Time interval);
97 Time GetBeaconInterval () const;
104 Time GetTbtt () const;
113 void ShiftTbtt (Time shift);
115
124
125 /*
126 * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz),
127 * where Starting channel frequency is standard-dependent as defined in IEEE 802.11-2007 17.3.8.3.2.
128 *
129 * Number of channels to use must be limited elsewhere.
130 */
131
136 uint16_t GetFrequencyChannel () const;
142 void SwitchFrequencyChannel (uint16_t new_id);
143
150 void SendManagementFrame (Ptr<Packet> frame, const WifiMacHeader& hdr);
157 bool CheckSupportedRates (SupportedRates rates) const;
160
163
173 uint32_t GetLinkMetric (Mac48Address peerAddress);
175
180 void Report (std::ostream & os) const;
182 void ResetStats ();
183
189 void SetBeaconGeneration (bool enable);
195 virtual void ConfigureStandard (enum WifiStandard standard);
203 virtual void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax);
204
213 int64_t AssignStreams (int64_t stream);
214private:
220 void Receive (Ptr<WifiMacQueueItem> mpdu);
228 void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
230 void SendBeacon ();
232 void ScheduleNextBeacon ();
238 bool GetBeaconGeneration () const;
240 virtual void DoDispose ();
241
242private:
243 typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin> > PluginList;
244
245 virtual void DoInitialize ();
246
258
261
269 {
270 uint16_t recvBeacons;
280 void Print (std::ostream & os) const;
282 Statistics ();
283 };
285
288
291};
292
293} // namespace ns3
294
295#endif /* MESH_WIFI_INTERFACE_MAC_H */
An identifier for simulation events.
Definition: event-id.h:54
an EUI-48 address
Definition: mac48-address.h:44
Basic MAC of mesh point Wi-Fi interface.
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
bool CheckSupportedRates(SupportedRates rates) const
Check supported rates.
Time m_beaconInterval
Beaconing interval.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > cb)
Set the link metric callback.
Mac48Address m_mpAddress
Mesh point address.
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
virtual void SetLinkUpCallback(Callback< void > linkUp)
void SwitchFrequencyChannel(uint16_t new_id)
Switch frequency channel.
void ShiftTbtt(Time shift)
Shift TBTT.
Time GetTbtt() const
Next beacon frame time.
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
void ResetStats()
Reset statistics function.
void Receive(Ptr< WifiMacQueueItem > mpdu)
Frame receive handler.
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > m_linkMetricCallback
linkMetricCallback
EventId m_beaconSendEvent
"Timer" for the next beacon
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin.
WifiStandard m_standard
Current standard: needed to configure metric.
void ScheduleNextBeacon()
Schedule next beacon.
virtual bool CanForwardPacketsTo(Mac48Address to) const
Return true if packets can be forwarded to the given destination, false otherwise.
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
uint16_t GetFrequencyChannel() const
Current channel Id.
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
bool GetBeaconGeneration() const
Get current beaconing status.
virtual void ConfigureStandard(enum WifiStandard standard)
Finish configuration based on the WifiStandard being provided.
void SetMeshPointAddress(Mac48Address addr)
Set the mesh point address.
Mac48Address GetMeshPointAddress() const
Get the mesh point address.
void Report(std::ostream &os) const
Report statistics.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual bool SupportsSendFrom() const
bool m_beaconEnable
Beaconing interval.
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
PluginList m_plugins
List of all installed plugins.
virtual void DoDispose()
Real d-tor.
SupportedRates GetSupportedRates() const
std::vector< Ptr< MeshWifiInterfaceMacPlugin > > PluginList
PluginList typedef.
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Time m_tbtt
Time for the next frame.
virtual void DoInitialize()
Initialize() implementation.
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Implements the IEEE 802.11 MAC header.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:85
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Print(std::ostream &os) const
Print statistics.