traffic-control: Convert tests and examples to using MaxSize

This commit is contained in:
Stefano Avallone
2018-03-03 10:54:45 +01:00
parent 998151ede3
commit 8d5e9bb5c6
21 changed files with 228 additions and 387 deletions

View File

@@ -72,6 +72,7 @@ us a note on ns-developers mailing list.</p>
<li>The Mode, MaxPackets and MaxBytes attributes of the Queue class have been deprecated in favor of the
MaxSize attribute. Old attributes can still be used, but using them will be no longer possible in one of the next releases. The methods to get/set the old attributes will be removed as well.</li>
<li>The attributes of the QueueDisc subclasses that separately determine the mode and the limit of the QueueDisc have been deprecated in favor of the single MaxSize attribute.</li>
<li>The GetQueueSize method of some QueueDisc subclasses (e.g., Red) has been removed and replaced by the GetCurrentSize method of the QueueDisc base class.</li>
</ul>
<hr>

View File

@@ -145,40 +145,42 @@ int main (int argc, char *argv[])
// Access link traffic control configuration
TrafficControlHelper tchPfifoFastAccess;
tchPfifoFastAccess.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "Limit", UintegerValue (1000));
tchPfifoFastAccess.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize", StringValue ("1000p"));
// Bottleneck link traffic control configuration
TrafficControlHelper tchBottleneck;
if (queueDiscType.compare ("PfifoFast") == 0)
{
tchBottleneck.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "Limit", UintegerValue (queueDiscSize));
tchBottleneck.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("ARED") == 0)
{
tchBottleneck.SetRootQueueDisc ("ns3::RedQueueDisc");
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::Mode", EnumValue (RedQueueDisc::QUEUE_DISC_MODE_PACKETS));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("CoDel") == 0)
{
tchBottleneck.SetRootQueueDisc ("ns3::CoDelQueueDisc");
Config::SetDefault ("ns3::CoDelQueueDisc::Mode", EnumValue (CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxPackets", UintegerValue (queueDiscSize));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else if (queueDiscType.compare ("FqCoDel") == 0)
{
uint32_t handle = tchBottleneck.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
Config::SetDefault ("ns3::FqCoDelQueueDisc::PacketLimit", UintegerValue (queueDiscSize));
Config::SetDefault ("ns3::FqCoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
tchBottleneck.AddPacketFilter (handle, "ns3::FqCoDelIpv4PacketFilter");
tchBottleneck.AddPacketFilter (handle, "ns3::FqCoDelIpv6PacketFilter");
}
else if (queueDiscType.compare ("PIE") == 0)
{
tchBottleneck.SetRootQueueDisc ("ns3::PieQueueDisc");
Config::SetDefault ("ns3::PieQueueDisc::Mode", EnumValue (PieQueueDisc::QUEUE_DISC_MODE_PACKETS));
Config::SetDefault ("ns3::PieQueueDisc::QueueLimit", UintegerValue (queueDiscSize));
Config::SetDefault ("ns3::PieQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
}
else
{
@@ -190,8 +192,7 @@ int main (int argc, char *argv[])
tchBottleneck.SetQueueLimits ("ns3::DynamicQueueLimits");
}
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (100));
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue ("100p"));
NetDeviceContainer devicesAccessLink = accessLink.Install (n1.Get (0), n2.Get (0));
tchPfifoFastAccess.Install (devicesAccessLink);
@@ -200,7 +201,7 @@ int main (int argc, char *argv[])
address.NewNetwork ();
Ipv4InterfaceContainer interfacesAccess = address.Assign (devicesAccessLink);
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (netdevicesQueueSize));
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue (std::to_string (netdevicesQueueSize) + "p"));
NetDeviceContainer devicesBottleneckLink = bottleneckLink.Install (n2.Get (0), n3.Get (0));
QueueDiscContainer qdiscs;

View File

@@ -70,18 +70,18 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (maxPackets));
Config::SetDefault ("ns3::QueueBase::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, maxPackets)));
if (!modeBytes)
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscLimitPackets)));
}
else
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_BYTES"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets * pktSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::BYTES, queueDiscLimitPackets * pktSize)));
minTh *= pktSize;
maxTh *= pktSize;
}

View File

@@ -72,18 +72,18 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (maxPackets));
Config::SetDefault ("ns3::QueueBase::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, maxPackets)));
if (!modeBytes)
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscLimitPackets)));
}
else
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_BYTES"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets * pktSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::BYTES, queueDiscLimitPackets * pktSize)));
minTh *= pktSize;
maxTh *= pktSize;
}

View File

@@ -110,7 +110,7 @@ main (int argc, char *argv[])
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
pointToPoint.SetQueue ("ns3::DropTailQueue", "Mode", StringValue ("QUEUE_MODE_PACKETS"), "MaxPackets", UintegerValue (1));
pointToPoint.SetQueue ("ns3::DropTailQueue", "MaxSize", StringValue ("1p"));
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);

View File

