|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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"
45 m_rv = CreateObject<UniformRandomVariable> ();
85 "The MAC parameter CW.",
88 MakeUintegerChecker<uint32_t> ())
89 .AddAttribute (
"SlotTime",
90 "Time slot duration for MAC backoff.",
94 .AddTraceSource (
"Enqueue",
95 "A packet arrived at the MAC for transmission.",
97 "ns3::UanMacCw::QueueTracedCallback")
98 .AddTraceSource (
"Dequeue",
99 "A was passed down to the PHY from the MAC.",
101 "ns3::UanMacCw::QueueTracedCallback")
102 .AddTraceSource (
"RX",
103 "A packet was destined for this MAC and was received.",
105 "ns3::UanMac::PacketModeTracedCallback")
128 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () >= 1 ||
m_phy->IsStateTx ());
132 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !
m_phy->IsStateTx ());
148 if (
m_phy->IsStateBusy ())
157 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () >= 1 ||
m_phy->IsStateTx ());
163 NS_ASSERT (
m_phy->GetTransducer ()->GetArrivalList ().size () == 0 && !
m_phy->IsStateTx ());
192 m_phy->RegisterListener (
this);
296 if (
m_phy->IsStateIdle ())
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_cleared
Flag when we've been cleared.
A class used for addressing MAC8 MAC's.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SaveTimer(void)
Cancel SendEvent and save remaining delay.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t m_cw
Contention window size.
void AddHeader(const Header &header)
Add header to this packet.
void SendPacket(void)
Send packet on PHY.
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void AttachPhy(Ptr< UanPhy > phy)
Attach PHY layer to this MAC.
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet destined for this MAC was received.
uint16_t m_pktTxProt
Next packet protocol number (usage varies by MAC).
void StartTimer(void)
Schedule SendPacket after delay.
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > cb)
Set the callback to forward packets up to higher layers.
virtual void NotifyRxEndOk(void)
Called when UanPhy finishes receiving packet without error.
UanMacCw()
Default constructor.
static TypeId GetTypeId(void)
Register this type.
virtual void DoDispose()
Destructor implementation.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
virtual void NotifyCcaEnd(void)
Called when UanPhy stops sensing channel is busy.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
TracedCallback< Ptr< const Packet >, uint16_t > m_enqueueLogger
A packet arrived at the MAC for transmission.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< UniformRandomVariable > m_rv
Provides uniform random variable for contention window.
State m_state
Current state.
virtual void NotifyTxStart(Time duration)
Called when transmission starts from Phy object.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Time m_slotTime
Slot time duration.
@ IDLE
Channel is IDLE, no packet is being transmitted.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
a polymophic address class
EventId m_sendEvent
Scheduled SendPacket event.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
virtual Address GetAddress(void)
Get the MAC Address.
Ptr< Packet > m_pktTx
Next packet to send.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
#define NS_UNUSED(x)
Mark a local variable as unused.
virtual bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest)
Enqueue packet to be transmitted.
bool m_txOngoing
Tx is ongoing.
virtual void NotifyRxEndError(void)
Called when UanPhy finishes receiving packet in error.
Simulation virtual time values and global simulation resolution.
Abstraction of packet modulation information.
Time m_sendTime
Time to send next packet.
void PhyRxPacketGood(Ptr< Packet > packet, double sinr, UanTxMode mode)
Receive packet from lower layer (passed to PHY as callback).
@ RUNNING
Delay timer running.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void EndTx(void)
End TX state.
virtual uint32_t GetCw(void)
Get the contention window size.
virtual void NotifyRxStart(void)
Called when UanPhy begins receiving packet.
virtual void NotifyCcaStart(void)
Called when UanPhy begins sensing channel is busy.
Time m_savedDelayS
Remaining delay until next send.
CW-MAC protocol, similar in idea to the 802.11 DCF with constant backoff window.
virtual void Clear(void)
Clears all pointer references.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Virtual base class for all UAN MAC protocols.
Time Seconds(double value)
Construct a Time in the indicated unit.
Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > m_forwardUpCb
Forwarding up callback.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static Mac8Address GetBroadcast(void)
Get the broadcast address (255).
virtual void SetSlotTime(Time duration)
Set the slot time duration.
TracedCallback< Ptr< const Packet >, uint16_t > m_dequeueLogger
A packet was passed down to the PHY from the MAC.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
void PhyRxPacketError(Ptr< Packet > packet, double sinr)
Packet received at lower layer in error.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual void NotifyTxEnd(void)
Function called when Phy object finishes transmitting packet.
uint32_t GetTxModeIndex()
Get the Tx mode index (Modulation type).
virtual ~UanMacCw()
Dummy destructor, DoDispose.
virtual Time GetSlotTime(void)
Get the slot time duration.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual void SetCw(uint32_t cw)
Set the contention window size.