A Discrete-Event Network Simulator
API
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ns3::UanMacCw Class Reference

CW-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:

Public Types

typedef void(* QueueTracedCallback) (Ptr< const Packet > packet, uint16_t proto)
 TracedCallback signature for enqueue/dequeue of a packet. More...
 
- Public Types inherited from ns3::UanMac
typedef void(* PacketModeTracedCallback) (Ptr< const Packet > packet, UanTxMode mode)
 TracedCallback signature for packet reception/enqueue/dequeue events. More...
 

Public Member Functions

 UanMacCw ()
 Default constructor. More...
 
virtual ~UanMacCw ()
 Dummy destructor, DoDispose. More...
 
int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. More...
 
virtual void AttachPhy (Ptr< UanPhy > phy)
 Attach PHY layer to this MAC. More...
 
virtual void Clear (void)
 Clears all pointer references. More...
 
virtual bool Enqueue (Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest)
 Enqueue packet to be transmitted. More...
 
virtual uint32_t GetCw (void)
 Get the contention window size. More...
 
virtual Time GetSlotTime (void)
 Get the slot time duration. More...
 
virtual void NotifyCcaEnd (void)
 Called when UanPhy stops sensing channel is busy. More...
 
virtual void NotifyCcaStart (void)
 Called when UanPhy begins sensing channel is busy. More...
 
virtual void NotifyRxEndError (void)
 Called when UanPhy finishes receiving packet in error. More...
 
virtual void NotifyRxEndOk (void)
 Called when UanPhy finishes receiving packet without error. More...
 
virtual void NotifyRxStart (void)
 Called when UanPhy begins receiving packet. More...
 
virtual void NotifyTxStart (Time duration)
 Called when transmission starts from Phy object. More...
 
virtual void SetCw (uint32_t cw)
 Set the contention window size. More...
 
virtual void SetForwardUpCb (Callback< void, Ptr< Packet >, uint16_t, const Mac8Address &> cb)
 Set the callback to forward packets up to higher layers. More...
 
virtual void SetSlotTime (Time duration)
 Set the slot time duration. More...
 
- Public Member Functions inherited from ns3::UanMac
 UanMac ()
 Default constructor. More...
 
virtual Address GetAddress (void)
 Get the MAC Address. More...
 
virtual Address GetBroadcast (void) const
 Get the broadcast address. More...
 
uint32_t GetTxModeIndex ()
 
virtual void SetAddress (Mac8Address addr)
 Set the address. More...
 
void SetTxModeIndex (uint32_t txModeIndex)
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 
- Public Member Functions inherited from ns3::UanPhyListener
virtual ~UanPhyListener ()
 Default destructor. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::UanMac
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Protected Member Functions

virtual void DoDispose ()
 Destructor implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Types

enum  State { IDLE, CCABUSY, RUNNING, TX }
 Enum defining possible Phy states. More...
 

Private Member Functions

void EndTx (void)
 End TX state. More...
 
void PhyRxPacketError (Ptr< Packet > packet, double sinr)
 Packet received at lower layer in error. More...
 
void PhyRxPacketGood (Ptr< Packet > packet, double sinr, UanTxMode mode)
 Receive packet from lower layer (passed to PHY as callback). More...
 
void SaveTimer (void)
 Cancel SendEvent and save remaining delay. More...
 
void SendPacket (void)
 Send packet on PHY. More...
 
void StartTimer (void)
 Schedule SendPacket after delay. More...
 

Private Attributes

Mac8Address m_address
 The MAC address. More...
 
bool m_cleared
 Flag when we've been cleared. More...
 
uint32_t m_cw
 Contention window size. More...
 
TracedCallback< Ptr< const Packet >, uint16_t > m_dequeueLogger
 A packet was passed down to the PHY from the MAC. More...
 
TracedCallback< Ptr< const Packet >, uint16_t > m_enqueueLogger
 A packet arrived at the MAC for transmission. More...
 
Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > m_forwardUpCb
 Forwarding up callback. More...
 
Ptr< UanPhym_phy
 PHY layer attached to this MAC. More...
 
Ptr< Packetm_pktTx
 Next packet to send. More...
 
uint16_t m_pktTxProt
 Next packet protocol number (usage varies by MAC). More...
 
Ptr< UniformRandomVariablem_rv
 Provides uniform random variable for contention window. More...
 
TracedCallback< Ptr< const Packet >, UanTxModem_rxLogger
 A packet destined for this MAC was received. More...
 
Time m_savedDelayS
 Remaining delay until next send. More...
 
EventId m_sendEvent
 Scheduled SendPacket event. More...
 
Time m_sendTime
 Time to send next packet. More...
 
Time m_slotTime
 Slot time duration. More...
 
State m_state
 Current state. More...
 
EventId m_txEndEvent
 Scheduled EndTx event. More...
 

Additional Inherited Members

Detailed Description

CW-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

Config Paths

ns3::UanMacCw is accessible through the following paths with Config::Set and Config::Connect:

Attributes

TraceSources

Size of this type is 272 bytes (on a 64-bit architecture).

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

Member Typedef Documentation

◆ QueueTracedCallback

typedef void(* ns3::UanMacCw::QueueTracedCallback) (Ptr< const Packet > packet, uint16_t proto)

TracedCallback signature for enqueue/dequeue of a packet.

Parameters
[in]packetThe Packet being received.
[in]protoThe protocol number.

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

Member Enumeration Documentation

◆ State

enum ns3::UanMacCw::State
private

Enum defining possible Phy states.

Enumerator
IDLE 

Idle state.

CCABUSY 

Channel busy.

RUNNING 

Delay timer running.

TX 

Transmitting.

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

