network: Move MaxSize attribute from QueueBase to derived classes

This commit is contained in:
Stefano Avallone
2020-02-17 15:34:15 +01:00
parent d1d8558d65
commit 5fc00356cf
11 changed files with 27 additions and 51 deletions

View File

@@ -72,6 +72,7 @@ method to configure a specific ack policy selector for a given Access Category.<
allows to choose between Block Ack policy and Implicit Block Ack Request policy and
allows to request an acknowledgment after a configurable number of MPDUs have been
transmitted.</li>
<li>The MaxSize attribute is removed from the QueueBase base class and moved to subclasses. A new MaxSize attribute is therefore added to the DropTailQueue class, while the MaxQueueSize attribute of the WifiMacQueue class is renamed as MaxSize for API consistency.</li>
</ul>
<h2>Changes to existing API:</h2>
<ul>

View File

@@ -68,11 +68,7 @@ There are five trace sources that may be hooked:
* ``DropBeforeEnqueue``
* ``DropAfterDequeue``
Also, the QueueBase class defines one attribute:
* ``MaxSize``: the maximum queue size
and two trace sources:
Also, the QueueBase class defines two additional trace sources:
* ``PacketsInQueue``
* ``BytesInQueue``
@@ -83,6 +79,10 @@ DropTail
This is a basic first-in-first-out (FIFO) queue that performs a tail drop
when the queue is full.
The DropTailQueue class defines one attribute:
* ``MaxSize``: the maximum queue size
Usage
*****

View File

@@ -75,6 +75,12 @@ DropTailQueue<Item>::GetTypeId (void)
.SetParent<Queue<Item> > ()
.SetGroupName ("Network")
.template AddConstructor<DropTailQueue<Item> > ()
.AddAttribute ("MaxSize",
"The max queue size",
QueueSizeValue (QueueSize ("100p")),
MakeQueueSizeAccessor (&QueueBase::SetMaxSize,
&QueueBase::GetMaxSize),
MakeQueueSizeChecker ())
;
return tid;
}

View File

@@ -36,12 +36,6 @@ QueueBase::GetTypeId (void)
static TypeId tid = TypeId ("ns3::QueueBase")
.SetParent<Object> ()
.SetGroupName ("Network")
.AddAttribute ("MaxSize",
"The max queue size",
QueueSizeValue (QueueSize ("100p")),
MakeQueueSizeAccessor (&QueueBase::SetMaxSize,
&QueueBase::GetMaxSize),
MakeQueueSizeChecker ())
.AddTraceSource ("PacketsInQueue",
"Number of packets currently stored in the queue",
MakeTraceSourceAccessor (&QueueBase::m_nPackets),
@@ -67,6 +61,7 @@ QueueBase::QueueBase () :
m_nTotalDroppedPacketsAfterDequeue (0)
{
NS_LOG_FUNCTION (this);
m_maxSize = QueueSize (QueueSizeUnit::PACKETS, std::numeric_limits<uint32_t>::max ());
}
QueueBase::~QueueBase ()

View File

@@ -55,24 +55,24 @@ main (int argc, char *argv[])
// The maximum queue size can either be enforced in bytes ('b') or
// packets ('p'). A special type called the ns3::QueueSize can
// hold queue size values in either unit (bytes or packets). The
// queue base class ns3::QueueBase has a MaxSize attribute that can
// DropTailQueue<Packet> class has a MaxSize attribute that can
// be set to a QueueSize.
// By default, the MaxSize attribute has a value of 100 packets ('100p')
// (this default can be observed in the function QueueBase::GetTypeId)
// (this default can be observed in the function DropTail<Item>::GetTypeId)
//
// Here, we set it to 80 packets. We could use one of two value types:
// a string-based value or a QueueSizeValue value
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue ("80p"));
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize", StringValue ("80p"));
// The below function call is redundant
Config::SetDefault ("ns3::QueueBase::MaxSize", QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, 80)));
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize", QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, 80)));
// Allow the user to override any of the defaults and the above
// SetDefaults() at run-time, via command-line arguments
// For example, via "--ns3::QueueBase::MaxSize=80p"
// For example, via "--ns3::DropTailQueue<Packet>::MaxSize=80p"
CommandLine cmd;
// This provides yet another way to set the value from the command line:
cmd.AddValue ("maxSize", "ns3::QueueBase::MaxSize");
cmd.AddValue ("maxSize", "ns3::DropTailQueue<Packet>::MaxSize");
cmd.Parse (argc, argv);
// Now, we will create a few objects using the low-level API

