A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::UanMacCw Class Reference

CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window. More...

#include <uan-mac-cw.h>

+ Inheritance diagram for ns3::UanMacCw:
+ Collaboration diagram for ns3::UanMacCw:

Public Member Functions

 UanMacCw ()
virtual ~UanMacCw ()
int64_t AssignStreams (int64_t stream)
virtual void AttachPhy (Ptr< UanPhy > phy)
virtual void Clear (void)
virtual bool Enqueue (Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)
virtual Address GetAddress ()
virtual Address GetBroadcast (void) const
virtual uint32_t GetCw (void)
virtual Time GetSlotTime (void)
virtual void NotifyCcaEnd (void)
 Function called by UanPhy object to notify of channel no longer sensed busy.
virtual void NotifyCcaStart (void)
 Function called by UanPhy object to notify of channel sensed busy.
virtual void NotifyRxEndError (void)
 Function called by UanPhy object to notify of packet received in error.
virtual void NotifyRxEndOk (void)
 Function called by UanPhy object to notify of packet received successfully.
virtual void NotifyRxStart (void)
 Function called by UanPhy object to notify of packet reception.
virtual void NotifyTxStart (Time duration)
 Function called by UanPhy object to notify of outgoing transmission start.
virtual void SetAddress (UanAddress addr)
virtual void SetCw (uint32_t cw)
virtual void SetForwardUpCb (Callback< void, Ptr< Packet >, const UanAddress & > cb)
virtual void SetSlotTime (Time duration)
- Public Member Functions inherited from ns3::UanPhyListener
virtual ~UanPhyListener ()

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::UanMacCw.

Protected Member Functions

virtual void DoDispose ()

Private Types

enum  State { IDLE, CCABUSY, RUNNING, TX }

Private Member Functions

void EndTx (void)
void PhyRxPacketError (Ptr< Packet > packet, double sinr)
void PhyRxPacketGood (Ptr< Packet > packet, double sinr, UanTxMode mode)
void SaveTimer (void)
void SendPacket (void)
void StartTimer (void)

Private Attributes

UanAddress m_address
bool m_cleared
uint32_t m_cw
TracedCallback< Ptr< const
Packet >, uint16_t > 
m_dequeueLogger
TracedCallback< Ptr< const
Packet >, uint16_t > 
m_enqueueLogger
Callback< void, Ptr< Packet >
, const UanAddress & > 
m_forwardUpCb
Ptr< UanPhym_phy
Ptr< Packetm_pktTx
uint16_t m_pktTxProt
Ptr< UniformRandomVariablem_rv
 Provides uniform random variables.
TracedCallback< Ptr< const
Packet >, UanTxMode
m_rxLogger
Time m_savedDelayS
EventId m_sendEvent
Time m_sendTime
Time m_slotTime
State m_state
EventId m_txEndEvent

Detailed Description

CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window.

For more information on this MAC protocol, see: Parrish, N.; Tracy, L.; Roy, S.; Arabshahi, P.; Fox, W., "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols," Selected Areas in Communications, IEEE Journal on , vol.26, no.9, pp.1720-1730, December 2008

Definition at line 43 of file uan-mac-cw.h.

Member Enumeration Documentation

enum ns3::UanMacCw::State
private
Enumerator:
IDLE 
CCABUSY 
RUNNING 
TX 

Definition at line 102 of file uan-mac-cw.h.

Constructor & Destructor Documentation

ns3::UanMacCw::UanMacCw ( )

Definition at line 36 of file uan-mac-cw.cc.

References m_rv.

ns3::UanMacCw::~UanMacCw ( )
virtual

Definition at line 47 of file uan-mac-cw.cc.

Member Function Documentation

int64_t ns3::UanMacCw::AssignStreams ( int64_t  stream)
virtual

Assign a fixed random variable stream number to the random variables used by this model. Return the number of streams (possibly zero) that have been assigned.

Parameters
streamfirst stream index to use
Returns
the number of stream indices assigned by this model

Implements ns3::UanMac.

Definition at line 290 of file uan-mac-cw.cc.

References m_rv, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().

+ Here is the call graph for this function:

void ns3::UanMacCw::AttachPhy ( Ptr< UanPhy phy)
virtual

Attach PHY layer to this MAC. Some MACs may be designed to work with multiple PHY layers. Others may only work with one.

Parameters
phyPhy layer to attach to this MAC

Implements ns3::UanMac.

Definition at line 193 of file uan-mac-cw.cc.

References m_phy, ns3::MakeCallback(), PhyRxPacketError(), PhyRxPacketGood(), ns3::UanPhy::RegisterListener(), ns3::UanPhy::SetReceiveErrorCallback(), and ns3::UanPhy::SetReceiveOkCallback().

+ Here is the call graph for this function:

void ns3::UanMacCw::Clear ( void  )
virtual

Clears all pointer references

Implements ns3::UanMac.

Definition at line 52 of file uan-mac-cw.cc.

References ns3::EventId::Cancel(), ns3::UanPhy::Clear(), m_cleared, m_phy, m_pktTx, m_sendEvent, and m_txEndEvent.

