CW-MAC protocol, similar in idea to the 802.11 DCF with constant backoff window. More...
#include "uan-mac-cw.h"
Public Types | |
typedef void(* | QueueTracedCallback) (Ptr< const Packet > packet, uint16_t proto) |
TracedCallback signature for enqueue/dequeue of a packet. More... | |
![]() | |
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, const Address &dest, uint16_t protocolNumber) |
Enqueue packet to be transmitted. More... | |
virtual Address | GetAddress () |
Get the MAC Address. More... | |
virtual Address | GetBroadcast (void) const |
Get the broadcast address. 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 | SetAddress (UanAddress addr) |
Set the address. More... | |
virtual void | SetCw (uint32_t cw) |
Set the contention window size. More... | |
virtual void | SetForwardUpCb (Callback< void, Ptr< Packet >, const UanAddress & > cb) |
Set the callback to forward packets up to higher layers. More... | |
virtual void | SetSlotTime (Time duration) |
Set the slot time duration. More... | |
![]() | |
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 |
Implement the GetInstanceTypeId method defined in ObjectBase. 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... | |
![]() | |
SimpleRefCount () | |
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. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
![]() | |
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... | |
![]() | |
virtual | ~UanPhyListener () |
Default destructor. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static void | Cleanup (void) |
Noop. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
virtual void | DoDispose () |
Destructor implementation. More... | |
![]() | |
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... | |
![]() | |
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 | |
UanAddress | 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 >, const UanAddress & > | m_forwardUpCb |
Forwarding up callback. More... | |
Ptr< UanPhy > | m_phy |
PHY layer attached to this MAC. More... | |
Ptr< Packet > | m_pktTx |
Next packet to send. More... | |
uint16_t | m_pktTxProt |
Next packet protocol number (usage varies by MAC). More... | |
Ptr< UniformRandomVariable > | m_rv |
Provides uniform random variable for contention window. More... | |
TracedCallback< Ptr< const Packet >, UanTxMode > | m_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 | |
![]() | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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
ns3::UanMacCw is accessible through the following paths with Config::Set and Config::Connect:
Size of this type is 232 bytes (on a 64-bit architecture).
Definition at line 46 of file uan-mac-cw.h.
TracedCallback signature for enqueue/dequeue of a packet.
[in] | packet | The Packet being received. |
[in] | proto | The protocol number. |
Definition at line 110 of file uan-mac-cw.h.
ns3::UanMacCw::UanMacCw | ( | ) |
|
virtual |
Dummy destructor, DoDispose.
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 294 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 197 of file uan-mac-cw.cc.
References m_phy, ns3::MakeCallback(), third::phy, PhyRxPacketError(), and PhyRxPacketGood().
|
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().
|
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 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(), and ns3::Object::DoDispose().
|
private |
End TX state.
Definition at line 302 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), IDLE, 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 number. Usage varies by MAC. |
Implements ns3::UanMac.
Definition at line 123 of file uan-mac-cw.cc.
References ns3::Packet::AddHeader(), CCABUSY, ns3::UanAddress::ConvertFrom(), GetAddress(), ns3::Time::GetSeconds(), ns3::Packet::GetSize(), ns3::UniformRandomVariable::GetValue(), IDLE, ns3::EventId::IsRunning(), 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::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, RUNNING, ns3::Seconds(), ns3::UanHeaderCommon::SetDest(), ns3::UanHeaderCommon::SetSrc(), ns3::UanHeaderCommon::SetType(), and TX.
|
virtual |
Get the MAC Address.
Implements ns3::UanMac.
Definition at line 111 of file uan-mac-cw.cc.
References m_address.
Referenced by EndTx(), Enqueue(), NotifyCcaEnd(), NotifyCcaStart(), NotifyRxEndError(), NotifyRxEndOk(), NotifyRxStart(), SaveTimer(), SendPacket(), and StartTimer().
|
virtual |
Get the broadcast address.
Implements ns3::UanMac.
Definition at line 206 of file uan-mac-cw.cc.
References ns3::UanAddress::GetBroadcast().
|
virtual |
Get the contention window size.
Definition at line 334 of file uan-mac-cw.cc.
References m_cw.
|
virtual |
Get the slot time duration.
Definition at line 339 of file uan-mac-cw.cc.
References m_slotTime.
|
static |
Register this type.
Definition at line 77 of file uan-mac-cw.cc.
References m_cw, m_dequeueLogger, m_enqueueLogger, m_rxLogger, m_slotTime, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MilliSeconds(), and ns3::TypeId::SetParent().
|
virtual |
Called when UanPhy stops sensing channel is busy.
Implements ns3::UanPhyListener.
Definition at line 261 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().
|
virtual |
Called when UanPhy begins sensing channel is busy.
Implements ns3::UanPhyListener.
Definition at line 249 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and SaveTimer().
|
virtual |
Called when UanPhy finishes receiving packet in error.
Implements ns3::UanPhyListener.
Definition at line 237 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), m_phy, m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().
|
virtual |
Called when UanPhy finishes receiving packet without error.
Implements ns3::UanPhyListener.
Definition at line 225 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), m_phy, m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and StartTimer().
|
virtual |
Called when UanPhy begins receiving packet.
Implements ns3::UanPhyListener.
Definition at line 213 of file uan-mac-cw.cc.
References CCABUSY, GetAddress(), m_state, ns3::Simulator::Now(), NS_LOG_DEBUG, RUNNING, and SaveTimer().
|
virtual |
Called when transmission starts from Phy object.
duration | Duration of transmission. |
Implements ns3::UanPhyListener.
Definition at line 273 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().
Packet received at lower layer in error.
packet | Packet received in error. |
sinr | SINR of received packet. |
Definition at line 355 of file uan-mac-cw.cc.
Referenced by AttachPhy().
Receive packet from lower layer (passed to PHY as callback).
packet | Packet being received. |
sinr | SINR of received packet. |
mode | Mode of received packet. |
Definition at line 344 of file uan-mac-cw.cc.
References ns3::UanAddress::GetBroadcast(), ns3::UanHeaderCommon::GetDest(), ns3::UanHeaderCommon::GetSrc(), m_address, m_forwardUpCb, and ns3::Packet::RemoveHeader().
Referenced by AttachPhy().
|
private |
Cancel SendEvent and save remaining delay.
Definition at line 360 of file uan-mac-cw.cc.
References ns3::Simulator::Cancel(), GetAddress(), m_pktTx, m_savedDelayS, m_sendEvent, m_sendTime, ns3::Simulator::Now(), NS_ASSERT, and NS_LOG_DEBUG.
Referenced by NotifyCcaStart(), NotifyRxStart(), and NotifyTxStart().
|
private |
Send packet on PHY.
Definition at line 387 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(), and TX.
Referenced by StartTimer().
|
virtual |
Set the address.
addr | UanAddress for this MAC. |
Implements ns3::UanMac.
Definition at line 117 of file uan-mac-cw.cc.
References m_address.
|
virtual |
Set the contention window size.
cw | Contention window size. |
Definition at line 324 of file uan-mac-cw.cc.
References m_cw.
|
virtual |
Set the callback to forward packets up to higher layers.
cb | The callback. packet The packet. address The source address. |
Implements ns3::UanMac.
Definition at line 191 of file uan-mac-cw.cc.
References m_forwardUpCb.
|
virtual |
Set the slot time duration.
duration | Slot time duration. |
Definition at line 329 of file uan-mac-cw.cc.
References m_slotTime.
|
private |
Schedule SendPacket after delay.
Definition at line 371 of file uan-mac-cw.cc.
References GetAddress(), ns3::Time::GetSeconds(), m_savedDelayS, m_sendEvent, m_sendTime, ns3::Simulator::Now(), NS_LOG_DEBUG, ns3::Simulator::Schedule(), and SendPacket().
Referenced by EndTx(), NotifyCcaEnd(), NotifyRxEndError(), and NotifyRxEndOk().
|
private |
The MAC address.
Definition at line 124 of file uan-mac-cw.h.
Referenced by Enqueue(), GetAddress(), PhyRxPacketGood(), and SetAddress().
|
private |
|
private |
Contention window size.
Definition at line 135 of file uan-mac-cw.h.
Referenced by Enqueue(), GetCw(), GetTypeId(), and SetCw().
|
private |
A packet was passed down to the PHY from the MAC.
Definition at line 132 of file uan-mac-cw.h.
Referenced by GetTypeId().
|
private |
A packet arrived at the MAC for transmission.
Definition at line 130 of file uan-mac-cw.h.
Referenced by Enqueue(), and GetTypeId().
|
private |
Forwarding up callback.
Definition at line 122 of file uan-mac-cw.h.
Referenced by PhyRxPacketGood(), and SetForwardUpCb().
PHY layer attached to this MAC.
Definition at line 126 of file uan-mac-cw.h.
Referenced by AttachPhy(), Clear(), EndTx(), Enqueue(), NotifyRxEndError(), NotifyRxEndOk(), and SendPacket().
Next packet to send.
Definition at line 144 of file uan-mac-cw.h.
Referenced by Clear(), Enqueue(), SaveTimer(), and SendPacket().
|
private |
Next packet protocol number (usage varies by MAC).
Definition at line 146 of file uan-mac-cw.h.
Referenced by Enqueue(), and SendPacket().
|
private |
Provides uniform random variable for contention window.
Definition at line 158 of file uan-mac-cw.h.
Referenced by AssignStreams(), Enqueue(), and UanMacCw().
|
private |
A packet destined for this MAC was received.
Definition at line 128 of file uan-mac-cw.h.
Referenced by GetTypeId().
|
private |
Remaining delay until next send.
Definition at line 142 of file uan-mac-cw.h.
Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().
|
private |
Scheduled SendPacket event.
Definition at line 148 of file uan-mac-cw.h.
Referenced by Clear(), SaveTimer(), and StartTimer().
|
private |
Time to send next packet.
Definition at line 140 of file uan-mac-cw.h.
Referenced by Enqueue(), SaveTimer(), SendPacket(), and StartTimer().
|
private |
Slot time duration.
Definition at line 136 of file uan-mac-cw.h.
Referenced by Enqueue(), GetSlotTime(), GetTypeId(), and SetSlotTime().
|
private |
Current state.
Definition at line 152 of file uan-mac-cw.h.
Referenced by EndTx(), Enqueue(), NotifyCcaEnd(), NotifyCcaStart(), NotifyRxEndError(), NotifyRxEndOk(), NotifyRxStart(), NotifyTxStart(), and SendPacket().
|
private |
Scheduled EndTx event.
Definition at line 150 of file uan-mac-cw.h.
Referenced by Clear(), Enqueue(), and NotifyTxStart().