View File

@@ -308,7 +308,7 @@ Ns3TcpStateTestCase::DoRun (void)
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue ("20p"));
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize", StringValue ("20p"));
Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (false));
if (m_writeLogging)

View File

@@ -129,7 +129,7 @@ int main (int argc, char *argv[])
}
// Devices queue configuration
Config::SetDefault ("ns3::QueueBase::MaxSize",
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueSize)));
// Create gateway, source, and sink

View File

@@ -70,7 +70,7 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::MaxSize",
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, maxPackets)));
if (!modeBytes)

View File

@@ -70,7 +70,8 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue (std::to_string (maxPackets) + "p"));
Config::SetDefault ("ns3::DropTailQueue<Packet>::MaxSize",
StringValue (std::to_string (maxPackets) + "p"));
if (!modeBytes)
{

View File

@@ -39,10 +39,11 @@ WifiMacQueue::GetTypeId (void)
.SetParent<Queue<WifiMacQueueItem> > ()
.SetGroupName ("Wifi")
.AddConstructor<WifiMacQueue> ()
.AddAttribute ("MaxQueueSize",
.AddAttribute ("MaxSize",
"The max queue size",
QueueSizeValue (QueueSize ("500p")),
MakeQueueSizeAccessor (&WifiMacQueue::SetMaxQueueSize),
MakeQueueSizeAccessor (&QueueBase::SetMaxSize,
&QueueBase::GetMaxSize),
MakeQueueSizeChecker ())
.AddAttribute ("MaxDelay", "If a packet stays longer than this delay in the queue, it is dropped.",
TimeValue (MilliSeconds (500)),
@@ -73,19 +74,6 @@ WifiMacQueue::~WifiMacQueue ()
const WifiMacQueue::ConstIterator WifiMacQueue::EMPTY = std::list<Ptr<WifiMacQueueItem>> ().end ();
void
WifiMacQueue::SetMaxQueueSize (QueueSize size)
{
NS_LOG_FUNCTION (this << size);
m_maxSize = size;
}
QueueSize
WifiMacQueue::GetMaxQueueSize (void) const
{
return m_maxSize;
}
void
WifiMacQueue::SetMaxDelay (Time delay)
{
@@ -139,8 +127,6 @@ WifiMacQueue::Insert (ConstIterator pos, Ptr<WifiMacQueueItem> item)
NS_ASSERT_MSG (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS,
"WifiMacQueues must be in packet mode");
QueueBase::SetMaxSize (GetMaxQueueSize ()); //Make sure QueueBase has the same maximum queue size
// insert the item if the queue is not full
if (QueueBase::GetNPackets () < GetMaxSize ().GetValue ())
{

View File

@@ -78,18 +78,6 @@ public:
using Queue<WifiMacQueueItem>::begin;
using Queue<WifiMacQueueItem>::end;
/**
* \brief Set the maximum size of this queue
*
* Trying to set a null size has no effect.
*
* \param size the maximum size
*/
void SetMaxQueueSize (QueueSize size);
/**
* \return the maximum size of this queue
*/
QueueSize GetMaxQueueSize (void) const;
/**
* Set the maximum delay before the packet is discarded.
*
@@ -325,7 +313,6 @@ private:
*/
bool TtlExceeded (ConstIterator &it);
QueueSize m_maxSize; //!< max queue size
Time m_maxDelay; //!< Time to live for packets in the queue
DropPolicy m_dropPolicy; //!< Drop behavior of queue
mutable bool m_expiredPacketsPresent; //!< True if expired packets are in the queue