Referenced by DoDispose().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::UanMacCw::DoDispose ( void  )
protectedvirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Definition at line 70 of file uan-mac-cw.cc.

References Clear().

+ Here is the call graph for this function:

void ns3::UanMacCw::EndTx ( void  )
private

Definition at line 298 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), IDLE, ns3::UanPhy::IsStateIdle(), m_phy, m_state, ns3::Simulator::Now(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, RUNNING, StartTimer(), and TX.

Referenced by NotifyTxStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Address ns3::UanMacCw::GetAddress ( )
virtual
Returns
MAC Address

Implements ns3::UanMac.

Definition at line 107 of file uan-mac-cw.cc.

References m_address.

Referenced by EndTx(), Enqueue(), NotifyCcaEnd(), NotifyCcaStart(), NotifyRxEndError(), NotifyRxEndOk(), NotifyRxStart(), SaveTimer(), SendPacket(), and StartTimer().

+ Here is the caller graph for this function:

Address ns3::UanMacCw::GetBroadcast ( void  ) const
virtual
Returns
Broadcast address

Implements ns3::UanMac.

Definition at line 202 of file uan-mac-cw.cc.

Referenced by PhyRxPacketGood().

+ Here is the caller graph for this function:

uint32_t ns3::UanMacCw::GetCw ( void  )
virtual
Returns
Contention window size

Definition at line 330 of file uan-mac-cw.cc.

References m_cw.

Time ns3::UanMacCw::GetSlotTime ( void  )
virtual
Returns
slot time duration

Definition at line 335 of file uan-mac-cw.cc.

References m_slotTime.

TypeId ns3::UanMacCw::GetTypeId ( void  )
static

This method returns the TypeId associated to ns3::UanMacCw.

Attributes defined for this type:

  • CW: The MAC parameter CW
  • SlotTime: Time slot duration for MAC backoff
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +20000000.0ns
    • Flags: construct write read

TraceSources defined for this type:

  • Enqueue: A packet arrived at the MAC for transmission
  • Dequeue: A was passed down to the PHY from the MAC
  • RX: A packet was destined for this MAC and was received

Reimplemented from ns3::UanMac.

Definition at line 77 of file uan-mac-cw.cc.

References m_cw, m_dequeueLogger, m_enqueueLogger, m_rxLogger, m_slotTime, ns3::MakeTraceSourceAccessor(), ns3::MilliSeconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyCcaEnd ( void  )
virtual

Function called by UanPhy object to notify of channel no longer sensed busy.

Implements ns3::UanPhyListener.

Definition at line 257 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyCcaStart ( void  )
virtual

Function called by UanPhy object to notify of channel sensed busy.

Implements ns3::UanPhyListener.

Definition at line 245 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and SaveTimer().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyRxEndError ( void  )
virtual

Function called by UanPhy object to notify of packet received in error.

Implements ns3::UanPhyListener.

Definition at line 233 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), ns3::UanPhy::IsStateCcaBusy(), m_phy, m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyRxEndOk ( void  )
virtual

Function called by UanPhy object to notify of packet received successfully.

Implements ns3::UanPhyListener.

Definition at line 221 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), ns3::UanPhy::IsStateCcaBusy(), m_phy, m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyRxStart ( void  )
virtual

Function called by UanPhy object to notify of packet reception.

Implements ns3::UanPhyListener.

Definition at line 209 of file uan-mac-cw.cc.

References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and SaveTimer().

+ Here is the call graph for this function:

void ns3::UanMacCw::NotifyTxStart ( Time  duration)
virtual

Function called by UanPhy object to notify of outgoing transmission start.

Implements ns3::UanPhyListener.

Definition at line 269 of file uan-mac-cw.cc.

References ns3::Simulator::Cancel(), CCABUSY, EndTx(), ns3::Time::GetSeconds(), ns3::EventId::IsRunning(), m_state, m_txEndEvent, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, RUNNING, SaveTimer(), and ns3::Simulator::Schedule().

+ Here is the call graph for this function:

void ns3::UanMacCw::PhyRxPacketError ( Ptr< Packet packet,
double  sinr 
)
private

Definition at line 351 of file uan-mac-cw.cc.

Referenced by AttachPhy().

+ Here is the caller graph for this function:

void ns3::UanMacCw::PhyRxPacketGood ( Ptr< Packet packet,
double  sinr,
UanTxMode  mode 
)
private

Definition at line 340 of file uan-mac-cw.cc.

References GetBroadcast(), ns3::UanHeaderCommon::GetDest(), ns3::UanHeaderCommon::GetSrc(), m_address, m_forwardUpCb, and ns3::Packet::RemoveHeader().

Referenced by AttachPhy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::UanMacCw::SaveTimer ( void  )
private

Definition at line 356 of file uan-mac-cw.cc.

References ns3::Simulator::Cancel(), GetAddress(), m_pktTx, m_savedDelayS, m_sendEvent, m_sendTime, ns3::Now(), ns3::Simulator::Now(), NS_ASSERT, and NS_LOG_DEBUG.

