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 * 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 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#ifndef HWMP_STATE_H
21#define HWMP_STATE_H
22
23#include "hwmp-protocol.h"
24
25#include "ns3/mesh-wifi-interface-mac-plugin.h"
26
27namespace ns3
28{
29
30class MeshWifiInterfaceMac;
31class WifiActionHeader;
32
33namespace dot11s
34{
35
36class IePreq;
37class IePrep;
38class IePerr;
39
40/**
41 * \ingroup dot11s
42 *
43 * \brief Interface MAC plugin for HWMP -- 802.11s routing protocol
44 */
46{
47 public:
48 /**
49 * Constructor
50 *
51 * \param ifIndex interface index
52 * \param protocol pointer to HWMP protocol instance
53 */
55 ~HwmpProtocolMac() override;
56
57 // Inherited from MAC plugin
58 void SetParent(Ptr<MeshWifiInterfaceMac> parent) override;
59 bool Receive(Ptr<Packet> packet, const WifiMacHeader& header) override;
61 WifiMacHeader& header,
62 Mac48Address from,
63 Mac48Address to) override;
64 // Update beacon is empty, because HWMP does not know anything about beacons
65 void UpdateBeacon(MeshWifiBeacon& beacon) const override{};
66 int64_t AssignStreams(int64_t stream) override;
67
68 private:
69 /// allow HwmpProtocol class friend access
70 friend class HwmpProtocol;
71 /**
72 * \returns a path selection action header
73 */
75 /// \name Interaction with HWMP:
76 ///@{
77 /**
78 * Send PREQ function
79 * \param preq the PREQ
80 */
81 void SendPreq(IePreq preq);
82 /**
83 * Send PREQ function for vector of PREQ
84 * \param preq vector of PREQ information elements
85 */
86 void SendPreqVector(std::vector<IePreq> preq);
87 /**
88 * Send PREP function
89 * \param prep the PREP information element
90 * \param receiver the MAC address of the receiver
91 */
92 void SendPrep(IePrep prep, Mac48Address receiver);
93 /**
94 * Forward a path error
95 * \param destinations vector of failed destinations
96 * \param receivers vector of receivers
97 */
98 void ForwardPerr(std::vector<HwmpProtocol::FailedDestination> destinations,
99 std::vector<Mac48Address> receivers);
100 /**
101 * initiate my own path error
102 * \param destinations vector of failed destinations
103 * \param receivers vector of receivers
104 */
105 void InitiatePerr(std::vector<HwmpProtocol::FailedDestination> destinations,
106 std::vector<Mac48Address> receivers);
107 /**
108 * Request a destination. If cannot send PREQ immediately, add a
109 * destination to existing PREQ generated by me and stored in PREQ queue
110 * \param dest is the destination to be resolved
111 * \param originator_seqno is a sequence number that shall be preq originator sequenece number
112 * \param dst_seqno is a sequence number taken from routing table
113 */
114 void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno);
115 ///@}
116
117 /// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe
118 /// queue)
119 void SendMyPreq();
120 /// Send PERR function
121 void SendMyPerr();
122 /**
123 * \param peerAddress peer address
124 * \return metric to HWMP protocol, needed only by metrics to add peer as routing entry
125 */
126 uint32_t GetLinkMetric(Mac48Address peerAddress) const;
127 /**
128 * Get the channel ID
129 * \returns the channel ID
130 */
131 uint16_t GetChannelId() const;
132 /**
133 * Report statistics
134 * \param os The output stream on which to report
135 */
136 void Report(std::ostream& os) const;
137 /// Reset statistics
138 void ResetStats();
139
140 private:
142 uint32_t m_ifIndex; ///< IF index
144
145 /// \name my PREQ and PREQ timer:
146 ///@{
147 EventId m_preqTimer; //!< Timer for PREQs
148 std::vector<IePreq> m_myPreq; //!< container of PREQs
149 ///@}
150
151 /// \name PERR timer and stored path error
152 ///@{
154
155 /// MyPerr structure
156 struct MyPerr
157 {
158 std::vector<HwmpProtocol::FailedDestination> destinations; ///< destinations
159 std::vector<Mac48Address> receivers; ///< receivers
160 };
161
162 MyPerr m_myPerr; ///< PERR
163
164 ///@}
165
166 /// \name Statistics
167 ///@{
168
169 /**
170 * Statistics structure
171 */
173 {
174 uint16_t txPreq; ///< transmit PREQ
175 uint16_t rxPreq; ///< receive PREQ
176 uint16_t txPrep; ///< transmit PREP
177 uint16_t rxPrep; ///< receive PREP
178 uint16_t txPerr; ///< transmit PERR
179 uint16_t rxPerr; ///< receive PERR
180 uint16_t txMgt; ///< transmit management
181 uint32_t txMgtBytes; ///< transmit management bytes
182 uint16_t rxMgt; ///< receive management
183 uint32_t rxMgtBytes; ///< receive management bytes
184 uint16_t txData; ///< transmit data
185 uint32_t txDataBytes; ///< transmit data bytes
186 uint16_t rxData; ///< receive data
187 uint32_t rxDataBytes; ///< receive data bytes
188 /**
189 * Print function
190 * \param os the output stream
191 */
192 void Print(std::ostream& os) const;
193 Statistics();
194 };
195
196 Statistics m_stats; ///< statistics
197 ///@}
198
199 private:
200 /**
201 * Receive data frame
202 *
203 * \param packet
204 * \param header
205 * \returns true if a packet was received
206 */
207 bool ReceiveData(Ptr<Packet> packet, const WifiMacHeader& header);
208 /**
209 * Receive action management frame
210 *
211 * \param packet
212 * \param header
213 * \returns true if a packet was received
214 */
215 bool ReceiveAction(Ptr<Packet> packet, const WifiMacHeader& header);
216};
217} // namespace dot11s
218} // namespace ns3
219#endif
An identifier for simulation events.
Definition: event-id.h:55
an EUI-48 address
Definition: mac48-address.h:46
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.
Definition: ptr.h:77
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.
Definition: hwmp-protocol.h:68
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.
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.
Statistics m_stats
statistics
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 txDataBytes
transmit data bytes
uint32_t rxMgtBytes
receive management bytes