@@ -31,7 +31,7 @@
#include "ns3/ipv6-queue-disc-item.h"
#include "ns3/tcp-header.h"
#include "ns3/udp-header.h"
#include "ns3/uinteger.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
using namespace ns3;
@@ -62,7 +62,7 @@ void
FqCoDelQueueDiscNoSuitableFilter::DoRun (void)
{
// Packets that cannot be classified by the available filters should be dropped
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("PacketLimit", UintegerValue (4));
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("4p"));
Ptr<FqCoDelIpv4PacketFilter> filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (filter);
@@ -121,7 +121,7 @@ FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::AddPacket (Ptr<FqCoDelQueueDisc
void
FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("PacketLimit", UintegerValue (4));
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("4p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
@@ -341,7 +341,7 @@ FqCoDelQueueDiscTCPFlowsSeparation::AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4
void
FqCoDelQueueDiscTCPFlowsSeparation::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("PacketLimit", UintegerValue (10));
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("10p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
@@ -431,7 +431,7 @@ FqCoDelQueueDiscUDPFlowsSeparation::AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4
void
FqCoDelQueueDiscUDPFlowsSeparation::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("PacketLimit", UintegerValue (10));
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("10p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);

View File

@@ -24,7 +24,7 @@
#include "ns3/ipv4-queue-disc-item.h"
#include "ns3/ipv6-queue-disc-item.h"
#include "ns3/enum.h"
#include "ns3/uinteger.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
#include "ns3/object-factory.h"
#include "ns3/socket.h"
@@ -80,7 +80,7 @@ PfifoFastQueueDiscTosPrioritization::DoRun (void)
for (uint16_t i = 0; i < 3; i++)
{
Ptr<DropTailQueue<QueueDiscItem> > queue = CreateObject<DropTailQueue<QueueDiscItem> > ();
bool ok = queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (1000));
bool ok = queue->SetAttributeFailSafe ("MaxSize", StringValue ("1000p"));
NS_TEST_ASSERT_MSG_EQ (ok, true, "unable to set attribute");
queueDisc->AddInternalQueue (queue);
}
@@ -157,7 +157,7 @@ PfifoFastQueueDiscDscpPrioritization::DoRun (void)
for (uint16_t i = 0; i < 3; i++)
{
Ptr<DropTailQueue<QueueDiscItem> > queue = CreateObject<DropTailQueue<QueueDiscItem> > ();
bool ok = queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (1000));
bool ok = queue->SetAttributeFailSafe ("MaxSize", StringValue ("1000p"));
NS_TEST_ASSERT_MSG_EQ (ok, true, "unable to set attribute");
queueDisc->AddInternalQueue (queue);
}
@@ -232,10 +232,10 @@ PfifoFastQueueDiscOverflow::AddPacket (Ptr<PfifoFastQueueDisc> queue, Ipv4Header
void
PfifoFastQueueDiscOverflow::DoRun (void)
{
Ptr<PfifoFastQueueDisc> queueDisc = CreateObjectWithAttributes<PfifoFastQueueDisc> ("Limit", UintegerValue (6));
Ptr<DropTailQueue<QueueDiscItem> > band0 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxPackets", UintegerValue (6));
Ptr<DropTailQueue<QueueDiscItem> > band1 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxPackets", UintegerValue (6));
Ptr<DropTailQueue<QueueDiscItem> > band2 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxPackets", UintegerValue (6));
Ptr<PfifoFastQueueDisc> queueDisc = CreateObjectWithAttributes<PfifoFastQueueDisc> ("MaxSize", StringValue ("6p"));
Ptr<DropTailQueue<QueueDiscItem> > band0 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxSize", StringValue ("6p"));
Ptr<DropTailQueue<QueueDiscItem> > band1 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxSize", StringValue ("6p"));
Ptr<DropTailQueue<QueueDiscItem> > band2 = CreateObjectWithAttributes<DropTailQueue<QueueDiscItem> > ("MaxSize", StringValue ("6p"));
queueDisc->AddInternalQueue (band0);
queueDisc->AddInternalQueue (band1);
queueDisc->AddInternalQueue (band2);
@@ -294,7 +294,7 @@ PfifoFastQueueDiscNoPriority::DoRun (void)
for (uint16_t i = 0; i < 3; i++)
{
Ptr<DropTailQueue<QueueDiscItem> > queue = CreateObject<DropTailQueue<QueueDiscItem> > ();
bool ok = queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (1000));
bool ok = queue->SetAttributeFailSafe ("MaxSize", StringValue ("1000p"));
NS_TEST_ASSERT_MSG_EQ (ok, true, "unable to set attribute");
queueDisc->AddInternalQueue (queue);
}

View File

@@ -1,3 +1,4 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2015 NITK Surathkal
@@ -104,7 +105,7 @@ std::stringstream filePlotQueueDiscAvg;
void
CheckQueueDiscSize (Ptr<QueueDisc> queue)
{
uint32_t qSize = StaticCast<RedQueueDisc> (queue)->GetQueueSize ();
uint32_t qSize = queue->GetCurrentSize ().GetValue ();
avgQueueDiscSize += qSize;
checkTimes++;
@@ -240,24 +241,23 @@ main (int argc, char *argv[])
// RED params
NS_LOG_INFO ("Set RED params");
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("1000p"));
Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSize));
Config::SetDefault ("ns3::RedQueueDisc::Wait", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::Gentle", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.002));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (5));
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (15));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (1000));
if (aredTest == 1) // test 1: red1
{
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("25p"));
}
else if (aredTest == 2) // test 2: red1Adapt
{
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (25));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("25p"));
}
else if (aredTest == 7) // test 7: fastlinkAutowq
{
@@ -286,13 +286,13 @@ main (int argc, char *argv[])
}
else if (aredTest == 13) // test 13: longlink
{
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("100p"));
}
else if (aredTest == 14) // test 14: longlinkAdapt
{
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("100p"));
}
else if (aredTest == 15) // test 15: longlinkAdapt1
{
@@ -301,7 +301,7 @@ main (int argc, char *argv[])
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (0));
Config::SetDefault ("ns3::RedQueueDisc::AdaptMaxP", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (100));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("100p"));
}
NS_LOG_INFO ("Install internet stack on all nodes.");
@@ -310,7 +310,7 @@ main (int argc, char *argv[])
TrafficControlHelper tchPfifo;
uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxSize", StringValue ("1000p"));
TrafficControlHelper tchRed;
tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (aredLinkDataRate),