Referenced by NotifyCcaStart(), NotifyRxStart(), and NotifyTxStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::UanMacCw::SendPacket ( void  )
private

Definition at line 383 of file uan-mac-cw.cc.

References GetAddress(), m_phy, m_pktTx, m_pktTxProt, m_savedDelayS, m_sendTime, m_state, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, RUNNING, ns3::Seconds(), ns3::UanPhy::SendPacket(), and TX.

Referenced by StartTimer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::UanMacCw::SetAddress ( UanAddress  addr)
virtual
Parameters
addrUanAddress for this MAC

Implements ns3::UanMac.

Definition at line 113 of file uan-mac-cw.cc.

References m_address.

void ns3::UanMacCw::SetCw ( uint32_t  cw)
virtual
Parameters
cwContention window size

Definition at line 320 of file uan-mac-cw.cc.

References m_cw.

void ns3::UanMacCw::SetForwardUpCb ( Callback< void, Ptr< Packet >, const UanAddress & >  cb)
virtual
Parameters
cbCallback to be called when a packet is forwarded up to higher layer

Implements ns3::UanMac.

Definition at line 187 of file uan-mac-cw.cc.

References m_forwardUpCb.

void ns3::UanMacCw::SetSlotTime ( Time  duration)
virtual
Parameters
durationSlot time duration

Definition at line 325 of file uan-mac-cw.cc.

References m_slotTime.

void ns3::UanMacCw::StartTimer ( void  )
private

Definition at line 367 of file uan-mac-cw.cc.

References GetAddress(), ns3::Time::GetSeconds(), m_savedDelayS, m_sendEvent, m_sendTime, ns3::Now(), ns3::Simulator::Now(), NS_LOG_DEBUG, ns3::Simulator::Schedule(), and SendPacket().

Referenced by EndTx(), NotifyCcaEnd(), NotifyRxEndError(), and NotifyRxEndOk().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

UanAddress ns3::UanMacCw::m_address
private

Definition at line 107 of file uan-mac-cw.h.

Referenced by Enqueue(), GetAddress(), PhyRxPacketGood(), and SetAddress().

bool ns3::UanMacCw::m_cleared
private

Definition at line 126 of file uan-mac-cw.h.

Referenced by Clear().

uint32_t ns3::UanMacCw::m_cw
private

Definition at line 114 of file uan-mac-cw.h.

Referenced by Enqueue(), GetCw(), GetTypeId(), and SetCw().

TracedCallback<Ptr<const Packet>, uint16_t > ns3::UanMacCw::m_dequeueLogger
private

Definition at line 111 of file uan-mac-cw.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet>, uint16_t > ns3::UanMacCw::m_enqueueLogger
private

Definition at line 110 of file uan-mac-cw.h.

Referenced by Enqueue(), and GetTypeId().

Callback<void, Ptr<Packet>, const UanAddress& > ns3::UanMacCw::m_forwardUpCb
private

Definition at line 106 of file uan-mac-cw.h.

Referenced by PhyRxPacketGood(), and SetForwardUpCb().

Ptr<UanPhy> ns3::UanMacCw::m_phy
private

Definition at line 108 of file uan-mac-cw.h.

Referenced by AttachPhy(), Clear(), EndTx(), Enqueue(), NotifyRxEndError(), NotifyRxEndOk(), and SendPacket().

Ptr<Packet> ns3::UanMacCw::m_pktTx
private

Definition at line 120 of file uan-mac-cw.h.

Referenced by Clear(), Enqueue(), SaveTimer(), and SendPacket().

uint16_t ns3::UanMacCw::m_pktTxProt
private

Definition at line 121 of file uan-mac-cw.h.

Referenced by Enqueue(), and SendPacket().

Ptr<UniformRandomVariable> ns3::UanMacCw::m_rv
private

Provides uniform random variables.

Definition at line 129 of file uan-mac-cw.h.

Referenced by AssignStreams(), Enqueue(), and UanMacCw().

TracedCallback<Ptr<const Packet>, UanTxMode > ns3::UanMacCw::m_rxLogger
private

Definition at line 109 of file uan-mac-cw.h.

Referenced by GetTypeId().

Time ns3::UanMacCw::m_savedDelayS
private

Definition at line 119 of file uan-mac-cw.h.

Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().

EventId ns3::UanMacCw::m_sendEvent
private

Definition at line 122 of file uan-mac-cw.h.

Referenced by Clear(), SaveTimer(), and StartTimer().

Time ns3::UanMacCw::m_sendTime
private

Definition at line 118 of file uan-mac-cw.h.

Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().

Time ns3::UanMacCw::m_slotTime
private

Definition at line 115 of file uan-mac-cw.h.

Referenced by Enqueue(), GetSlotTime(), GetTypeId(), and SetSlotTime().

State ns3::UanMacCw::m_state
private
EventId ns3::UanMacCw::m_txEndEvent
private

Definition at line 123 of file uan-mac-cw.h.

Referenced by Clear(), Enqueue(), and NotifyTxStart().


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