Constructor & Destructor Documentation

◆ UanMacCw()

ns3::UanMacCw::UanMacCw ( )

Default constructor.

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

References m_rv.

◆ ~UanMacCw()

ns3::UanMacCw::~UanMacCw ( )
virtual

Dummy destructor, DoDispose.

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

Member Function Documentation

◆ AssignStreams()

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 276 of file uan-mac-cw.cc.

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

◆ AttachPhy()

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 186 of file uan-mac-cw.cc.

References m_phy, ns3::MakeCallback(), third::phy, PhyRxPacketError(), and PhyRxPacketGood().

◆ Clear()

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(), m_cleared, m_phy, m_pktTx, m_sendEvent, and m_txEndEvent.

Referenced by DoDispose().

◆ DoDispose()

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

Destructor implementation.

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

Subclasses are expected to implement their real destruction code in an overridden 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(), and ns3::Object::DoDispose().

◆ EndTx()

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

◆ Enqueue()

bool ns3::UanMacCw::Enqueue ( Ptr< Packet pkt,
uint16_t  protocolNumber,
const Address dest 
)
virtual

◆ GetCw()

uint32_t ns3::UanMacCw::GetCw ( void  )
virtual

Get the contention window size.

Returns
Contention window size.

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

References m_cw.

◆ GetSlotTime()

Time ns3::UanMacCw::GetSlotTime ( void  )
virtual

Get the slot time duration.

Returns
Slot time duration.

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

References m_slotTime.

◆ GetTypeId()

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

◆ NotifyCcaEnd()

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

Called when UanPhy stops sensing channel is busy.

Implements ns3::UanPhyListener.

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

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

◆ NotifyCcaStart()

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

Called when UanPhy begins sensing channel is busy.

Implements ns3::UanPhyListener.

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

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

◆ NotifyRxEndError()

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

Called when UanPhy finishes receiving packet in error.

Implements ns3::UanPhyListener.

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

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

◆ NotifyRxEndOk()

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

Called when UanPhy finishes receiving packet without error.

Implements ns3::UanPhyListener.

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

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

◆ NotifyRxStart()

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

Called when UanPhy begins receiving packet.

Implements ns3::UanPhyListener.

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

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

◆ NotifyTxStart()

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

Called when transmission starts from Phy object.

Parameters
durationDuration of transmission.

Implements ns3::UanPhyListener.

Definition at line 255 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().

◆ PhyRxPacketError()

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

Packet received at lower layer in error.

Parameters
packetPacket received in error.
sinrSINR of received packet.

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

References NS_UNUSED.

Referenced by AttachPhy().

◆ PhyRxPacketGood()

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

Receive packet from lower layer (passed to PHY as callback).

Parameters
packetPacket being received.
sinrSINR of received packet.
modeMode of received packet.

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

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

Referenced by AttachPhy().

◆ SaveTimer()

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

Cancel SendEvent and save remaining delay.

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

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

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

◆ SendPacket()

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

◆ SetCw()

void ns3::UanMacCw::SetCw ( uint32_t  cw)
virtual

Set the contention window size.

Parameters
cwContention window size.

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

References m_cw.

◆ SetForwardUpCb()

void ns3::UanMacCw::SetForwardUpCb ( Callback< void, Ptr< Packet >, uint16_t, const Mac8Address &>  cb)
virtual

Set the callback to forward packets up to higher layers.

Parameters
cbThe callback. packet The packet. address The source address.

Implements ns3::UanMac.

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

References m_forwardUpCb.

◆ SetSlotTime()

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

Set the slot time duration.

Parameters
durationSlot time duration.

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

References m_slotTime.

◆ StartTimer()

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

Member Data Documentation

◆ m_address

Mac8Address ns3::UanMacCw::m_address
private

The MAC address.

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

Referenced by Enqueue(), and PhyRxPacketGood().

◆ m_cleared

bool ns3::UanMacCw::m_cleared
private

Flag when we've been cleared.

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

Referenced by Clear().

◆ m_cw

uint32_t ns3::UanMacCw::m_cw
private

Contention window size.

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

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

◆ m_dequeueLogger

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

A packet was passed down to the PHY from the MAC.

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

Referenced by GetTypeId().

◆ m_enqueueLogger

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

A packet arrived at the MAC for transmission.

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

Referenced by Enqueue(), and GetTypeId().

◆ m_forwardUpCb

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

Forwarding up callback.

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

Referenced by PhyRxPacketGood(), and SetForwardUpCb().

◆ m_phy

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

PHY layer attached to this MAC.

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

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

◆ m_pktTx

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

Next packet to send.

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

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

◆ m_pktTxProt

uint16_t ns3::UanMacCw::m_pktTxProt
private

Next packet protocol number (usage varies by MAC).

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

Referenced by Enqueue(), and SendPacket().

◆ m_rv

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

Provides uniform random variable for contention window.

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

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

◆ m_rxLogger

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

A packet destined for this MAC was received.

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

Referenced by GetTypeId().

◆ m_savedDelayS

Time ns3::UanMacCw::m_savedDelayS
private

Remaining delay until next send.

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

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

◆ m_sendEvent

EventId ns3::UanMacCw::m_sendEvent
private

Scheduled SendPacket event.

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

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

◆ m_sendTime

Time ns3::UanMacCw::m_sendTime
private

Time to send next packet.

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

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

◆ m_slotTime

Time ns3::UanMacCw::m_slotTime
private

Slot time duration.

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

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

◆ m_state

State ns3::UanMacCw::m_state
private

◆ m_txEndEvent

EventId ns3::UanMacCw::m_txEndEvent
private

Scheduled EndTx event.

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

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


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