View File

@@ -280,9 +280,10 @@ int main (int argc, char *argv[])
}
// Queue defaults
Config::SetDefault ("ns3::PfifoFastQueueDisc::Limit", UintegerValue (queueSize));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxPackets", UintegerValue (queueSize));
Config::SetDefault ("ns3::CoDelQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::PfifoFastQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueSize)));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueSize)));
// Create the nodes
NS_LOG_INFO ("Create nodes");

View File

@@ -129,8 +129,8 @@ int main (int argc, char *argv[])
}
// Devices queue configuration
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (queueSize));
Config::SetDefault ("ns3::QueueBase::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueSize)));
// Create gateway, source, and sink
NodeContainer gateway;
@@ -154,16 +154,16 @@ int main (int argc, char *argv[])
// Access link traffic control configuration
TrafficControlHelper tchPfifoFastAccess;
tchPfifoFastAccess.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "Limit", UintegerValue (1000));
tchPfifoFastAccess.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize", StringValue ("1000p"));
// Bottleneck link traffic control configuration
TrafficControlHelper tchPfifo;
tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "Limit", UintegerValue (queueDiscSize));
tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc", "MaxSize",
StringValue (std::to_string(queueDiscSize) + "p"));
TrafficControlHelper tchCoDel;
tchCoDel.SetRootQueueDisc ("ns3::CoDelQueueDisc");
Config::SetDefault ("ns3::CoDelQueueDisc::Mode", EnumValue (CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxPackets", UintegerValue (queueDiscSize));
Config::SetDefault ("ns3::CoDelQueueDisc::MaxSize", StringValue (std::to_string(queueDiscSize) + "p"));
Ipv4AddressHelper address;
address.SetBase ("10.0.0.0", "255.255.255.0");

View File

@@ -70,19 +70,20 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (maxPackets));
Config::SetDefault ("ns3::QueueBase::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, maxPackets)));
if (!modeBytes)
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets));
Config::SetDefault ("ns3::PfifoFastQueueDisc::Limit", UintegerValue (queueDiscLimitPackets));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscLimitPackets)));
Config::SetDefault ("ns3::PfifoFastQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscLimitPackets)));
}
else
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_BYTES"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets * pktSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::BYTES, queueDiscLimitPackets * pktSize)));
minTh *= pktSize;
maxTh *= pktSize;
}

View File

@@ -192,12 +192,11 @@ main (int argc, char *argv[])
// PIE params
NS_LOG_INFO ("Set PIE params");
Config::SetDefault ("ns3::PieQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::PieQueueDisc::MaxSize", StringValue ("100p"));
Config::SetDefault ("ns3::PieQueueDisc::MeanPktSize", UintegerValue (meanPktSize));
Config::SetDefault ("ns3::PieQueueDisc::DequeueThreshold", UintegerValue (10000));
Config::SetDefault ("ns3::PieQueueDisc::QueueDelayReference", TimeValue (Seconds (0.02)));
Config::SetDefault ("ns3::PieQueueDisc::MaxBurstAllowance", TimeValue (Seconds (0.1)));
Config::SetDefault ("ns3::PieQueueDisc::QueueLimit", UintegerValue (100));
NS_LOG_INFO ("Install internet stack on all nodes.");
InternetStackHelper internet;
@@ -205,7 +204,7 @@ main (int argc, char *argv[])
TrafficControlHelper tchPfifo;
uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxSize", StringValue ("1000p"));
TrafficControlHelper tchPie;
tchPie.SetRootQueueDisc ("ns3::PieQueueDisc");

View File

@@ -79,7 +79,7 @@ std::stringstream filePlotQueueAvg;
void
CheckQueueSize (Ptr<QueueDisc> queue)
{
uint32_t qSize = StaticCast<RedQueueDisc> (queue)->GetQueueSize ();
uint32_t qSize = queue->GetCurrentSize ().GetValue ();
avgQueueSize += qSize;
checkTimes++;
@@ -317,14 +317,13 @@ main (int argc, char *argv[])
// RED params
NS_LOG_INFO ("Set RED params");
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize", StringValue ("1000p"));
Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSize));
Config::SetDefault ("ns3::RedQueueDisc::Wait", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::Gentle", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::QW", DoubleValue (0.002));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (5));
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (15));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (1000));
if (redTest == 3) // test like 1, but with bad params
{
@@ -333,11 +332,11 @@ main (int argc, char *argv[])
}
else if (redTest == 5) // test 5, same of test 4, but in byte mode
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_BYTES"));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::BYTES, 1000 * meanPktSize)));
Config::SetDefault ("ns3::RedQueueDisc::Ns1Compat", BooleanValue (true));
Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (5 * meanPktSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (15 * meanPktSize));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (1000 * meanPktSize));
}
NS_LOG_INFO ("Install internet stack on all nodes.");
@@ -346,7 +345,7 @@ main (int argc, char *argv[])
TrafficControlHelper tchPfifo;
uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxSize", StringValue ("1000p"));
TrafficControlHelper tchRed;
tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (redLinkDataRate),

View File

@@ -70,18 +70,17 @@ int main (int argc, char *argv[])
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS"));
Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (maxPackets));
Config::SetDefault ("ns3::QueueBase::MaxSize", StringValue (std::to_string (maxPackets) + "p"));
if (!modeBytes)
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_PACKETS"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscLimitPackets)));
}
else
{
Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MODE_BYTES"));
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueDiscLimitPackets * pktSize));
Config::SetDefault ("ns3::RedQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::BYTES, queueDiscLimitPackets * pktSize)));
minTh *= pktSize;
maxTh *= pktSize;
}

