22 #include "ns3/attribute.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/double.h"
25 #include "ns3/nstime.h"
26 #include "ns3/uan-header-common.h"
27 #include "ns3/trace-source-accessor.h"
44 m_rv = CreateObject<UniformRandomVariable> ();
81 .AddConstructor<UanMacCw> ()
83 "The MAC parameter CW",
86 MakeUintegerChecker<uint32_t> ())
87 .AddAttribute (
"SlotTime",
88 "Time slot duration for MAC backoff",
92 .AddTraceSource (
"Enqueue",
93 "A packet arrived at the MAC for transmission",
95 .AddTraceSource (
"Dequeue",
96 "A was passed down to the PHY from the MAC",
98 .AddTraceSource (
"RX",
99 "A packet was destined for this MAC and was received",
135 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () >= 1 ||
m_phy->IsStateTx ());
139 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !
m_phy->IsStateTx ());
154 if (
m_phy->IsStateBusy ())
162 NS_LOG_DEBUG (
"Time " <<
Simulator::Now ().GetSeconds () <<
": Addr " <<
GetAddress () <<
": Enqueuing new packet while busy: (Chose CW " << cw <<
", Sending at " << m_sendTime.GetSeconds () <<
" Packet size: " << packet->
GetSize ());
163 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () >= 1 ||
m_phy->IsStateTx ());
169 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !
m_phy->IsStateTx ());
171 m_phy->SendPacket (packet,protocolNumber);
198 m_phy->RegisterListener (
this);
307 if (
m_phy->IsStateIdle ())
uint32_t RemoveHeader(Header &header)
keep track of time values and allow control of global simulation resolution
virtual Address GetAddress()
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
#define NS_ASSERT(condition)
static TypeId GetTypeId(void)
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
virtual void SetSlotTime(Time duration)
virtual void DoDispose(void)
virtual void AttachPhy(Ptr< UanPhy > phy)
TracedCallback< Ptr< const Packet >, uint16_t > m_enqueueLogger
static void Cancel(const EventId &id)
bool IsRunning(void) const
virtual Address GetBroadcast(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
virtual void NotifyRxEndError(void)
Function called by UanPhy object to notify of packet received in error.
#define NS_FATAL_ERROR(msg)
fatal error handling
a polymophic address class
virtual void SetAddress(UanAddress addr)
virtual bool Enqueue(Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)
double GetSeconds(void) const
Virtual base class for all UAN MAC protocols.
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
hold objects of type ns3::Time
static UanAddress ConvertFrom(const Address &address)
Hold an unsigned integer type.
virtual void SetCw(uint32_t cw)
virtual void NotifyRxStart(void)
Function called by UanPhy object to notify of packet reception.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
Abstraction of packet modulation information.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ptr< UniformRandomVariable > m_rv
Provides uniform random variables.
Callback< void, Ptr< Packet >, const UanAddress & > m_forwardUpCb
virtual void NotifyRxEndOk(void)
Function called by UanPhy object to notify of packet received successfully.
static UanAddress GetBroadcast(void)
virtual void NotifyCcaStart(void)
Function called by UanPhy object to notify of channel sensed busy.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual Time GetSlotTime(void)
virtual void NotifyTxStart(Time duration)
Function called by UanPhy object to notify of outgoing transmission start.
virtual uint32_t GetCw(void)
#define NS_LOG_DEBUG(msg)
int64_t AssignStreams(int64_t stream)
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, const UanAddress & > cb)
void PhyRxPacketGood(Ptr< Packet > packet, double sinr, UanTxMode mode)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
a base class which provides memory management and object aggregation
TracedCallback< Ptr< const Packet >, uint16_t > m_dequeueLogger
void PhyRxPacketError(Ptr< Packet > packet, double sinr)
a unique identifier for an interface.
virtual void NotifyCcaEnd(void)
Function called by UanPhy object to notify of channel no longer sensed busy.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)