Use longer names for QueueMode and ErrorUnit enums and move them to Queue and RateErrorModel classes respectively.
This commit is contained in:
@@ -58,7 +58,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Set a few attributes
|
||||
Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.01));
|
||||
Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("EU_PKT"));
|
||||
Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
|
||||
|
||||
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
|
||||
Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRateValue (DataRate ("448kb/s")));
|
||||
|
||||
@@ -330,7 +330,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// RED params
|
||||
NS_LOG_INFO ("Set RED params");
|
||||
Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("Packets"));
|
||||
Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("QUEUE_MODE_PACKETS"));
|
||||
Config::SetDefault ("ns3::RedQueue::MeanPktSize", UintegerValue (meanPktSize));
|
||||
Config::SetDefault ("ns3::RedQueue::Wait", BooleanValue (true));
|
||||
Config::SetDefault ("ns3::RedQueue::Gentle", BooleanValue (true));
|
||||
@@ -346,7 +346,7 @@ main (int argc, char *argv[])
|
||||
}
|
||||
else if (redTest == 5) // test 5, same of test 4, but in byte mode
|
||||
{
|
||||
Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("Bytes"));
|
||||
Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("QUEUE_MODE_BYTES"));
|
||||
Config::SetDefault ("ns3::RedQueue::Ns1Compat", BooleanValue (true));
|
||||
Config::SetDefault ("ns3::RedQueue::MinTh", DoubleValue (5 * meanPktSize));
|
||||
Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (15 * meanPktSize));
|
||||
@@ -414,7 +414,7 @@ main (int argc, char *argv[])
|
||||
Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (1));
|
||||
Ptr<Queue> queue = nd->GetQueue ();
|
||||
|
||||
StaticCast<RedQueue> (queue)->SetMode (RedQueue::PACKETS);
|
||||
StaticCast<RedQueue> (queue)->SetMode (RedQueue::QUEUE_MODE_PACKETS);
|
||||
StaticCast<RedQueue> (queue)->SetTh (5, 15);
|
||||
StaticCast<RedQueue> (queue)->SetQueueLimit (25);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ RedQueueTestCase::RunRedTest (StringValue mode)
|
||||
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)), true,
|
||||
"Verify that we can actually set the attribute QW");
|
||||
|
||||
if (queue->GetMode () == RedQueue::BYTES)
|
||||
if (queue->GetMode () == RedQueue::QUEUE_MODE_BYTES)
|
||||
{
|
||||
pktSize = 1000;
|
||||
modeSize = pktSize;
|
||||
@@ -264,8 +264,8 @@ RedQueueTestCase::Enqueue (Ptr<RedQueue> queue, uint32_t size, uint32_t nPkt)
|
||||
void
|
||||
RedQueueTestCase::DoRun (void)
|
||||
{
|
||||
RunRedTest (StringValue ("Packets"));
|
||||
RunRedTest (StringValue ("Bytes"));
|
||||
RunRedTest (StringValue ("QUEUE_MODE_PACKETS"));
|
||||
RunRedTest (StringValue ("QUEUE_MODE_BYTES"));
|
||||
Simulator::Destroy ();
|
||||
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ TypeId DropTailQueue::GetTypeId (void)
|
||||
.SetParent<Queue> ()
|
||||
.AddConstructor<DropTailQueue> ()
|
||||
.AddAttribute ("Mode",
|
||||
"Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
|
||||
EnumValue (PACKETS),
|
||||
"Whether to use bytes (see MaxBytes) or packets (see MaxPackets) as the maximum queue size metric.",
|
||||
EnumValue (QUEUE_MODE_PACKETS),
|
||||
MakeEnumAccessor (&DropTailQueue::SetMode),
|
||||
MakeEnumChecker (BYTES, "Bytes",
|
||||
PACKETS, "Packets"))
|
||||
MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
|
||||
QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
|
||||
.AddAttribute ("MaxPackets",
|
||||
"The maximum number of packets accepted by this DropTailQueue.",
|
||||
UintegerValue (100),
|
||||
@@ -67,13 +67,13 @@ DropTailQueue::~DropTailQueue ()
|
||||
}
|
||||
|
||||
void
|
||||
DropTailQueue::SetMode (enum Mode mode)
|
||||
DropTailQueue::SetMode (DropTailQueue::QueueMode mode)
|
||||
{
|
||||
NS_LOG_FUNCTION (mode);
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
DropTailQueue::Mode
|
||||
DropTailQueue::QueueMode
|
||||
DropTailQueue::GetMode (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -85,14 +85,14 @@ DropTailQueue::DoEnqueue (Ptr<Packet> p)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p);
|
||||
|
||||
if (m_mode == PACKETS && (m_packets.size () >= m_maxPackets))
|
||||
if (m_mode == QUEUE_MODE_PACKETS && (m_packets.size () >= m_maxPackets))
|
||||
{
|
||||
NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
|
||||
Drop (p);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_mode == BYTES && (m_bytesInQueue + p->GetSize () >= m_maxBytes))
|
||||
if (m_mode == QUEUE_MODE_BYTES && (m_bytesInQueue + p->GetSize () >= m_maxBytes))
|
||||
{
|
||||
NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
|
||||
Drop (p);
|
||||
|
||||
@@ -44,30 +44,20 @@ public:
|
||||
|
||||
virtual ~DropTailQueue();
|
||||
|
||||
/**
|
||||
* Enumeration of the modes supported in the class.
|
||||
*
|
||||
*/
|
||||
enum Mode {
|
||||
ILLEGAL, /**< Mode not set */
|
||||
PACKETS, /**< Use number of packets for maximum queue size */
|
||||
BYTES, /**< Use number of bytes for maximum queue size */
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the operating mode of this device.
|
||||
*
|
||||
* \param mode The operating mode of this device.
|
||||
*
|
||||
*/
|
||||
void SetMode (DropTailQueue::Mode mode);
|
||||
void SetMode (DropTailQueue::QueueMode mode);
|
||||
|
||||
/**
|
||||
* Get the encapsulation mode of this device.
|
||||
*
|
||||
* \returns The encapsulation mode of this device.
|
||||
*/
|
||||
DropTailQueue::Mode GetMode (void);
|
||||
DropTailQueue::QueueMode GetMode (void);
|
||||
|
||||
private:
|
||||
virtual bool DoEnqueue (Ptr<Packet> p);
|
||||
@@ -78,7 +68,7 @@ private:
|
||||
uint32_t m_maxPackets;
|
||||
uint32_t m_maxBytes;
|
||||
uint32_t m_bytesInQueue;
|
||||
Mode m_mode;
|
||||
QueueMode m_mode;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -111,11 +111,11 @@ TypeId RateErrorModel::GetTypeId (void)
|
||||
.SetParent<ErrorModel> ()
|
||||
.AddConstructor<RateErrorModel> ()
|
||||
.AddAttribute ("ErrorUnit", "The error unit",
|
||||
EnumValue (EU_BYTE),
|
||||
EnumValue (ERROR_UNIT_BYTE),
|
||||
MakeEnumAccessor (&RateErrorModel::m_unit),
|
||||
MakeEnumChecker (EU_BYTE, "EU_BYTE",
|
||||
EU_PKT, "EU_PKT",
|
||||
EU_BIT, "EU_BIT"))
|
||||
MakeEnumChecker (ERROR_UNIT_BIT, "ERROR_UNIT_BIT",
|
||||
ERROR_UNIT_BYTE, "ERROR_UNIT_BYTE",
|
||||
ERROR_UNIT_PACKET, "ERROR_UNIT_PACKET"))
|
||||
.AddAttribute ("ErrorRate", "The error rate.",
|
||||
DoubleValue (0.0),
|
||||
MakeDoubleAccessor (&RateErrorModel::m_rate),
|
||||
@@ -139,7 +139,7 @@ RateErrorModel::~RateErrorModel ()
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
enum ErrorUnit
|
||||
RateErrorModel::ErrorUnit
|
||||
RateErrorModel::GetUnit (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -184,11 +184,11 @@ RateErrorModel::DoCorrupt (Ptr<Packet> p)
|
||||
}
|
||||
switch (m_unit)
|
||||
{
|
||||
case EU_PKT:
|
||||
case ERROR_UNIT_PACKET:
|
||||
return DoCorruptPkt (p);
|
||||
case EU_BYTE:
|
||||
case ERROR_UNIT_BYTE:
|
||||
return DoCorruptByte (p);
|
||||
case EU_BIT:
|
||||
case ERROR_UNIT_BIT:
|
||||
return DoCorruptBit (p);
|
||||
default:
|
||||
NS_ASSERT_MSG (false, "m_unit not supported yet");
|
||||
|
||||
@@ -112,13 +112,6 @@ private:
|
||||
bool m_enable;
|
||||
};
|
||||
|
||||
enum ErrorUnit
|
||||
{
|
||||
EU_BIT,
|
||||
EU_BYTE,
|
||||
EU_PKT
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Determine which packets are errored corresponding to an underlying
|
||||
* distribution, rate, and unit.
|
||||
@@ -142,10 +135,17 @@ public:
|
||||
RateErrorModel ();
|
||||
virtual ~RateErrorModel ();
|
||||
|
||||
enum ErrorUnit
|
||||
{
|
||||
ERROR_UNIT_BIT,
|
||||
ERROR_UNIT_BYTE,
|
||||
ERROR_UNIT_PACKET
|
||||
};
|
||||
|
||||
/**
|
||||
* \returns the ErrorUnit being used by the underlying model
|
||||
*/
|
||||
enum ErrorUnit GetUnit (void) const;
|
||||
RateErrorModel::ErrorUnit GetUnit (void) const;
|
||||
/**
|
||||
* \param error_unit the ErrorUnit to be used by the underlying model
|
||||
*/
|
||||
|
||||
@@ -115,6 +115,16 @@ public:
|
||||
*/
|
||||
void ResetStatistics (void);
|
||||
|
||||
/**
|
||||
* \brief Enumeration of the modes supported in the class.
|
||||
*
|
||||
*/
|
||||
enum QueueMode
|
||||
{
|
||||
QUEUE_MODE_PACKETS, /**< Use number of packets for maximum queue size */
|
||||
QUEUE_MODE_BYTES, /**< Use number of bytes for maximum queue size */
|
||||
};
|
||||
|
||||
#if 0
|
||||
// average calculation requires keeping around
|
||||
// a buffer with the date of arrival of past received packets
|
||||
|
||||
@@ -81,11 +81,11 @@ TypeId RedQueue::GetTypeId (void)
|
||||
.SetParent<Queue> ()
|
||||
.AddConstructor<RedQueue> ()
|
||||
.AddAttribute ("Mode",
|
||||
"Bytes or packets",
|
||||
EnumValue (PACKETS),
|
||||
"Determines unit for QueueLimit",
|
||||
EnumValue (QUEUE_MODE_PACKETS),
|
||||
MakeEnumAccessor (&RedQueue::SetMode),
|
||||
MakeEnumChecker (BYTES, "Bytes",
|
||||
PACKETS, "Packets"))
|
||||
MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
|
||||
QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
|
||||
.AddAttribute ("MeanPktSize",
|
||||
"Average of packet size",
|
||||
UintegerValue (500),
|
||||
@@ -166,13 +166,13 @@ RedQueue::~RedQueue ()
|
||||
}
|
||||
|
||||
void
|
||||
RedQueue::SetMode (enum Mode mode)
|
||||
RedQueue::SetMode (RedQueue::QueueMode mode)
|
||||
{
|
||||
NS_LOG_FUNCTION (mode);
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
RedQueue::Mode
|
||||
RedQueue::QueueMode
|
||||
RedQueue::GetMode (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -215,12 +215,12 @@ RedQueue::DoEnqueue (Ptr<Packet> p)
|
||||
|
||||
uint32_t nQueued = 0;
|
||||
|
||||
if (GetMode () == BYTES)
|
||||
if (GetMode () == QUEUE_MODE_BYTES)
|
||||
{
|
||||
NS_LOG_DEBUG ("Enqueue in bytes mode");
|
||||
nQueued = m_bytesInQueue;
|
||||
}
|
||||
else if (GetMode () == PACKETS)
|
||||
else if (GetMode () == QUEUE_MODE_PACKETS)
|
||||
{
|
||||
NS_LOG_DEBUG ("Enqueue in packets mode");
|
||||
nQueued = m_packets.size ();
|
||||
@@ -540,7 +540,7 @@ RedQueue::ModifyP (double p, uint32_t count, uint32_t countBytes,
|
||||
NS_LOG_FUNCTION (this << p << count << countBytes << meanPktSize << isWait << size);
|
||||
double count1 = (double) count;
|
||||
|
||||
if (GetMode () == BYTES)
|
||||
if (GetMode () == QUEUE_MODE_BYTES)
|
||||
{
|
||||
count1 = (double) (countBytes / meanPktSize);
|
||||
}
|
||||
@@ -572,7 +572,7 @@ RedQueue::ModifyP (double p, uint32_t count, uint32_t countBytes,
|
||||
}
|
||||
}
|
||||
|
||||
if ((GetMode () == BYTES) && (p < 1.0))
|
||||
if ((GetMode () == QUEUE_MODE_BYTES) && (p < 1.0))
|
||||
{
|
||||
p = (p * size) / meanPktSize;
|
||||
}
|
||||
@@ -589,11 +589,11 @@ uint32_t
|
||||
RedQueue::GetQueueSize (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
if (GetMode () == BYTES)
|
||||
if (GetMode () == QUEUE_MODE_BYTES)
|
||||
{
|
||||
return m_bytesInQueue;
|
||||
}
|
||||
else if (GetMode () == PACKETS)
|
||||
else if (GetMode () == QUEUE_MODE_PACKETS)
|
||||
{
|
||||
return m_packets.size ();
|
||||
}
|
||||
|
||||
@@ -127,24 +127,13 @@ public:
|
||||
DTYPE_UNFORCED, // An "unforced" (random) drop
|
||||
};
|
||||
|
||||
/*
|
||||
* \brief Enumeration of the modes supported in the class.
|
||||
*
|
||||
*/
|
||||
enum Mode
|
||||
{
|
||||
ILLEGAL, // Mode not set
|
||||
PACKETS, // Use number of packets for maximum queue size
|
||||
BYTES, // Use number of bytes for maximum queue size
|
||||
};
|
||||
|
||||
/*
|
||||
* \brief Set the operating mode of this queue.
|
||||
* Set operating mode
|
||||
*
|
||||
* \param mode The operating mode of this queue.
|
||||
*/
|
||||
void SetMode (RedQueue::Mode mode);
|
||||
void SetMode (RedQueue::QueueMode mode);
|
||||
|
||||
/*
|
||||
* \brief Get the encapsulation mode of this queue.
|
||||
@@ -152,7 +141,7 @@ public:
|
||||
*
|
||||
* \returns The encapsulation mode of this queue.
|
||||
*/
|
||||
RedQueue::Mode GetMode (void);
|
||||
RedQueue::QueueMode GetMode (void);
|
||||
|
||||
/*
|
||||
* \brief Get the current value of the queue in bytes or packets.
|
||||
@@ -209,7 +198,7 @@ private:
|
||||
|
||||
// ** Variables supplied by user
|
||||
// Bytes or packets?
|
||||
Mode m_mode;
|
||||
QueueMode m_mode;
|
||||
// Avg pkt size
|
||||
uint32_t m_meanPktSize;
|
||||
// Avg pkt size used during idle times
|
||||
|
||||
@@ -94,7 +94,7 @@ ErrorModelSimple::DoRun (void)
|
||||
|
||||
Ptr<RateErrorModel> em = CreateObjectWithAttributes<RateErrorModel> ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0)));
|
||||
em->SetAttribute ("ErrorRate", DoubleValue (0.001));
|
||||
em->SetAttribute ("ErrorUnit", StringValue ("EU_PKT"));
|
||||
em->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
|
||||
|
||||
// The below hooks will cause drops and receptions to be counted
|
||||
output->SetAttribute ("ReceiveErrorModel", PointerValue (em));
|
||||
|
||||
Reference in New Issue
Block a user