View File

@@ -857,24 +857,6 @@ RedQueueDisc::ModifyP (double p, uint32_t size)
return p;
}
uint32_t
RedQueueDisc::GetQueueSize (void)
{
NS_LOG_FUNCTION (this);
if (GetMode () == QUEUE_DISC_MODE_BYTES)
{
return GetInternalQueue (0)->GetNBytes ();
}
else if (GetMode () == QUEUE_DISC_MODE_PACKETS)
{
return GetInternalQueue (0)->GetNPackets ();
}
else
{
NS_ABORT_MSG ("Unknown RED mode.");
}
}
Ptr<QueueDiscItem>
RedQueueDisc::DoDequeue (void)
{

View File

@@ -147,13 +147,6 @@ public:
*/
QueueDiscMode GetMode (void) const;
/**
* \brief Get the current value of the queue in bytes or packets.
*
* \returns The queue size in bytes or packets.
*/
uint32_t GetQueueSize (void);
/**
* \brief Set the alpha value to adapt m_curMaxP.
*

View File

@@ -120,7 +120,7 @@ private:
* Run ARED queue disc test function
* \param mode the test mode
*/
void RunAredDiscTest (StringValue mode);
void RunAredDiscTest (QueueSizeUnit mode);
};
AredQueueDiscTestCase::AredQueueDiscTestCase ()
@@ -129,7 +129,7 @@ AredQueueDiscTestCase::AredQueueDiscTestCase ()
}
void
AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
AredQueueDiscTestCase::RunAredDiscTest (QueueSizeUnit mode)
{
uint32_t pktSize = 0;
uint32_t modeSize = 1; // 1 for packets; pktSize for bytes
@@ -140,10 +140,8 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 1: Verify automatic setting of QW. [QW = 0.0 with default LinkBandwidth]
Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
if (queue->GetMode () == RedQueueDisc::QUEUE_DISC_MODE_BYTES)
if (mode == QueueSizeUnit::BYTES)
{
pktSize = 500;
modeSize = pktSize;
@@ -156,8 +154,8 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute QW");
queue->Initialize ();
@@ -169,14 +167,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 2: Verify automatic setting of QW. [QW = 0.0 with lesser LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
@@ -190,14 +186,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 3: Verify automatic setting of QW. [QW = -1.0 with default LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-1.0)), true,
"Verify that we can actually set the attribute QW");
queue->Initialize ();
@@ -209,14 +203,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 4: Verify automatic setting of QW. [QW = -1.0 with lesser LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-1.0)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
@@ -230,14 +222,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 5: Verify automatic setting of QW. [QW = -2.0 with default LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-2.0)), true,
"Verify that we can actually set the attribute QW");
queue->Initialize ();
@@ -249,14 +239,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 6: Verify automatic setting of QW. [QW = -2.0 with lesser LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (-2.0)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("0.015Mbps"))), true,
@@ -270,14 +258,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 7: Verify automatic setting of minTh and maxTh. [minTh = maxTh = 0.0, with default LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
queue->Initialize ();
Enqueue (queue, pktSize, 300);
st = queue->GetStats ();
@@ -287,14 +273,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 8: Verify automatic setting of minTh and maxTh. [minTh = maxTh = 0.0, with higher LinkBandwidth]
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (0.0)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LinkBandwidth", DataRateValue (DataRate ("150Mbps"))), true,
"Verify that we can actually set the attribute LinkBandwidth");
queue->Initialize ();
@@ -308,14 +292,12 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
queue = CreateObject<RedQueueDisc> ();
minTh = 5 * modeSize;
maxTh = 15 * modeSize;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -332,10 +314,8 @@ AredQueueDiscTestCase::RunAredDiscTest (StringValue mode)
// test 10: Adaptive RED (automatic and adaptive settings enabled)
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
"Verify that we can actually set the attribute LInterm");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("ARED", BooleanValue (true)), true,
@@ -373,8 +353,8 @@ AredQueueDiscTestCase::EnqueueWithDelay (Ptr<RedQueueDisc> queue, uint32_t size,
void
AredQueueDiscTestCase::DoRun (void)
{
RunAredDiscTest (StringValue ("QUEUE_DISC_MODE_PACKETS"));
RunAredDiscTest (StringValue ("QUEUE_DISC_MODE_BYTES"));
RunAredDiscTest (QueueSizeUnit::PACKETS);
RunAredDiscTest (QueueSizeUnit::BYTES);
Simulator::Destroy ();
}

View File

@@ -122,37 +122,17 @@ public:
*
* \param mode the mode
*/
CoDelQueueDiscBasicEnqueueDequeue (std::string mode);
CoDelQueueDiscBasicEnqueueDequeue (QueueSizeUnit mode);
virtual void DoRun (void);
/**
* Queue test size function
* \param queue the queue disc
* \param size the size
* \param error the error string
*/
void QueueTestSize (Ptr<CoDelQueueDisc> queue, uint32_t size, std::string error)
{
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
}
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
}
private:
StringValue m_mode; ///< mode
QueueSizeUnit m_mode; ///< mode
};
CoDelQueueDiscBasicEnqueueDequeue::CoDelQueueDiscBasicEnqueueDequeue (std::string mode)
: TestCase ("Basic enqueue and dequeue operations, and attribute setting for " + mode)
CoDelQueueDiscBasicEnqueueDequeue::CoDelQueueDiscBasicEnqueueDequeue (QueueSizeUnit mode)
: TestCase ("Basic enqueue and dequeue operations, and attribute setting")
{
m_mode = StringValue (mode);
m_mode = mode;
}
void
@@ -165,12 +145,6 @@ CoDelQueueDiscBasicEnqueueDequeue::DoRun (void)
Address dest;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (1500)), true,
"Verify that we can actually set the attribute MaxPackets");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue (pktSize * 1500)), true,
"Verify that we can actually set the attribute MaxBytes");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
"Verify that we can actually set the attribute MinBytes");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Interval", StringValue ("50ms")), true,
@@ -178,14 +152,16 @@ CoDelQueueDiscBasicEnqueueDequeue::DoRun (void)
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Target", StringValue ("4ms")), true,
"Verify that we can actually set the attribute Target");
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
if (m_mode == QueueSizeUnit::BYTES)
{
modeSize = pktSize;
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
else if (m_mode == QueueSizeUnit::PACKETS)
{
modeSize = 1;
}
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 1500))),
true, "Verify that we can actually set the attribute MaxSize");
queue->Initialize ();
Ptr<Packet> p1, p2, p3, p4, p5, p6;
@@ -196,19 +172,19 @@ CoDelQueueDiscBasicEnqueueDequeue::DoRun (void)
p5 = Create<Packet> (pktSize);
p6 = Create<Packet> (pktSize);
QueueTestSize (queue, 0 * modeSize, "There should be no packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, "There should be no packets in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest));
QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, "There should be one packet in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest));
QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, "There should be two packets in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest));
QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, "There should be three packets in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p4, dest));
QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, "There should be four packets in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p5, dest));
QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, "There should be five packets in queue");
queue->Enqueue (Create<CodelQueueDiscTestItem> (p6, dest));
QueueTestSize (queue, 6 * modeSize, "There should be six packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 6 * modeSize, "There should be six packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
0, "There should be no packets being dropped due to full queue");
@@ -217,32 +193,32 @@ CoDelQueueDiscBasicEnqueueDequeue::DoRun (void)
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, "There should be five packets in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, "There should be four packets in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, "There should be three packets in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the forth packet");
QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, "There should be two packets in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the fifth packet");
QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, "There should be one packet in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the last packet");
QueueTestSize (queue, 0 * modeSize, "There should be zero packet in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, "There should be zero packet in queue");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
item = queue->Dequeue ();
@@ -266,29 +242,9 @@ public:
*
* \param mode the mode
*/
CoDelQueueDiscBasicOverflow (std::string mode);
CoDelQueueDiscBasicOverflow (QueueSizeUnit mode);
virtual void DoRun (void);
/**
* Queue test size function
* \param queue the queue disc
* \param size the size
* \param error the error string
*/
void QueueTestSize (Ptr<CoDelQueueDisc> queue, uint32_t size, std::string error)
{
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
}
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
}
private:
/**
* Enqueue function
@@ -297,13 +253,13 @@ private:
* \param nPkt the number of packets
*/
void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
StringValue m_mode; ///< mode
QueueSizeUnit m_mode; ///< mode
};
CoDelQueueDiscBasicOverflow::CoDelQueueDiscBasicOverflow (std::string mode)
: TestCase ("Basic overflow behavior for " + mode)
CoDelQueueDiscBasicOverflow::CoDelQueueDiscBasicOverflow (QueueSizeUnit mode)
: TestCase ("Basic overflow behavior")
{
m_mode = StringValue (mode);
m_mode = mode;
}
void
@@ -313,16 +269,13 @@ CoDelQueueDiscBasicOverflow::DoRun (void)
uint32_t pktSize = 1000;
uint32_t modeSize = 0;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
"Verify that we can actually set the attribute Mode");
Address dest;
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
if (m_mode == QueueSizeUnit::BYTES)
{
modeSize = pktSize;
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
else if (m_mode == QueueSizeUnit::PACKETS)
{
modeSize = 1;
}
@@ -332,10 +285,8 @@ CoDelQueueDiscBasicOverflow::DoRun (void)
p2 = Create<Packet> (pktSize);
p3 = Create<Packet> (pktSize);
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (500)), true,
"Verify that we can actually set the attribute MaxPackets");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue (pktSize * 500)), true,
"Verify that we can actually set the attribute MaxBytes");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
"Verify that we can actually set the attribute MinBytes");
@@ -346,7 +297,7 @@ CoDelQueueDiscBasicOverflow::DoRun (void)
queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest));
queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest));
QueueTestSize (queue, 500 * modeSize, "There should be 500 packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 500 * modeSize, "There should be 500 packets in queue");
NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
3, "There should be three packets being dropped due to full queue");
}
@@ -473,29 +424,9 @@ public:
*
* \param mode the mode
*/
CoDelQueueDiscBasicDrop (std::string mode);
CoDelQueueDiscBasicDrop (QueueSizeUnit mode);
virtual void DoRun (void);
/**
* Queue test size function
* \param queue the queue disc
* \param size the size
* \param error the error string
*/
void QueueTestSize (Ptr<CoDelQueueDisc> queue, uint32_t size, std::string error)
{
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
{
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
}
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
}
private:
/**
* Enqueue function
@@ -515,14 +446,14 @@ private:
* \param newVal the new value
*/
void DropNextTracer (uint32_t oldVal, uint32_t newVal);
StringValue m_mode; ///< mode
QueueSizeUnit m_mode; ///< mode
uint32_t m_dropNextCount; ///< count the number of times m_dropNext is recalculated
};
CoDelQueueDiscBasicDrop::CoDelQueueDiscBasicDrop (std::string mode)
: TestCase ("Basic drop operations for " + mode)
CoDelQueueDiscBasicDrop::CoDelQueueDiscBasicDrop (QueueSizeUnit mode)
: TestCase ("Basic drop operations")
{
m_mode = StringValue (mode);
m_mode = mode;
m_dropNextCount = 0;
}
@@ -541,22 +472,22 @@ CoDelQueueDiscBasicDrop::DoRun (void)
uint32_t pktSize = 1000;
uint32_t modeSize = 0;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
"Verify that we can actually set the attribute Mode");
if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_BYTES)
if (m_mode == QueueSizeUnit::BYTES)
{
modeSize = pktSize;
}
else if (queue->GetMode () == CoDelQueueDisc::QUEUE_DISC_MODE_PACKETS)
else if (m_mode == QueueSizeUnit::PACKETS)
{
modeSize = 1;
}
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
true, "Verify that we can actually set the attribute MaxSize");
queue->Initialize ();
Enqueue (queue, pktSize, 20);
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 20 * modeSize, "There should be 20 packets in queue.");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
// Although the first dequeue occurs with a sojourn time above target
// the dequeue should be successful in this interval
@@ -593,7 +524,7 @@ void
CoDelQueueDiscBasicDrop::Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize)
{
uint32_t initialDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
uint32_t initialQSize = queue->GetQueueSize ();
uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
uint32_t initialDropNext = queue->GetDropNext ();
Time currentTime = Simulator::Now ();
uint32_t currentDropCount = 0;
@@ -614,13 +545,13 @@ CoDelQueueDiscBasicDrop::Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize)
NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
"Sojourn time has just gone above target from below."
"Hence, there should be no packet drops");
QueueTestSize (queue, initialQSize - modeSize, "There should be 1 packet dequeued.");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
}
else if (currentTime >= queue->GetInterval ())
{
currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
QueueTestSize (queue, initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
"We enter the dropping state, perform initial packet drop, and dequeue the next."
"So there should be 2 more packets dequeued.");
NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
@@ -631,7 +562,7 @@ CoDelQueueDiscBasicDrop::Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize)
if (currentTime.GetMicroSeconds () < initialDropNext)
{
currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
QueueTestSize (queue, initialQSize - modeSize, "We are in dropping state."
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
"Sojourn is still above target."
"However, it's not time for next drop."
"So there should be only 1 more packet dequeued");
@@ -641,7 +572,7 @@ CoDelQueueDiscBasicDrop::Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize)
else if (currentTime.GetMicroSeconds () >= initialDropNext)
{
currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
QueueTestSize (queue, initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
"It's time for next drop."
"The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1 + m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated plus 1 from last dequeue");
@@ -663,17 +594,17 @@ public:
: TestSuite ("codel-queue-disc", UNIT)
{
// Test 1: simple enqueue/dequeue with no drops
AddTestCase (new CoDelQueueDiscBasicEnqueueDequeue ("QUEUE_DISC_MODE_PACKETS"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicEnqueueDequeue ("QUEUE_DISC_MODE_BYTES"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicEnqueueDequeue (QueueSizeUnit::PACKETS), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicEnqueueDequeue (QueueSizeUnit::BYTES), TestCase::QUICK);
// Test 2: enqueue with drops due to queue overflow
AddTestCase (new CoDelQueueDiscBasicOverflow ("QUEUE_DISC_MODE_PACKETS"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicOverflow ("QUEUE_DISC_MODE_BYTES"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicOverflow (QueueSizeUnit::PACKETS), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicOverflow (QueueSizeUnit::BYTES), TestCase::QUICK);
// Test 3: test NewtonStep() against explicit port of Linux implementation
AddTestCase (new CoDelQueueDiscNewtonStepTest (), TestCase::QUICK);
// Test 4: test ControlLaw() against explicit port of Linux implementation
AddTestCase (new CoDelQueueDiscControlLawTest (), TestCase::QUICK);
// Test 5: enqueue/dequeue with drops according to CoDel algorithm
AddTestCase (new CoDelQueueDiscBasicDrop ("QUEUE_DISC_MODE_PACKETS"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicDrop ("QUEUE_DISC_MODE_BYTES"), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicDrop (QueueSizeUnit::PACKETS), TestCase::QUICK);
AddTestCase (new CoDelQueueDiscBasicDrop (QueueSizeUnit::BYTES), TestCase::QUICK);
}
} g_coDelQueueTestSuite; ///< the test suite

View File

@@ -130,7 +130,7 @@ private:
* Run test function
* \param mode the test mode
*/
void RunPieTest (StringValue mode);
void RunPieTest (QueueSizeUnit mode);
};
PieQueueDiscTestCase::PieQueueDiscTestCase ()
@@ -139,7 +139,7 @@ PieQueueDiscTestCase::PieQueueDiscTestCase ()
}
void
PieQueueDiscTestCase::RunPieTest (StringValue mode)
PieQueueDiscTestCase::RunPieTest (QueueSizeUnit mode)
{
uint32_t pktSize = 0;
@@ -151,12 +151,9 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
// test 1: simple enqueue/dequeue with defaults, no drops
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
Address dest;
if (queue->GetMode () == PieQueueDisc::QUEUE_DISC_MODE_BYTES)
if (mode == QueueSizeUnit::BYTES)
{
// pktSize should be same as MeanPktSize to avoid performance gap between byte and packet mode
pktSize = 1000;
@@ -164,8 +161,8 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
qSize = qSize * modeSize;
}
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
Ptr<Packet> p1, p2, p3, p4, p5, p6, p7, p8;
p1 = Create<Packet> (pktSize);
@@ -178,34 +175,34 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
p8 = Create<Packet> (pktSize);
queue->Initialize ();
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 0 * modeSize, "There should be no packets in there");
queue->Enqueue (Create<PieQueueDiscTestItem> (p1, dest));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 1 * modeSize, "There should be one packet in there");
queue->Enqueue (Create<PieQueueDiscTestItem> (p2, dest));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 2 * modeSize, "There should be two packets in there");
queue->Enqueue (Create<PieQueueDiscTestItem> (p3, dest));
queue->Enqueue (Create<PieQueueDiscTestItem> (p4, dest));
queue->Enqueue (Create<PieQueueDiscTestItem> (p5, dest));
queue->Enqueue (Create<PieQueueDiscTestItem> (p6, dest));
queue->Enqueue (Create<PieQueueDiscTestItem> (p7, dest));
queue->Enqueue (Create<PieQueueDiscTestItem> (p8, dest));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 8 * modeSize, "There should be eight packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 8 * modeSize, "There should be eight packets in there");
Ptr<QueueDiscItem> item;
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 7 * modeSize, "There should be seven packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 7 * modeSize, "There should be seven packets in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 6 * modeSize, "There should be six packet in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 6 * modeSize, "There should be six packet in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 5 * modeSize, "There should be five packets in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");
item = queue->Dequeue ();
@@ -221,10 +218,8 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
// test 2: more data with defaults, unforced drops but no forced drops
queue = CreateObject<PieQueueDisc> ();
pktSize = 1000; // pktSize != 0 because DequeueThreshold always works in bytes
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("A", DoubleValue (0.125)), true,
"Verify that we can actually set the attribute A");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("B", DoubleValue (1.25)), true,
@@ -252,10 +247,8 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
// test 3: same as test 2, but with higher QueueDelayReference
queue = CreateObject<PieQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("A", DoubleValue (0.125)), true,
"Verify that we can actually set the attribute A");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("B", DoubleValue (1.25)), true,
@@ -283,10 +276,8 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
// test 4: same as test 2, but with reduced dequeue rate
queue = CreateObject<PieQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("A", DoubleValue (0.125)), true,
"Verify that we can actually set the attribute A");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("B", DoubleValue (1.25)), true,
@@ -314,10 +305,8 @@ PieQueueDiscTestCase::RunPieTest (StringValue mode)
// test 5: same dequeue rate as test 4, but with higher Tupdate
queue = CreateObject<PieQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("A", DoubleValue (0.125)), true,
"Verify that we can actually set the attribute A");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("B", DoubleValue (1.25)), true,
@@ -385,8 +374,8 @@ PieQueueDiscTestCase::DequeueWithDelay (Ptr<PieQueueDisc> queue, double delay, u
void
PieQueueDiscTestCase::DoRun (void)
{
RunPieTest (StringValue ("QUEUE_DISC_MODE_PACKETS"));
RunPieTest (StringValue ("QUEUE_DISC_MODE_BYTES"));
RunPieTest (QueueSizeUnit::PACKETS);
RunPieTest (QueueSizeUnit::BYTES);
Simulator::Destroy ();
}

View File

@@ -116,7 +116,7 @@ private:
* Run RED test function
* \param mode the mode
*/
void RunRedTest (StringValue mode);
void RunRedTest (QueueSizeUnit mode);
};
RedQueueDiscTestCase::RedQueueDiscTestCase ()
@@ -125,7 +125,7 @@ RedQueueDiscTestCase::RedQueueDiscTestCase ()
}
void
RedQueueDiscTestCase::RunRedTest (StringValue mode)
RedQueueDiscTestCase::RunRedTest (QueueSizeUnit mode)
{
uint32_t pktSize = 0;
// 1 for packets; pktSize for bytes
@@ -136,26 +136,24 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
// test 1: simple enqueue/dequeue with no drops
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
Address dest;
if (queue->GetMode () == RedQueueDisc::QUEUE_DISC_MODE_BYTES)
if (mode == QueueSizeUnit::BYTES)
{
// pktSize should be same as MeanPktSize to avoid performance gap between byte and packet mode
pktSize = 500;
modeSize = pktSize;
queue->SetTh (minTh * modeSize, maxTh * modeSize);
queue->SetQueueLimit (qSize * modeSize);
queue->SetMaxSize (QueueSize (mode, qSize * modeSize));
}
Ptr<Packet> p1, p2, p3, p4, p5, p6, p7, p8;
@@ -169,34 +167,34 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
p8 = Create<Packet> (pktSize);
queue->Initialize ();
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 0 * modeSize, "There should be no packets in there");
queue->Enqueue (Create<RedQueueDiscTestItem> (p1, dest, false));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 1 * modeSize, "There should be one packet in there");
queue->Enqueue (Create<RedQueueDiscTestItem> (p2, dest, false));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 2 * modeSize, "There should be two packets in there");
queue->Enqueue (Create<RedQueueDiscTestItem> (p3, dest, false));
queue->Enqueue (Create<RedQueueDiscTestItem> (p4, dest, false));
queue->Enqueue (Create<RedQueueDiscTestItem> (p5, dest, false));
queue->Enqueue (Create<RedQueueDiscTestItem> (p6, dest, false));
queue->Enqueue (Create<RedQueueDiscTestItem> (p7, dest, false));
queue->Enqueue (Create<RedQueueDiscTestItem> (p8, dest, false));
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 8 * modeSize, "There should be eight packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 8 * modeSize, "There should be eight packets in there");
Ptr<QueueDiscItem> item;
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 7 * modeSize, "There should be seven packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 7 * modeSize, "There should be seven packets in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 6 * modeSize, "There should be six packet in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 6 * modeSize, "There should be six packet in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in there");
NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 5 * modeSize, "There should be five packets in there");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");
item = queue->Dequeue ();
@@ -214,14 +212,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
minTh = 70 * modeSize;
maxTh = 150 * modeSize;
qSize = 300 * modeSize;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
queue->Initialize ();
Enqueue (queue, pktSize, 300, false);
QueueDisc::Stats st = queue->GetStats ();
@@ -247,14 +243,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 3: more data, now drops due QW change
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)), true,
"Verify that we can actually set the attribute QW");
queue->Initialize ();
@@ -269,14 +263,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 4: reduced maxTh, this causes more drops
maxTh = 100 * modeSize;
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)), true,
"Verify that we can actually set the attribute QW");
queue->Initialize ();
@@ -291,14 +283,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 5: change drop probability to a high value (LInterm)
maxTh = 150 * modeSize;
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (5)), true,
@@ -314,14 +304,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 6: disable Gentle param
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Gentle", BooleanValue (false)), true,
@@ -337,14 +325,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 7: disable Wait param
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Wait", BooleanValue (false)), true,
@@ -362,14 +348,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
queue = CreateObject<RedQueueDisc> ();
minTh = 30 * modeSize;
maxTh = 90 * modeSize;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -390,14 +374,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 9: Packets are ECN capable, but RED queue disc is not ECN enabled
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -418,14 +400,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 10: Packets are ECN capable and RED queue disc is ECN enabled
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -448,14 +428,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
queue = CreateObject<RedQueueDisc> ();
minTh = 30 * modeSize;
maxTh = 90 * modeSize;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -471,14 +449,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
// test 12: Feng's Adaptive RED with default parameter settings and varying m_curMaxP
queue = CreateObject<RedQueueDisc> ();
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -498,14 +474,12 @@ RedQueueDiscTestCase::RunRedTest (StringValue mode)
queue = CreateObject<RedQueueDisc> ();
minTh = 30 * modeSize;
maxTh = 90 * modeSize;
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
"Verify that we can actually set the attribute Mode");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minTh)), true,
"Verify that we can actually set the attribute MinTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxTh)), true,
"Verify that we can actually set the attribute MaxTh");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValue (qSize)), true,
"Verify that we can actually set the attribute QueueLimit");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (mode, qSize))),
true, "Verify that we can actually set the attribute MaxSize");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
"Verify that we can actually set the attribute QW");
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("LInterm", DoubleValue (2)), true,
@@ -535,8 +509,8 @@ RedQueueDiscTestCase::Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t
void
RedQueueDiscTestCase::DoRun (void)
{
RunRedTest (StringValue ("QUEUE_DISC_MODE_PACKETS"));
RunRedTest (StringValue ("QUEUE_DISC_MODE_BYTES"));
RunRedTest (QueueSizeUnit::PACKETS);
RunRedTest (QueueSizeUnit::BYTES);
Simulator::Destroy ();
}

