This class handles duplicate detection and recomposition of fragments. More...
#include "mac-rx-middle.h"
Public Types | |
typedef Callback< void, Ptr< Packet >, const WifiMacHeader * > | ForwardUpCallback |
typedef for callback More... | |
Public Member Functions | |
MacRxMiddle () | |
~MacRxMiddle () | |
void | Receive (Ptr< Packet > packet, const WifiMacHeader *hdr) |
Receive a packet. More... | |
void | SetForwardCallback (ForwardUpCallback callback) |
Set a callback to forward the packet up. More... | |
void | SetPcfCallback (Callback< void > callback) |
Set a callback to trigger the next PCF frame. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< MacRxMiddle > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Private Types | |
typedef std::map< Mac48Address, OriginatorRxStatus *, std::less< Mac48Address > > | Originators |
typedef for a map between address and OriginatorRxStatus More... | |
typedef std::map< Mac48Address, OriginatorRxStatus *, std::less< Mac48Address > >::iterator | OriginatorsI |
typedef for an iterator for Originators More... | |
typedef std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus *, std::less< std::pair< Mac48Address, uint8_t > > > | QosOriginators |
typedef for a map between address, OriginatorRxStatus, and Traffic ID More... | |
typedef std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus *, std::less< std::pair< Mac48Address, uint8_t > > >::iterator | QosOriginatorsI |
typedef for an iterator for QosOriginators More... | |
Private Member Functions | |
Ptr< Packet > | HandleFragments (Ptr< Packet > packet, const WifiMacHeader *hdr, OriginatorRxStatus *originator) |
Check if the received packet is a fragment and handle it appropriately. More... | |
bool | IsDuplicate (const WifiMacHeader *hdr, OriginatorRxStatus *originator) const |
Check if we have already received the packet from the sender before (by looking at the sequence control field). More... | |
OriginatorRxStatus * | Lookup (const WifiMacHeader *hdr) |
Look up for OriginatorRxStatus associated with the sender address (by looking at ADDR2 field in the header). More... | |
Private Attributes | |
ForwardUpCallback | m_callback |
forward up callback More... | |
Originators | m_originatorStatus |
originator status More... | |
Callback< void > | m_pcfCallback |
PCF callback. More... | |
QosOriginators | m_qosOriginatorStatus |
QOS originator status. More... | |
Friends | |
class | MacRxMiddleTest |
allow MacRxMiddleTest associated class access More... | |
This class handles duplicate detection and recomposition of fragments.
Definition at line 40 of file mac-rx-middle.h.
typedef Callback<void, Ptr<Packet>, const WifiMacHeader*> ns3::MacRxMiddle::ForwardUpCallback |
typedef for callback
Definition at line 46 of file mac-rx-middle.h.
|
private |
typedef for a map between address and OriginatorRxStatus
Definition at line 119 of file mac-rx-middle.h.
|
private |
typedef for an iterator for Originators
Definition at line 127 of file mac-rx-middle.h.
|
private |
typedef for a map between address, OriginatorRxStatus, and Traffic ID
Definition at line 123 of file mac-rx-middle.h.
|
private |
typedef for an iterator for QosOriginators
Definition at line 131 of file mac-rx-middle.h.
ns3::MacRxMiddle::MacRxMiddle | ( | ) |
Definition at line 161 of file mac-rx-middle.cc.
References NS_LOG_FUNCTION_NOARGS.
ns3::MacRxMiddle::~MacRxMiddle | ( | ) |
Definition at line 166 of file mac-rx-middle.cc.
References m_originatorStatus, m_qosOriginatorStatus, and NS_LOG_FUNCTION_NOARGS.
|
private |
Check if the received packet is a fragment and handle it appropriately.
If the packet is not a fragment, the method returns the packet. If the packet is a fragment (not the last fragment), the method initiates de-fragmentation process and return 0. If the packet is the last fragment, the method tries to re-construct the full packet and return the packet if success.
packet | |
hdr | |
originator |
Definition at line 240 of file mac-rx-middle.cc.
References ns3::OriginatorRxStatus::AccumulateFirstFragment(), ns3::OriginatorRxStatus::AccumulateFragment(), ns3::OriginatorRxStatus::AccumulateLastFragment(), ns3::WifiMacHeader::GetFragmentNumber(), ns3::WifiMacHeader::GetSequenceControl(), ns3::WifiMacHeader::GetSequenceNumber(), ns3::Packet::GetSize(), ns3::WifiMacHeader::GetSize(), ns3::OriginatorRxStatus::IsDeFragmenting(), ns3::WifiMacHeader::IsMoreFragments(), ns3::OriginatorRxStatus::IsNextFragment(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::OriginatorRxStatus::SetSequenceControl().
Referenced by Receive().
|
private |
Check if we have already received the packet from the sender before (by looking at the sequence control field).
hdr | |
originator |
Definition at line 227 of file mac-rx-middle.cc.
References ns3::OriginatorRxStatus::GetLastSequenceControl(), ns3::WifiMacHeader::GetSequenceControl(), ns3::WifiMacHeader::IsRetry(), and NS_LOG_FUNCTION.
Referenced by Receive().
|
private |
Look up for OriginatorRxStatus associated with the sender address (by looking at ADDR2 field in the header).
The method creates a new OriginatorRxStatus if one is not already presented.
hdr |
Definition at line 193 of file mac-rx-middle.cc.
References ns3::WifiMacHeader::GetAddr2(), ns3::WifiMacHeader::GetQosTid(), ns3::Mac48Address::IsGroup(), ns3::WifiMacHeader::IsQosData(), m_originatorStatus, m_qosOriginatorStatus, and NS_LOG_FUNCTION.
Referenced by Receive().
void ns3::MacRxMiddle::Receive | ( | Ptr< Packet > | packet, |
const WifiMacHeader * | hdr | ||
) |
Receive a packet.
packet | the packet |
hdr | MAC header |
The check below is really unneeded because it can fail in a lot of normal cases. Specifically, it is possible for sequence numbers to loop back to zero once they reach 0xfff0 and to go up to 0xf7f0 in which case the check below will report the two sequence numbers to not have the correct order relationship. So, this check cannot be used to discard old duplicate frames. It is thus here only for documentation purposes.
Definition at line 299 of file mac-rx-middle.cc.
References ns3::WifiMacHeader::GetAddr1(), ns3::WifiMacHeader::GetAddr2(), ns3::WifiMacHeader::GetFragmentNumber(), ns3::OriginatorRxStatus::GetLastSequenceControl(), ns3::WifiMacHeader::GetSequenceControl(), ns3::WifiMacHeader::GetSequenceNumber(), HandleFragments(), ns3::WifiMacHeader::IsData(), IsDuplicate(), ns3::Mac48Address::IsGroup(), ns3::WifiMacHeader::IsMgt(), ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), Lookup(), m_callback, m_pcfCallback, NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::OriginatorRxStatus::SetSequenceControl().
Referenced by ns3::OcbWifiMac::EnableForWave(), and ns3::RegularWifiMac::RegularWifiMac().
void ns3::MacRxMiddle::SetForwardCallback | ( | ForwardUpCallback | callback | ) |
Set a callback to forward the packet up.
callback |
Definition at line 186 of file mac-rx-middle.cc.
References m_callback, and NS_LOG_FUNCTION_NOARGS.
void ns3::MacRxMiddle::SetPcfCallback | ( | Callback< void > | callback | ) |
Set a callback to trigger the next PCF frame.
callback |
Definition at line 346 of file mac-rx-middle.cc.
References m_pcfCallback.
|
friend |
allow MacRxMiddleTest associated class access
Definition at line 76 of file mac-rx-middle.h.
|
private |
forward up callback
Definition at line 135 of file mac-rx-middle.h.
Referenced by Receive(), and SetForwardCallback().
|
private |
originator status
Definition at line 133 of file mac-rx-middle.h.
Referenced by Lookup(), and ~MacRxMiddle().
|
private |
PCF callback.
Definition at line 137 of file mac-rx-middle.h.
Referenced by Receive(), and SetPcfCallback().
|
private |
QOS originator status.
Definition at line 134 of file mac-rx-middle.h.
Referenced by Lookup(), and ~MacRxMiddle().