A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
hwmp-protocol-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#ifndef HWMP_STATE_H
10#define HWMP_STATE_H
11
12#include "hwmp-protocol.h"
13
14#include "ns3/mesh-wifi-interface-mac-plugin.h"
15
16namespace ns3
17{
18
19class MeshWifiInterfaceMac;
20class WifiActionHeader;
21
22namespace dot11s
23{
24
25class IePreq;
26class IePrep;
27class IePerr;
28
29/**
30 * @ingroup dot11s
31 *
32 * @brief Interface MAC plugin for HWMP -- 802.11s routing protocol
33 */
35{
36 public:
37 /**
38 * Constructor
39 *
40 * @param ifIndex interface index
41 * @param protocol pointer to HWMP protocol instance
42 */
44 ~HwmpProtocolMac() override;
45
46 // Inherited from MAC plugin
47 void SetParent(Ptr<MeshWifiInterfaceMac> parent) override;
48 bool Receive(Ptr<Packet> packet, const WifiMacHeader& header) override;
50 WifiMacHeader& header,
51 Mac48Address from,
52 Mac48Address to) override;
53
54 // Update beacon is empty, because HWMP does not know anything about beacons
55 void UpdateBeacon(MeshWifiBeacon& beacon) const override
56 {
57 }
58
59 int64_t AssignStreams(int64_t stream) override;
60
61 private:
62 /// allow HwmpProtocol class friend access
63 friend class HwmpProtocol;
64 /**
65 * @returns a path selection action header
66 */
68 /// @name Interaction with HWMP:
69 ///@{
70 /**
71 * Send PREQ function
72 * @param preq the PREQ
73 */
74 void SendPreq(IePreq preq);
75 /**
76 * Send PREQ function for vector of PREQ
77 * @param preq vector of PREQ information elements
78 */
79 void SendPreqVector(std::vector<IePreq> preq);
80 /**
81 * Send PREP function
82 * @param prep the PREP information element
83 * @param receiver the MAC address of the receiver
84 */
85 void SendPrep(IePrep prep, Mac48Address receiver);
86 /**
87 * Forward a path error
88 * @param destinations vector of failed destinations
89 * @param receivers vector of receivers
90 */
91 void ForwardPerr(std::vector<HwmpProtocol::FailedDestination> destinations,
92 std::vector<Mac48Address> receivers);
93 /**
94 * initiate my own path error
95 * @param destinations vector of failed destinations
96 * @param receivers vector of receivers
97 */
98 void InitiatePerr(std::vector<HwmpProtocol::FailedDestination> destinations,
99 std::vector<Mac48Address> receivers);
100 /**
101 * Request a destination. If cannot send PREQ immediately, add a
102 * destination to existing PREQ generated by me and stored in PREQ queue
103 * @param dest is the destination to be resolved
104 * @param originator_seqno is a sequence number that shall be preq originator sequenece number
105 * @param dst_seqno is a sequence number taken from routing table
106 */
107 void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno);
108 ///@}
109
110 /// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe
111 /// queue)
112 void SendMyPreq();
113 /// Send PERR function
114 void SendMyPerr();
115 /**
116 * @param peerAddress peer address
117 * @return metric to HWMP protocol, needed only by metrics to add peer as routing entry
118 */
119 uint32_t GetLinkMetric(Mac48Address peerAddress) const;
120 /**
121 * Get the channel ID
122 * @returns the channel ID
123 */
124 uint16_t GetChannelId() const;
125 /**
126 * Report statistics
127 * @param os The output stream on which to report
128 */
129 void Report(std::ostream& os) const;
130 /// Reset statistics
131 void ResetStats();
132
133 private:
135 uint32_t m_ifIndex; ///< IF index
137
138 /// @name my PREQ and PREQ timer:
139 ///@{
140 EventId m_preqTimer; //!< Timer for PREQs
141 std::vector<IePreq> m_myPreq; //!< container of PREQs
142 ///@}
143
144 /// @name PERR timer and stored path error
145 ///@{
147
148 /// MyPerr structure
149 struct MyPerr
150 {
151 std::vector<HwmpProtocol::FailedDestination> destinations; ///< destinations
152 std::vector<Mac48Address> receivers; ///< receivers
153 };
154
155 MyPerr m_myPerr; ///< PERR
156
157 ///@}
158
159 /// @name Statistics
160 ///@{
161
162 /**
163 * Statistics structure
164 */
166 {
167 uint16_t txPreq; ///< transmit PREQ
168 uint16_t rxPreq; ///< receive PREQ
169 uint16_t txPrep; ///< transmit PREP
170 uint16_t rxPrep; ///< receive PREP
171 uint16_t txPerr; ///< transmit PERR
172 uint16_t rxPerr; ///< receive PERR
173 uint16_t txMgt; ///< transmit management
174 uint32_t txMgtBytes; ///< transmit management bytes
175 uint16_t rxMgt; ///< receive management
176 uint32_t rxMgtBytes; ///< receive management bytes
177 uint16_t txData; ///< transmit data
178 uint32_t txDataBytes; ///< transmit data bytes
179 uint16_t rxData; ///< receive data
180 uint32_t rxDataBytes; ///< receive data bytes
181 /**
182 * Print function
183 * @param os the output stream
184 */
185 void Print(std::ostream& os) const;
186 Statistics();
187 };
188
189 Statistics m_stats; ///< statistics
190 ///@}
191
192 private:
193 /**
194 * Receive data frame
195 *
196 * @param packet
197 * @param header
198 * @returns true if a packet was received
199 */
200 bool ReceiveData(Ptr<Packet> packet, const WifiMacHeader& header);
201 /**
202 * Receive action management frame
203 *
204 * @param packet
205 * @param header
206 * @returns true if a packet was received
207 */
208 bool ReceiveAction(Ptr<Packet> packet, const WifiMacHeader& header);
209};
210} // namespace dot11s
211} // namespace ns3
212#endif
An identifier for simulation events.
Definition event-id.h:45
an EUI-48 address
Beacon is beacon header + list of arbitrary information elements.
Common interface for mesh point interface MAC plugins.
Smart pointer class similar to boost::intrusive_ptr.
See IEEE 802.11 chapter 7.3.1.11 Header format: | category: 1 | action value: 1 |.
Implements the IEEE 802.11 MAC header.
Hybrid wireless mesh protocol – a mesh routing protocol defined in IEEE 802.11-2012 standard.
Interface MAC plugin for HWMP – 802.11s routing protocol.
static WifiActionHeader GetWifiActionHeader()
void SendMyPreq()
Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)
void SendPreq(IePreq preq)
Send PREQ function.
HwmpProtocolMac(uint32_t ifIndex, Ptr< HwmpProtocol > protocol)
Constructor.
void SetParent(Ptr< MeshWifiInterfaceMac > parent) override
Each plugin must be installed on an interface to work.
void SendPreqVector(std::vector< IePreq > preq)
Send PREQ function for vector of PREQ.
void SendPrep(IePrep prep, Mac48Address receiver)
Send PREP function.
void SendMyPerr()
Send PERR function.
uint16_t GetChannelId() const
Get the channel ID.
void UpdateBeacon(MeshWifiBeacon &beacon) const override
Update beacon before it will be formed and sent.
bool Receive(Ptr< Packet > packet, const WifiMacHeader &header) override
Process received frame.
void ForwardPerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
Forward a path error.
Ptr< HwmpProtocol > m_protocol
protocol
bool ReceiveData(Ptr< Packet > packet, const WifiMacHeader &header)
Receive data frame.
EventId m_preqTimer
Timer for PREQs.
void ResetStats()
Reset statistics.
uint32_t GetLinkMetric(Mac48Address peerAddress) const
bool ReceiveAction(Ptr< Packet > packet, const WifiMacHeader &header)
Receive action management frame.
void InitiatePerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
initiate my own path error
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
std::vector< IePreq > m_myPreq
container of PREQs
void Report(std::ostream &os) const
Report statistics.
bool UpdateOutcomingFrame(Ptr< Packet > packet, WifiMacHeader &header, Mac48Address from, Mac48Address to) override
Update frame before it will be forwarded down.
Ptr< MeshWifiInterfaceMac > m_parent
parent
void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno)
Request a destination.
See 7.3.2.97 of 802.11s draft 2.07.
See 7.3.2.96 of 802.11s draft 2.07.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< HwmpProtocol::FailedDestination > destinations
destinations
std::vector< Mac48Address > receivers
receivers
uint32_t txMgtBytes
transmit management bytes
void Print(std::ostream &os) const
Print function.
uint32_t rxMgtBytes
receive management bytes