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 // Update beacon is empty, because HWMP does not know anything about beacons
54 void UpdateBeacon(MeshWifiBeacon& beacon) const override{};
55 int64_t AssignStreams(int64_t stream) override;
56
57 private:
58 /// allow HwmpProtocol class friend access
59 friend class HwmpProtocol;
60 /**
61 * \returns a path selection action header
62 */
64 /// \name Interaction with HWMP:
65 ///@{
66 /**
67 * Send PREQ function
68 * \param preq the PREQ
69 */
70 void SendPreq(IePreq preq);
71 /**
72 * Send PREQ function for vector of PREQ
73 * \param preq vector of PREQ information elements
74 */
75 void SendPreqVector(std::vector<IePreq> preq);
76 /**
77 * Send PREP function
78 * \param prep the PREP information element
79 * \param receiver the MAC address of the receiver
80 */
81 void SendPrep(IePrep prep, Mac48Address receiver);
82 /**
83 * Forward a path error
84 * \param destinations vector of failed destinations
85 * \param receivers vector of receivers
86 */
87 void ForwardPerr(std::vector<HwmpProtocol::FailedDestination> destinations,
88 std::vector<Mac48Address> receivers);
89 /**
90 * initiate my own path error
91 * \param destinations vector of failed destinations
92 * \param receivers vector of receivers
93 */
94 void InitiatePerr(std::vector<HwmpProtocol::FailedDestination> destinations,
95 std::vector<Mac48Address> receivers);
96 /**
97 * Request a destination. If cannot send PREQ immediately, add a
98 * destination to existing PREQ generated by me and stored in PREQ queue
99 * \param dest is the destination to be resolved
100 * \param originator_seqno is a sequence number that shall be preq originator sequenece number
101 * \param dst_seqno is a sequence number taken from routing table
102 */
103 void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno);
104 ///@}
105
106 /// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe
107 /// queue)
108 void SendMyPreq();
109 /// Send PERR function
110 void SendMyPerr();
111 /**
112 * \param peerAddress peer address
113 * \return metric to HWMP protocol, needed only by metrics to add peer as routing entry
114 */
115 uint32_t GetLinkMetric(Mac48Address peerAddress) const;
116 /**
117 * Get the channel ID
118 * \returns the channel ID
119 */
120 uint16_t GetChannelId() const;
121 /**
122 * Report statistics
123 * \param os The output stream on which to report
124 */
125 void Report(std::ostream& os) const;
126 /// Reset statistics
127 void ResetStats();
128
129 private:
131 uint32_t m_ifIndex; ///< IF index
133
134 /// \name my PREQ and PREQ timer:
135 ///@{
136 EventId m_preqTimer; //!< Timer for PREQs
137 std::vector<IePreq> m_myPreq; //!< container of PREQs
138 ///@}
139
140 /// \name PERR timer and stored path error
141 ///@{
143
144 /// MyPerr structure
145 struct MyPerr
146 {
147 std::vector<HwmpProtocol::FailedDestination> destinations; ///< destinations
148 std::vector<Mac48Address> receivers; ///< receivers
149 };
150
151 MyPerr m_myPerr; ///< PERR
152
153 ///@}
154
155 /// \name Statistics
156 ///@{
157
158 /**
159 * Statistics structure
160 */
162 {
163 uint16_t txPreq; ///< transmit PREQ
164 uint16_t rxPreq; ///< receive PREQ
165 uint16_t txPrep; ///< transmit PREP
166 uint16_t rxPrep; ///< receive PREP
167 uint16_t txPerr; ///< transmit PERR
168 uint16_t rxPerr; ///< receive PERR
169 uint16_t txMgt; ///< transmit management
170 uint32_t txMgtBytes; ///< transmit management bytes
171 uint16_t rxMgt; ///< receive management
172 uint32_t rxMgtBytes; ///< receive management bytes
173 uint16_t txData; ///< transmit data
174 uint32_t txDataBytes; ///< transmit data bytes
175 uint16_t rxData; ///< receive data
176 uint32_t rxDataBytes; ///< receive data bytes
177 /**
178 * Print function
179 * \param os the output stream
180 */
181 void Print(std::ostream& os) const;
182 Statistics();
183 };
184
185 Statistics m_stats; ///< statistics
186 ///@}
187
188 private:
189 /**
190 * Receive data frame
191 *
192 * \param packet
193 * \param header
194 * \returns true if a packet was received
195 */
196 bool ReceiveData(Ptr<Packet> packet, const WifiMacHeader& header);
197 /**
198 * Receive action management frame
199 *
200 * \param packet
201 * \param header
202 * \returns true if a packet was received
203 */
204 bool ReceiveAction(Ptr<Packet> packet, const WifiMacHeader& header);
205};
206} // namespace dot11s
207} // namespace ns3
208#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