lr-wpan: beacon improvements and jitter addition
This commit is contained in:
@@ -21,10 +21,13 @@ Changes from ns-3.42 to ns-3-dev
|
||||
### Changes to existing API
|
||||
* (lr-wpan) Attribute `macBeaconPayload` in `MacPibAttributes` is now a std::vector<uint8_t> instead of a packet pointer.
|
||||
* (lr-wpan) Removes the word `address` from the MAC address prefix when `LOG_PREFIX_FUNC` is used.
|
||||
* (lr-wpan) Removes the word `address` from the CSMA-CA logs prefix when `LOG_PREFIX_FUNC` is used.
|
||||
|
||||
### Changes to build system
|
||||
|
||||
### Changed behavior
|
||||
* (lr-wpan) Beacons are now transmitted using CSMA-CA when requested from a beacon request command.
|
||||
* (lr-wpan) Upon a beacon request command, beacons are transmitted after a jitter to reduce the probability of collisions.
|
||||
|
||||
Changes from ns-3.41 to ns-3.42
|
||||
-------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@ Release 3-dev
|
||||
### Bugs fixed
|
||||
|
||||
- (lr-wpan) !2001 - Beacon improvements and fixes
|
||||
- (lr-wpan) !2042 - Beacon improvements and jitter addition
|
||||
|
||||
Release 3.42
|
||||
------------
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
|
||||
#undef NS_LOG_APPEND_CONTEXT
|
||||
#define NS_LOG_APPEND_CONTEXT \
|
||||
std::clog << "[address " << m_mac->GetShortAddress() << " | " << m_mac->GetExtendedAddress() \
|
||||
<< "] ";
|
||||
std::clog << "[" << m_mac->GetShortAddress() << " | " << m_mac->GetExtendedAddress() << "] ";
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
@@ -101,28 +100,24 @@ LrWpanCsmaCa::GetMac() const
|
||||
void
|
||||
LrWpanCsmaCa::SetSlottedCsmaCa()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
m_isSlotted = true;
|
||||
}
|
||||
|
||||
void
|
||||
LrWpanCsmaCa::SetUnSlottedCsmaCa()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
m_isSlotted = false;
|
||||
}
|
||||
|
||||
bool
|
||||
LrWpanCsmaCa::IsSlottedCsmaCa() const
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
return m_isSlotted;
|
||||
}
|
||||
|
||||
bool
|
||||
LrWpanCsmaCa::IsUnSlottedCsmaCa() const
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
return !m_isSlotted;
|
||||
}
|
||||
|
||||
@@ -234,6 +229,8 @@ LrWpanCsmaCa::Start()
|
||||
m_NB = 0;
|
||||
if (IsSlottedCsmaCa())
|
||||
{
|
||||
NS_LOG_DEBUG("Using Slotted CSMA-CA");
|
||||
|
||||
// TODO: Check if the current PHY is using the Japanese band 950 Mhz:
|
||||
// (IEEE_802_15_4_950MHZ_BPSK and IEEE_802_15_4_950MHZ_2GFSK)
|
||||
// if in use, m_CW = 1.
|
||||
@@ -264,6 +261,7 @@ LrWpanCsmaCa::Start()
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_DEBUG("Using Unslotted CSMA-CA");
|
||||
m_BE = m_macMinBE;
|
||||
m_randomBackoffEvent = Simulator::ScheduleNow(&LrWpanCsmaCa::RandomBackoffDelay, this);
|
||||
}
|
||||
|
||||
@@ -252,9 +252,9 @@ LrWpanMac::LrWpanMac()
|
||||
m_maxTxQueueSize = m_txQueue.max_size();
|
||||
m_maxIndTxQueueSize = m_indTxQueue.max_size();
|
||||
|
||||
uniformVar = CreateObject<UniformRandomVariable>();
|
||||
m_macDsn = SequenceNumber8(uniformVar->GetInteger(0, 255));
|
||||
m_macBsn = SequenceNumber8(uniformVar->GetInteger(0, 255));
|
||||
m_uniformVar = CreateObject<UniformRandomVariable>();
|
||||
m_macDsn = SequenceNumber8(m_uniformVar->GetInteger(0, 255));
|
||||
m_macBsn = SequenceNumber8(m_uniformVar->GetInteger(0, 255));
|
||||
m_macBeaconPayload = {};
|
||||
m_macBeaconPayloadLength = 0;
|
||||
m_shortAddress = Mac16Address("FF:FF"); // FF:FF = The address is not assigned.
|
||||
@@ -1049,18 +1049,28 @@ LrWpanMac::SendOneBeacon()
|
||||
|
||||
beaconPacket->AddTrailer(macTrailer);
|
||||
|
||||
// Set the Beacon packet to be transmitted
|
||||
m_txPkt = beaconPacket;
|
||||
|
||||
if (m_csmaCa->IsSlottedCsmaCa())
|
||||
{
|
||||
// Beacon in beacon-enabled mode
|
||||
// Transmit beacon immediately (i.e. Without CSMA/CA)
|
||||
m_txPkt = beaconPacket;
|
||||
m_outSuperframeStatus = BEACON;
|
||||
NS_LOG_DEBUG("Outgoing superframe Active Portion (Beacon + CAP + CFP): "
|
||||
<< m_superframeDuration << " symbols");
|
||||
}
|
||||
|
||||
ChangeMacState(MAC_SENDING);
|
||||
m_phy->PlmeSetTRXStateRequest(IEEE_802_15_4_PHY_TX_ON);
|
||||
ChangeMacState(MAC_SENDING);
|
||||
m_phy->PlmeSetTRXStateRequest(IEEE_802_15_4_PHY_TX_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Beacon as a result of a beacon request
|
||||
// The beacon shall be transmitted using CSMA/CA
|
||||
// IEEE 802.15.4-2011 (Section 5.1.2.1.2)
|
||||
Ptr<TxQueueElement> txQElement = Create<TxQueueElement>();
|
||||
txQElement->txQPkt = beaconPacket;
|
||||
EnqueueTxQElement(txQElement);
|
||||
CheckQueue();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1710,7 +1720,7 @@ LrWpanMac::BeaconSearchTimeout()
|
||||
void
|
||||
LrWpanMac::ReceiveBeacon(uint8_t lqi, Ptr<Packet> p)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
NS_LOG_FUNCTION(this << lqi << p);
|
||||
// The received beacon size in symbols
|
||||
// Beacon = Sync Header (SHR)[5 bytes] +
|
||||
// PHY header (PHR) [1 byte] +
|
||||
@@ -2322,7 +2332,17 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
|
||||
case CommandPayloadHeader::BEACON_REQ:
|
||||
if (m_csmaCa->IsUnSlottedCsmaCa() && m_coor)
|
||||
{
|
||||
SendOneBeacon();
|
||||
// Jitter = Between 0 and 2 aUnitBackoffPeriods
|
||||
// (0, 320us or 640us in 2.4Ghz O-QPSK)
|
||||
// While this jitter is not described by the standard,
|
||||
// it reduces the probability of collisions in beacons
|
||||
// transmitted as a result of a beacon request
|
||||
Time jitter =
|
||||
Seconds(static_cast<double>(m_uniformVar->GetInteger(0, 3) *
|
||||
aUnitBackoffPeriod) /
|
||||
symbolRate);
|
||||
|
||||
Simulator::Schedule((jitter), &LrWpanMac::SendOneBeacon, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2981,6 +3001,15 @@ LrWpanMac::PrintTxQueue(std::ostream& os) const
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
int64_t
|
||||
LrWpanMac::AssignStreams(int64_t stream)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
m_uniformVar->SetStream(stream);
|
||||
m_csmaCa->AssignStreams(stream);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
LrWpanMac::RemovePendTxQElement(Ptr<Packet> p)
|
||||
{
|
||||
@@ -3063,7 +3092,18 @@ LrWpanMac::PdDataConfirm(PhyEnumeration status)
|
||||
}
|
||||
|
||||
ifsWaitTime = Seconds(static_cast<double>(GetIfsSize()) / symbolRate);
|
||||
m_txPkt = nullptr;
|
||||
|
||||
if (m_csmaCa->IsSlottedCsmaCa())
|
||||
{
|
||||
// The beacon was sent immediately in beacon-enabled mode
|
||||
m_txPkt = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The beacon was sent using CSMA/CA as a result of a beacon request
|
||||
// therefore, remove it from TX Queue
|
||||
RemoveFirstTxQElement();
|
||||
}
|
||||
}
|
||||
else if (macHdr.IsAckReq()) // We have sent a regular data packet, check if we have to
|
||||
// wait for an ACK.
|
||||
|
||||
@@ -712,6 +712,15 @@ class LrWpanMac : public LrWpanMacBase
|
||||
*/
|
||||
void PrintTxQueue(std::ostream& os) const;
|
||||
|
||||
/**
|
||||
* Assign a fixed random variable stream number to the random variables
|
||||
* used by this model. Return the number of streams that have been assigned.
|
||||
*
|
||||
* \param stream first stream index to use
|
||||
* \return the number of stream indices assigned by this model
|
||||
*/
|
||||
int64_t AssignStreams(int64_t stream);
|
||||
|
||||
/**
|
||||
* TracedCallback signature for sent packets.
|
||||
*
|
||||
@@ -1335,7 +1344,7 @@ class LrWpanMac : public LrWpanMacBase
|
||||
/**
|
||||
* The uniform random variable used in this mac layer
|
||||
*/
|
||||
Ptr<UniformRandomVariable> uniformVar;
|
||||
Ptr<UniformRandomVariable> m_uniformVar;
|
||||
};
|
||||
} // namespace lrwpan
|
||||
} // namespace ns3
|
||||
|
||||
Reference in New Issue
Block a user