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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef MAC_RX_MIDDLE_H
10#define MAC_RX_MIDDLE_H
11
12#include "ns3/callback.h"
13#include "ns3/simple-ref-count.h"
14
15#include <map>
16
17namespace ns3
18{
19
20class WifiMacHeader;
21class OriginatorRxStatus;
22class Packet;
23class Mac48Address;
24class WifiMpdu;
25
26/**
27 * \ingroup wifi
28 *
29 * This class handles duplicate detection and recomposition of fragments.
30 */
31class MacRxMiddle : public SimpleRefCount<MacRxMiddle>
32{
33 public:
34 /**
35 * typedef for callback
36 */
38
41
42 /**
43 * Set a callback to forward the packet up.
44 *
45 * \param callback the callback to set
46 */
48
49 /**
50 * Receive an MPDU on the given link.
51 *
52 * \param mpdu the MPDU
53 * \param linkId the ID of the given link
54 */
55 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
56
57 private:
58 /// allow MacRxMiddleTest associated class access
59 friend class MacRxMiddleTest;
60 /**
61 * Look up for OriginatorRxStatus associated with the sender address
62 * (by looking at ADDR2 field in the header).
63 * The method creates a new OriginatorRxStatus if one is not already presented.
64 *
65 * \param hdr the MAC header
66 *
67 * \return OriginatorRxStatus
68 */
70 /**
71 * Check if we have already received the packet from the sender before
72 * (by looking at the sequence control field).
73 *
74 * \param hdr the MAC header
75 * \param originator the packet originator status
76 *
77 * \return true if we already received the packet previously,
78 * false otherwise
79 */
80 bool IsDuplicate(const WifiMacHeader& hdr, const OriginatorRxStatus& originator) const;
81 /**
82 * Check if the received packet is a fragment and handle it appropriately.
83 * If the packet is not a fragment, the method returns the packet.
84 * If the packet is a fragment (not the last fragment), the method initiates
85 * de-fragmentation process and return 0.
86 * If the packet is the last fragment, the method tries to re-construct the full packet
87 * and return the packet if success.
88 *
89 * \param packet the packet
90 * \param hdr the MAC header
91 * \param originator the packet originator status
92 *
93 * \return a packet if the packet is successfully reassembled (or not a fragment),
94 * 0 if we failed to reassemble the packet (e.g. missing fragments/out-of-order).
95 */
97 const WifiMacHeader& hdr,
98 OriginatorRxStatus& originator);
99
100 /**
101 * typedef for a map between address and OriginatorRxStatus
102 */
103 using Originators = std::map<Mac48Address, OriginatorRxStatus, std::less<>>;
104
105 /**
106 * typedef for a map between address, OriginatorRxStatus, and Traffic ID
107 */
109 std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>;
110
111 /**
112 * typedef for an iterator for Originators
113 */
114 using OriginatorsI = std::map<Mac48Address, OriginatorRxStatus, std::less<>>::iterator;
115
116 /**
117 * typedef for an iterator for QosOriginators
118 */
120 std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>::iterator;
121
122 Originators m_originatorStatus; ///< originator status
123 QosOriginators m_qosOriginatorStatus; ///< QOS originator status
124 ForwardUpCallback m_callback; ///< forward up callback
125};
126
127} // namespace ns3
128
129#endif /* MAC_RX_MIDDLE_H */
This class handles duplicate detection and recomposition of fragments.
friend class MacRxMiddleTest
allow MacRxMiddleTest associated class access
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< Mac48Address, OriginatorRxStatus, std::less<> >::iterator OriginatorsI
typedef for an iterator for Originators
Originators m_originatorStatus
originator status
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus, std::less<> > QosOriginators
typedef for a map between address, OriginatorRxStatus, and Traffic ID
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.
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus, std::less<> >::iterator QosOriginatorsI
typedef for an iterator for QosOriginators
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<> > Originators
typedef for a map between address and OriginatorRxStatus
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.
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.