A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac-rx-middle.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef MAC_RX_MIDDLE_H
21#define MAC_RX_MIDDLE_H
22
23#include "ns3/callback.h"
24#include "ns3/simple-ref-count.h"
25
26#include <map>
27
28namespace ns3
29{
30
31class WifiMacHeader;
32class OriginatorRxStatus;
33class Packet;
34class Mac48Address;
35class WifiMpdu;
36
37/**
38 * \ingroup wifi
39 *
40 * This class handles duplicate detection and recomposition of fragments.
41 */
42class MacRxMiddle : public SimpleRefCount<MacRxMiddle>
43{
44 public:
45 /**
46 * typedef for callback
47 */
49
52
53 /**
54 * Set a callback to forward the packet up.
55 *
56 * \param callback the callback to set
57 */
59
60 /**
61 * Receive an MPDU on the given link.
62 *
63 * \param mpdu the MPDU
64 * \param linkId the ID of the given link
65 */
66 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
67
68 private:
69 /// allow MacRxMiddleTest associated class access
70 friend class MacRxMiddleTest;
71 /**
72 * Look up for OriginatorRxStatus associated with the sender address
73 * (by looking at ADDR2 field in the header).
74 * The method creates a new OriginatorRxStatus if one is not already presented.
75 *
76 * \param hdr the MAC header
77 *
78 * \return OriginatorRxStatus
79 */
81 /**
82 * Check if we have already received the packet from the sender before
83 * (by looking at the sequence control field).
84 *
85 * \param hdr the MAC header
86 * \param originator the packet originator status
87 *
88 * \return true if we already received the packet previously,
89 * false otherwise
90 */
91 bool IsDuplicate(const WifiMacHeader& hdr, const OriginatorRxStatus& originator) const;
92 /**
93 * Check if the received packet is a fragment and handle it appropriately.
94 * If the packet is not a fragment, the method returns the packet.
95 * If the packet is a fragment (not the last fragment), the method initiates
96 * de-fragmentation process and return 0.
97 * If the packet is the last fragment, the method tries to re-construct the full packet
98 * and return the packet if success.
99 *
100 * \param packet the packet
101 * \param hdr the MAC header
102 * \param originator the packet originator status
103 *
104 * \return a packet if the packet is successfully reassembled (or not a fragment),
105 * 0 if we failed to reassemble the packet (e.g. missing fragments/out-of-order).
106 */
108 const WifiMacHeader& hdr,
109 OriginatorRxStatus& originator);
110
111 /**
112 * typedef for a map between address and OriginatorRxStatus
113 */
114 using Originators = std::map<Mac48Address, OriginatorRxStatus, std::less<>>;
115
116 /**
117 * typedef for a map between address, OriginatorRxStatus, and Traffic ID
118 */
120 std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>;
121
122 /**
123 * typedef for an iterator for Originators
124 */
125 using OriginatorsI = std::map<Mac48Address, OriginatorRxStatus, std::less<>>::iterator;
126
127 /**
128 * typedef for an iterator for QosOriginators
129 */
131 std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>::iterator;
132
133 Originators m_originatorStatus; ///< originator status
134 QosOriginators m_qosOriginatorStatus; ///< QOS originator status
135 ForwardUpCallback m_callback; ///< forward up callback
136};
137
138} // namespace ns3
139
140#endif /* MAC_RX_MIDDLE_H */
This class handles duplicate detection and recomposition of fragments.
Definition: mac-rx-middle.h:43
friend class MacRxMiddleTest
allow MacRxMiddleTest associated class access
Definition: mac-rx-middle.h:70
void SetForwardCallback(ForwardUpCallback callback)
Set a callback to forward the packet up.
bool IsDuplicate(const WifiMacHeader &hdr, const OriginatorRxStatus &originator) const
Check if we have already received the packet from the sender before (by looking at the sequence contr...
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus, std::less<> >::iterator QosOriginatorsI
typedef for an iterator for QosOriginators
Originators m_originatorStatus
originator status
std::map< Mac48Address, OriginatorRxStatus, std::less<> > Originators
typedef for a map between address and OriginatorRxStatus
Ptr< const Packet > HandleFragments(Ptr< const Packet > packet, const WifiMacHeader &hdr, OriginatorRxStatus &originator)
Check if the received packet is a fragment and handle it appropriately.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Receive an MPDU on the given link.
QosOriginators m_qosOriginatorStatus
QOS originator status.
std::map< Mac48Address, OriginatorRxStatus, std::less<> >::iterator OriginatorsI
typedef for an iterator for Originators
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus, std::less<> > QosOriginators
typedef for a map between address, OriginatorRxStatus, and Traffic ID
ForwardUpCallback m_callback
forward up callback
OriginatorRxStatus & Lookup(const WifiMacHeader &hdr)
Look up for OriginatorRxStatus associated with the sender address (by looking at ADDR2 field in the h...
A class to keep track of the packet originator status.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
Implements the IEEE 802.11 MAC header.
Every class exported by the ns3 library is enclosed in the ns3 namespace.