View File

@@ -99,19 +99,12 @@ QueueDiscTestItem::Mark (void)
class TcFlowControlTestCase : public TestCase
{
public:
/// Device queue operating mode
enum TestType
{
PACKET_MODE,
BYTE_MODE
};
/**
* Constructor
*
* \param tt the test type
*/
TcFlowControlTestCase (TestType tt);
TcFlowControlTestCase (QueueSizeUnit tt);
virtual ~TcFlowControlTestCase ();
private:
virtual void DoRun (void);
@@ -142,10 +135,10 @@ private:
* \param msg the message to print if a different number of packets are stored
*/
void CheckPacketsInQueueDisc (Ptr<NetDevice> dev, uint16_t nPackets, const char* msg);
TestType m_type; //!< the test type
QueueSizeUnit m_type; //!< the test type
};
TcFlowControlTestCase::TcFlowControlTestCase (TestType tt)
TcFlowControlTestCase::TcFlowControlTestCase (QueueSizeUnit tt)
: TestCase ("Test the operation of the flow control mechanism"),
m_type (tt)
{
@@ -201,15 +194,13 @@ TcFlowControlTestCase::DoRun (void)
Ptr<Queue<Packet> > queue;
if (m_type == PACKET_MODE)
if (m_type == QueueSizeUnit::PACKETS)
{
queue = CreateObjectWithAttributes<DropTailQueue<Packet> > ("Mode", EnumValue (QueueBase::QUEUE_MODE_PACKETS),
"MaxPackets", UintegerValue (5));
queue = CreateObjectWithAttributes<DropTailQueue<Packet> > ("MaxSize", StringValue ("5p"));
}
else
{
queue = CreateObjectWithAttributes<DropTailQueue<Packet> > ("Mode", EnumValue (QueueBase::QUEUE_MODE_BYTES),
"MaxBytes", UintegerValue (5000));
queue = CreateObjectWithAttributes<DropTailQueue<Packet> > ("MaxSize", StringValue ("5000B"));
}
// link the two nodes
@@ -232,7 +223,7 @@ TcFlowControlTestCase::DoRun (void)
Simulator::Schedule (Time (Seconds (0)), &TcFlowControlTestCase::SendPackets,
this, n.Get (0), 10);
if (m_type == PACKET_MODE)
if (m_type == QueueSizeUnit::PACKETS)
{
/*
* When the device queue is in packet mode, all the packets enqueued in the
@@ -395,7 +386,7 @@ public:
TcFlowControlTestSuite ()
: TestSuite ("tc-flow-control", UNIT)
{
AddTestCase (new TcFlowControlTestCase (TcFlowControlTestCase::PACKET_MODE), TestCase::QUICK);
AddTestCase (new TcFlowControlTestCase (TcFlowControlTestCase::BYTE_MODE), TestCase::QUICK);
AddTestCase (new TcFlowControlTestCase (QueueSizeUnit::PACKETS), TestCase::QUICK);
AddTestCase (new TcFlowControlTestCase (QueueSizeUnit::BYTES), TestCase::QUICK);
}
} g_tcFlowControlTestSuite; ///< the test suite