wifi: Move some static functions to WifiUtils
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "ctrl-headers.h"
|
||||
#include "wifi-mac-header.h"
|
||||
#include "qos-utils.h"
|
||||
#include "wifi-utils.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
#define WINSIZE_ASSERT NS_ASSERT ((m_winEnd - m_winStart + 4096) % 4096 == m_winSize - 1)
|
||||
@@ -53,7 +54,7 @@ BlockAckCache::UpdateWithMpdu (const WifiMacHeader *hdr)
|
||||
uint16_t seqNumber = hdr->GetSequenceNumber ();
|
||||
if (!QosUtilsIsOldPacket (m_winStart, seqNumber))
|
||||
{
|
||||
if (!IsInWindow (seqNumber))
|
||||
if (!IsInWindow (seqNumber, m_winStart, m_winSize))
|
||||
{
|
||||
uint16_t delta = (seqNumber - m_winEnd + 4096) % 4096;
|
||||
if (delta > 1)
|
||||
@@ -75,7 +76,7 @@ BlockAckCache::UpdateWithBlockAckReq (uint16_t startingSeq)
|
||||
NS_LOG_FUNCTION (this << startingSeq);
|
||||
if (!QosUtilsIsOldPacket (m_winStart, startingSeq))
|
||||
{
|
||||
if (IsInWindow (startingSeq))
|
||||
if (IsInWindow (startingSeq, m_winStart, m_winSize))
|
||||
{
|
||||
if (startingSeq != m_winStart)
|
||||
{
|
||||
@@ -110,13 +111,6 @@ BlockAckCache::ResetPortionOfBitmap (uint16_t start, uint16_t end)
|
||||
m_bitmap[i] = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
BlockAckCache::IsInWindow (uint16_t seq) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << seq);
|
||||
return ((seq - m_winStart + 4096) % 4096) < m_winSize;
|
||||
}
|
||||
|
||||
void
|
||||
BlockAckCache::FillBlockAckBitmap (CtrlBAckResponseHeader *blockAckHeader)
|
||||
{
|
||||
|
||||
@@ -75,12 +75,6 @@ private:
|
||||
* \param end the ending position
|
||||
*/
|
||||
void ResetPortionOfBitmap (uint16_t start, uint16_t end);
|
||||
/**
|
||||
* Is in window function
|
||||
* \param seq the sequence
|
||||
* \returns true if is in the window
|
||||
*/
|
||||
bool IsInWindow (uint16_t seq) const;
|
||||
|
||||
uint16_t m_winStart; ///< window start
|
||||
uint8_t m_winSize; ///< window size
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "snr-tag.h"
|
||||
#include "ampdu-tag.h"
|
||||
#include "wifi-mac-queue.h"
|
||||
#include "wifi-utils.h"
|
||||
|
||||
#undef NS_LOG_APPEND_CONTEXT
|
||||
#define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
|
||||
@@ -1152,44 +1153,6 @@ rxPacket:
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacLow::GetAckSize (void)
|
||||
{
|
||||
WifiMacHeader ack;
|
||||
ack.SetType (WIFI_MAC_CTL_ACK);
|
||||
return ack.GetSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacLow::GetBlockAckSize (BlockAckType type)
|
||||
{
|
||||
WifiMacHeader hdr;
|
||||
hdr.SetType (WIFI_MAC_CTL_BACKRESP);
|
||||
CtrlBAckResponseHeader blockAck;
|
||||
if (type == BASIC_BLOCK_ACK)
|
||||
{
|
||||
blockAck.SetType (BASIC_BLOCK_ACK);
|
||||
}
|
||||
else if (type == COMPRESSED_BLOCK_ACK)
|
||||
{
|
||||
blockAck.SetType (COMPRESSED_BLOCK_ACK);
|
||||
}
|
||||
else if (type == MULTI_TID_BLOCK_ACK)
|
||||
{
|
||||
//Not implemented
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
return hdr.GetSize () + blockAck.GetSerializedSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacLow::GetRtsSize (void)
|
||||
{
|
||||
WifiMacHeader rts;
|
||||
rts.SetType (WIFI_MAC_CTL_RTS);
|
||||
return rts.GetSize () + 4;
|
||||
}
|
||||
|
||||
Time
|
||||
MacLow::GetAckDuration (Mac48Address to, WifiTxVector dataTxVector) const
|
||||
{
|
||||
@@ -1228,14 +1191,6 @@ MacLow::GetCtsDuration (WifiTxVector ctsTxVector) const
|
||||
return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, m_phy->GetFrequency ());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacLow::GetCtsSize (void)
|
||||
{
|
||||
WifiMacHeader cts;
|
||||
cts.SetType (WIFI_MAC_CTL_CTS);
|
||||
return cts.GetSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacLow::GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr, bool isAmpdu)
|
||||
{
|
||||
@@ -2155,12 +2110,6 @@ MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMod
|
||||
ForwardDown (packet, &ack, ackTxVector);
|
||||
}
|
||||
|
||||
bool
|
||||
MacLow::IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize)
|
||||
{
|
||||
return ((seq - winstart + 4096) % 4096) < winsize;
|
||||
}
|
||||
|
||||
bool
|
||||
MacLow::ReceiveMpdu (Ptr<Packet> packet, WifiMacHeader hdr)
|
||||
{
|
||||
|
||||
@@ -615,31 +615,6 @@ private:
|
||||
* or switching channel.
|
||||
*/
|
||||
void CancelAllEvents (void);
|
||||
/**
|
||||
* Return the total ACK size (including FCS trailer).
|
||||
*
|
||||
* \return the total ACK size
|
||||
*/
|
||||
static uint32_t GetAckSize (void);
|
||||
/**
|
||||
* Return the total Block ACK size (including FCS trailer).
|
||||
*
|
||||
* \param type the Block ACK type
|
||||
* \return the total Block ACK size
|
||||
*/
|
||||
static uint32_t GetBlockAckSize (BlockAckType type);
|
||||
/**
|
||||
* Return the total RTS size (including FCS trailer).
|
||||
*
|
||||
* \return the total RTS size
|
||||
*/
|
||||
static uint32_t GetRtsSize (void);
|
||||
/**
|
||||
* Return the total CTS size (including FCS trailer).
|
||||
*
|
||||
* \return the total CTS size
|
||||
*/
|
||||
static uint32_t GetCtsSize (void);
|
||||
/**
|
||||
* Return the total size of the packet after WifiMacHeader and FCS trailer
|
||||
* have been added.
|
||||
@@ -960,15 +935,6 @@ private:
|
||||
* See section 9.10.4 in IEEE 802.11 standard for more details.
|
||||
*/
|
||||
void RxCompleteBufferedPacketsUntilFirstLost (Mac48Address originator, uint8_t tid);
|
||||
/**
|
||||
* \param seq MPDU sequence number
|
||||
* \param winstart sequence number window start
|
||||
* \param winsize the size of the sequence number window (currently default is 64)
|
||||
* \returns true if in the window
|
||||
*
|
||||
* This method checks if the MPDU's sequence number is inside the scoreboard boundaries or not
|
||||
*/
|
||||
static bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
|
||||
/**
|
||||
* \param packet the packet
|
||||
* \param hdr the header
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "wifi-utils.h"
|
||||
#include "wifi-mac-header.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace ns3 {
|
||||
@@ -75,4 +76,56 @@ ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Tim
|
||||
return gi;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetAckSize (void)
|
||||
{
|
||||
WifiMacHeader ack;
|
||||
ack.SetType (WIFI_MAC_CTL_ACK);
|
||||
return ack.GetSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetBlockAckSize (BlockAckType type)
|
||||
{
|
||||
WifiMacHeader hdr;
|
||||
hdr.SetType (WIFI_MAC_CTL_BACKRESP);
|
||||
CtrlBAckResponseHeader blockAck;
|
||||
if (type == BASIC_BLOCK_ACK)
|
||||
{
|
||||
blockAck.SetType (BASIC_BLOCK_ACK);
|
||||
}
|
||||
else if (type == COMPRESSED_BLOCK_ACK)
|
||||
{
|
||||
blockAck.SetType (COMPRESSED_BLOCK_ACK);
|
||||
}
|
||||
else if (type == MULTI_TID_BLOCK_ACK)
|
||||
{
|
||||
//Not implemented
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
return hdr.GetSize () + blockAck.GetSerializedSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetRtsSize (void)
|
||||
{
|
||||
WifiMacHeader rts;
|
||||
rts.SetType (WIFI_MAC_CTL_RTS);
|
||||
return rts.GetSize () + 4;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetCtsSize (void)
|
||||
{
|
||||
WifiMacHeader cts;
|
||||
cts.SetType (WIFI_MAC_CTL_CTS);
|
||||
return cts.GetSize () + 4;
|
||||
}
|
||||
|
||||
bool
|
||||
IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize)
|
||||
{
|
||||
return ((seq - winstart + 4096) % 4096) < winsize;
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -22,19 +22,20 @@
|
||||
#define WIFI_UTILS_H
|
||||
|
||||
#include "wifi-mode.h"
|
||||
#include "ctrl-headers.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* Return the logarithm of the given value to base 2.
|
||||
*
|
||||
* \param val
|
||||
*
|
||||
* \return the logarithm of val to base 2.
|
||||
*/
|
||||
double Log2 (double val);
|
||||
/**
|
||||
* Return the logarithm of the given value to base 2.
|
||||
*
|
||||
* \param val
|
||||
*
|
||||
* \return the logarithm of val to base 2.
|
||||
*/
|
||||
double Log2 (double val);
|
||||
/**
|
||||
* Convert from dBm to Watts.
|
||||
*
|
||||
@@ -77,6 +78,40 @@ double RatioToDb (double ratio);
|
||||
* \return the guard interval duration in nanoseconds
|
||||
*/
|
||||
uint16_t ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Time heGuardInterval);
|
||||
/**
|
||||
* Return the total ACK size (including FCS trailer).
|
||||
*
|
||||
* \return the total ACK size
|
||||
*/
|
||||
uint32_t GetAckSize (void);
|
||||
/**
|
||||
* Return the total Block ACK size (including FCS trailer).
|
||||
*
|
||||
* \param type the Block ACK type
|
||||
* \return the total Block ACK size
|
||||
*/
|
||||
uint32_t GetBlockAckSize (BlockAckType type);
|
||||
/**
|
||||
* Return the total RTS size (including FCS trailer).
|
||||
*
|
||||
* \return the total RTS size
|
||||
*/
|
||||
uint32_t GetRtsSize (void);
|
||||
/**
|
||||
* Return the total CTS size (including FCS trailer).
|
||||
*
|
||||
* \return the total CTS size
|
||||
*/
|
||||
uint32_t GetCtsSize (void);
|
||||
/**
|
||||
* \param seq MPDU sequence number
|
||||
* \param winstart sequence number window start
|
||||
* \param winsize the size of the sequence number window (currently default is 64)
|
||||
* \returns true if in the window
|
||||
*
|
||||
* This method checks if the MPDU's sequence number is inside the scoreboard boundaries or not
|
||||
*/
|
||||
bool IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user