A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::MacRxMiddle Class Reference

This class handles duplicate detection and recomposition of fragments. More...

#include "mac-rx-middle.h"

+ Inheritance diagram for ns3::MacRxMiddle:
+ Collaboration diagram for ns3::MacRxMiddle:

Public Types

using ForwardUpCallback = Callback<void, Ptr<const WifiMpdu>, uint8_t >
 typedef for callback
 

Public Member Functions

 MacRxMiddle ()
 
 ~MacRxMiddle ()
 
void Receive (Ptr< const WifiMpdu > mpdu, uint8_t linkId)
 Receive an MPDU on the given link.
 
void SetForwardCallback (ForwardUpCallback callback)
 Set a callback to forward the packet up.
 
- Public Member Functions inherited from ns3::SimpleRefCount< MacRxMiddle >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 

Private Types

using Originators = std::map<Mac48Address, OriginatorRxStatus, std::less<>>
 typedef for a map between address and OriginatorRxStatus
 
using OriginatorsI = std::map<Mac48Address, OriginatorRxStatus, std::less<>>::iterator
 typedef for an iterator for Originators
 
using QosOriginators
 typedef for a map between address, OriginatorRxStatus, and Traffic ID
 
using QosOriginatorsI
 typedef for an iterator for QosOriginators
 

Private Member Functions

Ptr< const PacketHandleFragments (Ptr< const Packet > packet, const WifiMacHeader &hdr, OriginatorRxStatus &originator)
 Check if the received packet is a fragment and handle it appropriately.
 
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 control field).
 
OriginatorRxStatusLookup (const WifiMacHeader &hdr)
 Look up for OriginatorRxStatus associated with the sender address (by looking at ADDR2 field in the header).
 

Private Attributes

ForwardUpCallback m_callback
 forward up callback
 
Originators m_originatorStatus
 originator status
 
QosOriginators m_qosOriginatorStatus
 QOS originator status.
 

Friends

class MacRxMiddleTest
 allow MacRxMiddleTest associated class access
 

Detailed Description

This class handles duplicate detection and recomposition of fragments.

Definition at line 31 of file mac-rx-middle.h.

Member Typedef Documentation

◆ ForwardUpCallback

using ns3::MacRxMiddle::ForwardUpCallback = Callback<void, Ptr<const WifiMpdu>, uint8_t >

typedef for callback

Definition at line 37 of file mac-rx-middle.h.

◆ Originators

using ns3::MacRxMiddle::Originators = std::map<Mac48Address, OriginatorRxStatus, std::less<>>
private

typedef for a map between address and OriginatorRxStatus

Definition at line 103 of file mac-rx-middle.h.

◆ OriginatorsI

using ns3::MacRxMiddle::OriginatorsI = std::map<Mac48Address, OriginatorRxStatus, std::less<>>::iterator
private

typedef for an iterator for Originators

Definition at line 114 of file mac-rx-middle.h.

◆ QosOriginators

Initial value:
std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>

typedef for a map between address, OriginatorRxStatus, and Traffic ID

Definition at line 108 of file mac-rx-middle.h.

◆ QosOriginatorsI

Initial value:
std::map<std::pair<Mac48Address, uint8_t>, OriginatorRxStatus, std::less<>>::iterator

typedef for an iterator for QosOriginators

Definition at line 119 of file mac-rx-middle.h.

Constructor & Destructor Documentation

◆ MacRxMiddle()

ns3::MacRxMiddle::MacRxMiddle ( )

Definition at line 146 of file mac-rx-middle.cc.

References NS_LOG_FUNCTION_NOARGS.

◆ ~MacRxMiddle()

ns3::MacRxMiddle::~MacRxMiddle ( )

Definition at line 151 of file mac-rx-middle.cc.

References NS_LOG_FUNCTION_NOARGS.

Member Function Documentation

◆ HandleFragments()

Ptr< const Packet > ns3::MacRxMiddle::HandleFragments ( Ptr< const Packet > packet,
const WifiMacHeader & hdr,
OriginatorRxStatus & originator )
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.

Parameters
packetthe packet
hdrthe MAC header
originatorthe packet originator status
Returns
a packet if the packet is successfully reassembled (or not a fragment), 0 if we failed to reassemble the packet (e.g. missing fragments/out-of-order).

Definition at line 192 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::WifiMacHeader::GetSize(), ns3::OriginatorRxStatus::IsDeFragmenting(), ns3::WifiMacHeader::IsMoreFragments(), ns3::OriginatorRxStatus::IsNextFragment(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::OriginatorRxStatus::SetSequenceControl().

Referenced by Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsDuplicate()

bool ns3::MacRxMiddle::IsDuplicate ( const WifiMacHeader & hdr,
const OriginatorRxStatus & originator ) const
private

Check if we have already received the packet from the sender before (by looking at the sequence control field).

Parameters
hdrthe MAC header
originatorthe packet originator status
Returns
true if we already received the packet previously, false otherwise

Definition at line 185 of file mac-rx-middle.cc.

References ns3::OriginatorRxStatus::GetLastSequenceControl(), ns3::WifiMacHeader::GetSequenceControl(), ns3::WifiMacHeader::IsRetry(), and NS_LOG_FUNCTION.

Referenced by Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Lookup()

OriginatorRxStatus & ns3::MacRxMiddle::Lookup ( const WifiMacHeader & hdr)
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.

Parameters
hdrthe MAC header
Returns
OriginatorRxStatus

Definition at line 164 of file mac-rx-middle.cc.

References ns3::WifiMacHeader::GetAddr2(), ns3::WifiMacHeader::GetQosTid(), ns3::WifiMacHeader::IsQosData(), m_originatorStatus, m_qosOriginatorStatus, and NS_LOG_FUNCTION.

Referenced by Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Receive()

void ns3::MacRxMiddle::Receive ( Ptr< const WifiMpdu > mpdu,
uint8_t linkId )

Receive an MPDU on the given link.

Parameters
mpduthe MPDU
linkIdthe ID of the given link

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 252 of file mac-rx-middle.cc.

References ns3::Create(), HandleFragments(), IsDuplicate(), Lookup(), m_callback, NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SetForwardCallback()

void ns3::MacRxMiddle::SetForwardCallback ( ForwardUpCallback callback)

Set a callback to forward the packet up.

Parameters
callbackthe callback to set

Definition at line 157 of file mac-rx-middle.cc.

References m_callback, and NS_LOG_FUNCTION_NOARGS.

Friends And Related Symbol Documentation

◆ MacRxMiddleTest

friend class MacRxMiddleTest
friend

allow MacRxMiddleTest associated class access

Definition at line 59 of file mac-rx-middle.h.

Member Data Documentation

◆ m_callback

ForwardUpCallback ns3::MacRxMiddle::m_callback
private

forward up callback

Definition at line 124 of file mac-rx-middle.h.

Referenced by Receive(), and SetForwardCallback().

◆ m_originatorStatus

Originators ns3::MacRxMiddle::m_originatorStatus
private

originator status

Definition at line 122 of file mac-rx-middle.h.

Referenced by Lookup().

◆ m_qosOriginatorStatus

QosOriginators ns3::MacRxMiddle::m_qosOriginatorStatus
private

QOS originator status.

Definition at line 123 of file mac-rx-middle.h.

Referenced by Lookup().


The documentation for this class was generated from the following files: