diff --git a/examples/error-model/simple-error-model.cc b/examples/error-model/simple-error-model.cc index f4c4ad873..52e7c0be3 100644 --- a/examples/error-model/simple-error-model.cc +++ b/examples/error-model/simple-error-model.cc @@ -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"))); diff --git a/src/network/examples/red-tests.cc b/src/network/examples/red-tests.cc index 53514ca7e..deb39c437 100644 --- a/src/network/examples/red-tests.cc +++ b/src/network/examples/red-tests.cc @@ -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 nd = StaticCast (devn2n3.Get (1)); Ptr queue = nd->GetQueue (); - StaticCast (queue)->SetMode (RedQueue::PACKETS); + StaticCast (queue)->SetMode (RedQueue::QUEUE_MODE_PACKETS); StaticCast (queue)->SetTh (5, 15); StaticCast (queue)->SetQueueLimit (25); } diff --git a/src/network/test/red-queue-test-suite.cc b/src/network/test/red-queue-test-suite.cc index da383b807..3ca7b2fd8 100644 --- a/src/network/test/red-queue-test-suite.cc +++ b/src/network/test/red-queue-test-suite.cc @@ -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 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 (); } diff --git a/src/network/utils/drop-tail-queue.cc b/src/network/utils/drop-tail-queue.cc index 03de05210..ff4e31784 100644 --- a/src/network/utils/drop-tail-queue.cc +++ b/src/network/utils/drop-tail-queue.cc @@ -33,11 +33,11 @@ TypeId DropTailQueue::GetTypeId (void) .SetParent () .AddConstructor () .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 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); diff --git a/src/network/utils/drop-tail-queue.h b/src/network/utils/drop-tail-queue.h index 93a020fca..b259b636a 100644 --- a/src/network/utils/drop-tail-queue.h +++ b/src/network/utils/drop-tail-queue.h @@ -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 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 diff --git a/src/network/utils/error-model.cc b/src/network/utils/error-model.cc index d53bd05e5..70ff7b938 100644 --- a/src/network/utils/error-model.cc +++ b/src/network/utils/error-model.cc @@ -111,11 +111,11 @@ TypeId RateErrorModel::GetTypeId (void) .SetParent () .AddConstructor () .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 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"); diff --git a/src/network/utils/error-model.h b/src/network/utils/error-model.h index 919d1b97d..98ff49fce 100644 --- a/src/network/utils/error-model.h +++ b/src/network/utils/error-model.h @@ -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 */ diff --git a/src/network/utils/queue.h b/src/network/utils/queue.h index 824722c81..89b527012 100644 --- a/src/network/utils/queue.h +++ b/src/network/utils/queue.h @@ -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 diff --git a/src/network/utils/red-queue.cc b/src/network/utils/red-queue.cc index 1ff724764..94c4d3ea7 100644 --- a/src/network/utils/red-queue.cc +++ b/src/network/utils/red-queue.cc @@ -81,11 +81,11 @@ TypeId RedQueue::GetTypeId (void) .SetParent () .AddConstructor () .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 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 (); } diff --git a/src/network/utils/red-queue.h b/src/network/utils/red-queue.h index c5d73beee..eee60d797 100644 --- a/src/network/utils/red-queue.h +++ b/src/network/utils/red-queue.h @@ -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 diff --git a/src/test/error-model-test-suite.cc b/src/test/error-model-test-suite.cc index e18921521..44fee9ca4 100644 --- a/src/test/error-model-test-suite.cc +++ b/src/test/error-model-test-suite.cc @@ -94,7 +94,7 @@ ErrorModelSimple::DoRun (void) Ptr em = CreateObjectWithAttributes ("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));