CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window. More...
#include <uan-mac-cw.h>
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) |
![]() | |
virtual | ~UanPhyListener () |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
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< UanPhy > | m_phy |
Ptr< Packet > | m_pktTx |
uint16_t | m_pktTxProt |
Ptr< UniformRandomVariable > | m_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 |
CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window.
This type is not accessible from the Config system.
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.
|
private |
Definition at line 102 of file uan-mac-cw.h.
ns3::UanMacCw::UanMacCw | ( | ) |
Definition at line 36 of file uan-mac-cw.cc.
References m_rv.
|
virtual |
Definition at line 47 of file uan-mac-cw.cc.
|
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.
stream | first stream index to use |
Implements ns3::UanMac.
Definition at line 290 of file uan-mac-cw.cc.
References m_rv, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
Attach PHY layer to this MAC. Some MACs may be designed to work with multiple PHY layers. Others may only work with one.
phy | Phy 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().
|
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().
|
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().
|
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().
|
virtual |
Enqueue packet to be transmitted
pkt | Packet to be transmitted |
dest | Destination address |
protocolNumber | Protocol #. Usage varies by MAC |
Implements ns3::UanMac.
Definition at line 119 of file uan-mac-cw.cc.
References ns3::Packet::AddHeader(), CCABUSY, ns3::UanAddress::ConvertFrom(), GetAddress(), ns3::UanTransducer::GetArrivalList(), ns3::Time::GetSeconds(), ns3::Packet::GetSize(), ns3::UanPhy::GetTransducer(), ns3::UniformRandomVariable::GetValue(), IDLE, ns3::EventId::IsRunning(), ns3::UanPhy::IsStateBusy(), ns3::UanPhy::IsStateTx(), m_address, m_cw, m_enqueueLogger, m_phy, m_pktTx, m_pktTxProt, m_rv, m_savedDelayS, m_sendTime, m_slotTime, m_state, m_txEndEvent, ns3::Now(), ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, RUNNING, ns3::Seconds(), ns3::UanPhy::SendPacket(), ns3::UanHeaderCommon::SetDest(), ns3::UanHeaderCommon::SetSrc(), ns3::UanHeaderCommon::SetType(), and TX.
|
virtual |
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().
|
virtual |
Implements ns3::UanMac.
Definition at line 202 of file uan-mac-cw.cc.
Referenced by PhyRxPacketGood().
|
virtual |
|
virtual |
|
static |
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
Definition at line 351 of file uan-mac-cw.cc.
Referenced by AttachPhy().
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().
|
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().
|
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().
|
virtual |
addr | UanAddress for this MAC |
Implements ns3::UanMac.
Definition at line 113 of file uan-mac-cw.cc.
References m_address.
|
virtual |
|
virtual |
cb | Callback 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.
|
virtual |
duration | Slot time duration |
Definition at line 325 of file uan-mac-cw.cc.
References m_slotTime.
|
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().
|
private |
Definition at line 107 of file uan-mac-cw.h.
Referenced by Enqueue(), GetAddress(), PhyRxPacketGood(), and SetAddress().
|
private |
Definition at line 126 of file uan-mac-cw.h.
Referenced by Clear().
|
private |
Definition at line 114 of file uan-mac-cw.h.
Referenced by Enqueue(), GetCw(), GetTypeId(), and SetCw().
|
private |
Definition at line 111 of file uan-mac-cw.h.
Referenced by GetTypeId().
|
private |
Definition at line 110 of file uan-mac-cw.h.
Referenced by Enqueue(), and GetTypeId().
|
private |
Definition at line 106 of file uan-mac-cw.h.
Referenced by PhyRxPacketGood(), and SetForwardUpCb().
Definition at line 108 of file uan-mac-cw.h.
Referenced by AttachPhy(), Clear(), EndTx(), Enqueue(), NotifyRxEndError(), NotifyRxEndOk(), and SendPacket().
Definition at line 120 of file uan-mac-cw.h.
Referenced by Clear(), Enqueue(), SaveTimer(), and SendPacket().
|
private |
Definition at line 121 of file uan-mac-cw.h.
Referenced by Enqueue(), and SendPacket().
|
private |
Provides uniform random variables.
Definition at line 129 of file uan-mac-cw.h.
Referenced by AssignStreams(), Enqueue(), and UanMacCw().
|
private |
Definition at line 109 of file uan-mac-cw.h.
Referenced by GetTypeId().
|
private |
Definition at line 119 of file uan-mac-cw.h.
Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().
|
private |
Definition at line 122 of file uan-mac-cw.h.
Referenced by Clear(), SaveTimer(), and StartTimer().
|
private |
Definition at line 118 of file uan-mac-cw.h.
Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().
|
private |
Definition at line 115 of file uan-mac-cw.h.
Referenced by Enqueue(), GetSlotTime(), GetTypeId(), and SetSlotTime().
|
private |
Definition at line 124 of file uan-mac-cw.h.
Referenced by EndTx(), Enqueue(), NotifyCcaEnd(), NotifyCcaStart(), NotifyRxEndError(), NotifyRxEndOk(), NotifyRxStart(), NotifyTxStart(), and SendPacket().
|
private |
Definition at line 123 of file uan-mac-cw.h.
Referenced by Clear(), Enqueue(), and NotifyTxStart().