A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mesh-wifi-interface-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Kirill Andreev <andreev@iitp.ru>
18 * Pavel Boyko <boyko@iitp.ru>
19 */
20
21#ifndef MESH_WIFI_INTERFACE_MAC_H
22#define MESH_WIFI_INTERFACE_MAC_H
23
24#include "ns3/callback.h"
25#include "ns3/event-id.h"
26#include "ns3/mac48-address.h"
27#include "ns3/mesh-wifi-interface-mac-plugin.h"
28#include "ns3/mgt-headers.h"
29#include "ns3/nstime.h"
30#include "ns3/packet.h"
31#include "ns3/wifi-mac.h"
32
33#include <map>
34#include <stdint.h>
35
36namespace ns3
37{
38
39class UniformRandomVariable;
40
54{
55 public:
60 static TypeId GetTypeId();
64 ~MeshWifiInterfaceMac() override;
65
66 // Inherited from WifiMac
67 void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
68 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
69 bool SupportsSendFrom() const override;
70 void SetLinkUpCallback(Callback<void> linkUp) override;
71 bool CanForwardPacketsTo(Mac48Address to) const override;
72
75
86
89
93 void SetRandomStartDelay(Time interval);
98 void SetBeaconInterval(Time interval);
103 Time GetBeaconInterval() const;
111 Time GetTbtt() const;
121 void ShiftTbtt(Time shift);
123
132
133 /*
134 * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz),
135 * where Starting channel frequency is standard-dependent as defined in IEEE
136 * 802.11-2007 17.3.8.3.2.
137 *
138 * Number of channels to use must be limited elsewhere.
139 */
140
145 uint16_t GetFrequencyChannel() const;
151 void SwitchFrequencyChannel(uint16_t new_id);
152
159 void SendManagementFrame(Ptr<Packet> frame, const WifiMacHeader& hdr);
166 bool CheckSupportedRates(AllSupportedRates rates) const;
167
173
176
188
193 void Report(std::ostream& os) const;
194
198 void ResetStats();
199
205 void SetBeaconGeneration(bool enable);
211 void ConfigureStandard(WifiStandard standard) override;
219 void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax) override;
220
229 int64_t AssignStreams(int64_t stream);
230
231 private:
238 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
246 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to);
250 void SendBeacon();
254 void ScheduleNextBeacon();
260 bool GetBeaconGeneration() const;
264 void DoDispose() override;
265
266 private:
267 typedef std::vector<Ptr<MeshWifiInterfaceMacPlugin>> PluginList;
268
269 void DoInitialize() override;
270
282
285
292
295 {
296 uint16_t recvBeacons;
306 void Print(std::ostream& os) const;
310 Statistics();
311 };
312
314
317
320};
321
322} // namespace ns3
323
324#endif /* MESH_WIFI_INTERFACE_MAC_H */
Callback template class.
Definition: callback.h:438
An identifier for simulation events.
Definition: event-id.h:55
an EUI-48 address
Definition: mac48-address.h:46
Basic MAC of mesh point Wi-Fi interface.
bool SupportsSendFrom() const override
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
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.
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.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void ResetStats()
Reset statistics function.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax) override
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
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.
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
uint16_t GetFrequencyChannel() const
Current channel Id.
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
void DoInitialize() override
Initialize() implementation.
bool GetBeaconGeneration() const
Get current beaconing status.
AllSupportedRates GetSupportedRates() const
Get supported rates.
void SetMeshPointAddress(Mac48Address addr)
Set the mesh point address.
void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from) override
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.
Time GetBeaconInterval() const
Get beacon interval.
bool m_beaconEnable
Beaconing interval.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
Frame receive handler.
void SetLinkUpCallback(Callback< void > linkUp) override
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
PluginList m_plugins
List of all installed plugins.
void ConfigureStandard(WifiStandard standard) override
Finish configuration based on the WifiStandard being provided.
bool CheckSupportedRates(AllSupportedRates rates) const
Check supported rates.
std::vector< Ptr< MeshWifiInterfaceMacPlugin > > PluginList
PluginList typedef.
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Time m_tbtt
Time for the next frame.
void DoDispose() override
Real d-tor.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
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:94
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.
Struct containing all supported rates.
void Print(std::ostream &os) const
Print statistics.