29 #include "ns3/nstime.h"
30 #include "ns3/simulator.h"
31 #include "ns3/assert.h"
32 #include "ns3/double.h"
33 #include "ns3/uinteger.h"
55 : m_frameNo (frameNo),
59 uint32_t numPkts = (maxPkts) ? maxPkts :
list.size ();
64 for (uint32_t i = 0; i < numPkts; i++)
66 length +=
list.front ().first->GetSize () +
77 std::list<std::pair <Ptr<Packet>,
UanAddress > >::iterator it;
97 const std::list<std::pair <Ptr<Packet>,
UanAddress > > &
155 m_state (UNASSOCIATED),
156 m_rtsBlocked (false),
161 m_ev = CreateObject<ExponentialRandomVariable> ();
188 std::list<std::pair <Ptr<Packet>,
UanAddress > >::iterator it;
211 .AddConstructor<UanMacRc> ()
212 .AddAttribute (
"RetryRate",
213 "Number of retry attempts per second (of RTS/GWPING)",
216 MakeDoubleChecker<double> ())
217 .AddAttribute (
"MaxFrames",
218 "Maximum number of frames to include in a single RTS",
221 MakeUintegerChecker<uint32_t> ())
222 .AddAttribute (
"QueueLimit",
223 "Maximum packets to queue at MAC",
226 MakeUintegerChecker<uint32_t> ())
227 .AddAttribute (
"SIFS",
228 "Spacing to give between frames (this should match gateway)",
232 .AddAttribute (
"NumberOfRates",
233 "Number of rate divisions supported by each PHY",
236 MakeUintegerChecker<uint32_t> ())
237 .AddAttribute (
"MinRetryRate",
238 "Smallest allowed RTS retry rate",
241 MakeDoubleChecker<double> ())
242 .AddAttribute (
"RetryStep",
243 "Retry rate increment",
246 MakeDoubleChecker<double> ())
247 .AddAttribute (
"MaxPropDelay",
248 "Maximum possible propagation delay to gateway",
252 .AddTraceSource (
"Enqueue",
253 "A (data) packet arrived at MAC for transmission",
255 .AddTraceSource (
"Dequeue",
256 "A (data) packet was passed down to PHY from MAC",
258 .AddTraceSource (
"RX",
259 "A packet was destined for and received at this MAC layer",
288 if (protocolNumber > 0)
290 NS_LOG_WARN (
"Warning: UanMacRc does not support multiple protocols. protocolNumber argument to Enqueue is being ignored");
438 std::list<Reservation>::iterator it =
m_resList.begin ();
452 it->SetTransmitted ();
464 Time frameDelay = Seconds (0);
466 const std::list<std::pair <Ptr<Packet>,
UanAddress > > l = it->GetPktList ();
467 std::list<std::pair <Ptr<Packet>,
UanAddress > >::const_iterator pit;
472 for (uint32_t i = 0; i < it->GetNoFrames (); i++, pit++)
487 Time eventTime = startDelay + frameDelay;
492 eventTime = Seconds (0);
496 NS_FATAL_ERROR (
"Scheduling error resulted in very negative data transmission time! eventTime = " << eventTime.
GetSeconds ());
499 NS_LOG_DEBUG (Simulator::Now ().GetSeconds () <<
" Node " <<
m_address <<
" scheduling with delay " << eventTime.
GetSeconds () <<
" propDelay " << m_learnedProp.GetSeconds () <<
" start delay " << startDelay.
GetSeconds () <<
" arrival time " << arrTime.
GetSeconds ());
501 frameDelay = frameDelay +
m_sifs + Seconds (pkt->
GetSize () / currentBps);
549 m_phy->SendPacket (pkt, rate);
558 std::list<Reservation>::iterator it =
m_resList.begin ();
568 NS_LOG_DEBUG (
"In " << __func__ <<
" could not find reservation corresponding to received ACK");
571 if (!it->IsTransmitted ())
577 const std::list<std::pair <Ptr<Packet>,
UanAddress > > l = it->GetPktList ();
578 std::list<std::pair <Ptr<Packet>,
UanAddress > >::const_iterator pit;
582 std::set<uint8_t>::iterator nit = nacks.begin ();
584 for (; nit != nacks.end (); nit++)
660 res.IncrementRetry ();
714 if (phyDual->IsPhy1Rx ())
756 res.IncrementRetry ();
uint32_t RemoveHeader(Header &header)
keep track of time values and allow control of global simulation resolution
void ReceiveOkFromPhy(Ptr< Packet >, double sinr, UanTxMode mode)
#define NS_LOG_FUNCTION(parameters)
NS_LOG_COMPONENT_DEFINE("UanMacRc")
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
void AddTimestamp(Time t)
#define NS_ASSERT(condition)
uint32_t GetSize(void) const
virtual void DoDispose(void)
bool IsRunning(void) const
virtual Address GetAddress(void)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
void ProcessAck(Ptr< Packet > ack)
#define NS_FATAL_ERROR(msg)
fatal error handling
a polymophic address class
virtual Address GetBroadcast(void) const
uint32_t GetNoFrames() const
void SetTransmitted(bool t=true)
Sets reservation transmitted state.
TracedCallback< Ptr< const Packet >, uint16_t > m_dequeueLogger
double GetSeconds(void) const
Virtual base class for all UAN MAC protocols.
Reservation()
Create empty object with default values.
std::vector< Time > m_timestamp
uint8_t GetRetryNo() const
hold objects of type ns3::Time
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, const UanAddress & > cb)
static UanAddress ConvertFrom(const Address &address)
Hold an unsigned integer type.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
Abstraction of packet modulation information.
bool IsTransmitted() const
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ptr< ExponentialRandomVariable > m_ev
Provides exponential random variables.
std::list< std::pair< Ptr< Packet >, UanAddress > > m_pktQueue
static uint32_t m_cntrlSends
static UanAddress GetBroadcast(void)
void AssociateTimeout(void)
void SetFrameNo(uint8_t fn)
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
static TypeId GetTypeId(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
const std::list< std::pair< Ptr< Packet >, UanAddress > > & GetPktList(void) const
int64_t AssignStreams(int64_t stream)
TracedCallback< Ptr< const Packet >, uint16_t > m_enqueueLogger
std::list< Reservation > m_resList
virtual void SetAddress(UanAddress addr)
virtual void AttachPhy(Ptr< UanPhy > phy)
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
uint32_t GetLength() const
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
#define NS_LOG_DEBUG(msg)
Stores reservation info for use in scheduling data channel by reservation channel MAC...
uint8_t GetFrameNo() const
double GetValue(double mean, double bound)
Returns a random double from an exponential distribution with the specified mean and upper bound...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
std::list< std::pair< Ptr< Packet >, UanAddress > > m_pktList
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void IncrementRetry()
Increments retry count by 1.
Callback< void, Ptr< Packet >, const UanAddress & > m_forwardUpCb
void AddHeader(const Header &header)
Time GetTimestamp(uint8_t n) const
virtual bool Enqueue(Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)