--- a/src/network/examples/droptail_vs_red.cc Wed Dec 21 21:14:09 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: John Abraham <john.abraham@gatech.edu>
- *
- */
-
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/applications-module.h"
-#include "ns3/point-to-point-layout-module.h"
-
-#include <iostream>
-#include <iomanip>
-#include <map>
-
-using namespace ns3;
-using namespace std;
-
-
-int main (int argc, char *argv[])
-{
- uint32_t nLeaf = 5;
- uint32_t maxPackets = 100;
- uint32_t modeBytes = 0;
- double minTh = 50;
- double maxTh = 80;
- uint32_t pktSize = 512;
- std::string appDataRate = "10Mbps";
- std::string queueType = "DropTail";
- uint16_t port = 5001;
- std::string bottleNeckLinkBw = "1Mbps";
- std::string bottleNeckLinkDelay = "50ms";
-
- CommandLine cmd;
- cmd.AddValue ("nLeaf", "Number of left and right side leaf nodes", nLeaf);
- cmd.AddValue ("maxPackets","Max Packets allowed in the queue", maxPackets);
- cmd.AddValue ("queueType", "Set Queue type to DropTail or RED", queueType);
- cmd.AddValue ("appPktSize", "Set OnOff App Packet Size", pktSize);
- cmd.AddValue ("appDataRate", "Set OnOff App DataRate", appDataRate);
- cmd.AddValue ("modeBytes", "Set Queue mode to Packets <0> or bytes <1>", modeBytes);
-
- cmd.AddValue ("redMinTh", "RED queue minimum threshold", minTh);
- cmd.AddValue ("redMaxTh", "RED queue maximum threshold", maxTh);
- cmd.Parse (argc,argv);
-
- if ((queueType != "RED") && (queueType != "DropTail"))
- {
- NS_ABORT_MSG ("Invalid queue type: Use --queueType=RED or --queueType=DropTail");
- }
-
- Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSize));
- Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRate));
-
-
- if (!modeBytes)
- {
- Config::SetDefault ("ns3::DropTailQueue::Mode", StringValue ("Packets"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (maxPackets));
- Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("Packets"));
- Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (maxPackets));
- }
- else
- {
- Config::SetDefault ("ns3::DropTailQueue::Mode", StringValue ("Bytes"));
- Config::SetDefault ("ns3::DropTailQueue::MaxBytes", UintegerValue (maxPackets * pktSize));
- Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("Bytes"));
- Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (maxPackets * pktSize));
- minTh *= pktSize;
- maxTh *= pktSize;
- }
-
- // Create the point-to-point link helpers
- PointToPointHelper bottleNeckLink;
- bottleNeckLink.SetDeviceAttribute ("DataRate", StringValue (bottleNeckLinkBw));
- bottleNeckLink.SetChannelAttribute ("Delay", StringValue (bottleNeckLinkDelay));
- if (queueType == "RED")
- {
- bottleNeckLink.SetQueue ("ns3::RedQueue",
- "MinTh", DoubleValue (minTh),
- "MaxTh", DoubleValue (maxTh),
- "LinkBandwidth", StringValue (bottleNeckLinkBw),
- "LinkDelay", StringValue (bottleNeckLinkDelay));
- }
- PointToPointHelper pointToPointLeaf;
- pointToPointLeaf.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
- pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("1ms"));
-
- PointToPointDumbbellHelper d (nLeaf, pointToPointLeaf,
- nLeaf, pointToPointLeaf,
- bottleNeckLink);
-
- // Install Stack
- InternetStackHelper stack;
- d.InstallStack (stack);
-
- // Assign IP Addresses
- d.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"),
- Ipv4AddressHelper ("10.2.1.0", "255.255.255.0"),
- Ipv4AddressHelper ("10.3.1.0", "255.255.255.0"));
-
- // Install on/off app on all right side nodes
- OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
- clientHelper.SetAttribute ("OnTime", RandomVariableValue (UniformVariable (0, 1)));
- clientHelper.SetAttribute ("OffTime", RandomVariableValue (UniformVariable (0, 1)));
- Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
- PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
- ApplicationContainer sinkApps;
- for (uint32_t i = 0; i < d.LeftCount (); ++i)
- {
- sinkApps.Add (packetSinkHelper.Install (d.GetLeft (i)));
- }
- sinkApps.Start (Seconds (0.0));
- sinkApps.Stop (Seconds (30.0));
-
- ApplicationContainer clientApps;
- for (uint32_t i = 0; i < d.RightCount (); ++i)
- {
- // Create an on/off app sending packets to the left side
- AddressValue remoteAddress (InetSocketAddress (d.GetLeftIpv4Address (i), port));
- clientHelper.SetAttribute ("Remote", remoteAddress);
- clientApps.Add (clientHelper.Install (d.GetRight (i)));
- }
- clientApps.Start (Seconds (1.0)); // Start 1 second after sink
- clientApps.Stop (Seconds (15.0)); // Stop before the sink
-
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
- std::cout << "Running the simulation" << std::endl;
- Simulator::Run ();
-
- uint32_t totalRxBytesCounter = 0;
- for (uint32_t i = 0; i < sinkApps.GetN (); i++)
- {
- Ptr <Application> app = sinkApps.Get (i);
- Ptr <PacketSink> pktSink = DynamicCast <PacketSink> (app);
- totalRxBytesCounter += pktSink->GetTotalRx ();
- }
- NS_LOG_UNCOND ("----------------------------\nQueue Type:"
- << queueType
- << "\nGoodput Bytes/sec:"
- << totalRxBytesCounter/Simulator::Now ().GetSeconds ());
- NS_LOG_UNCOND ("----------------------------");
-
-
- std::cout << "Destroying the simulation" << std::endl;
- Simulator::Destroy ();
- return 0;
-}
--- a/src/network/examples/red-tests.cc Wed Dec 21 21:14:09 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,482 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Authors: Marcos Talau <talau@users.sourceforge.net>
- * Duy Nguyen <duy@soe.ucsc.edu>
- *
- */
-
-/**
- * These validation tests are detailed in http://icir.org/floyd/papers/redsims.ps
- *
- * In this code the tests 1, 3, 4 and 5 refer to the tests corresponding to
- * Figure 1, 3, 4, and 5 respectively from the document mentioned above.
- */
-
-/** Network topology
- *
- * 10Mb/s, 2ms 10Mb/s, 4ms
- * n0--------------| |---------------n4
- * | 1.5Mbps/s, 20ms |
- * n2------------------n3
- * 10Mb/s, 3ms | | 10Mb/s, 5ms
- * n1--------------| |---------------n5
- *
- *
- */
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/flow-monitor-helper.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/applications-module.h"
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("RedTests");
-
-uint32_t checkTimes;
-double avgQueueSize;
-
-// The times
-double global_start_time;
-double global_stop_time;
-double sink_start_time;
-double sink_stop_time;
-double client_start_time;
-double client_stop_time;
-
-NodeContainer n0n2;
-NodeContainer n1n2;
-NodeContainer n2n3;
-NodeContainer n3n4;
-NodeContainer n3n5;
-
-Ipv4InterfaceContainer i0i2;
-Ipv4InterfaceContainer i1i2;
-Ipv4InterfaceContainer i2i3;
-Ipv4InterfaceContainer i3i4;
-Ipv4InterfaceContainer i3i5;
-
-std::stringstream filePlotQueue;
-std::stringstream filePlotQueueAvg;
-
-void
-CheckQueueSize (Ptr<Queue> queue)
-{
- uint32_t qSize = StaticCast<RedQueue> (queue)->GetQueueSize ();
-
- avgQueueSize += qSize;
- checkTimes++;
-
- // check queue size every 1/100 of a second
- Simulator::Schedule (Seconds (0.01), &CheckQueueSize, queue);
-
- std::ofstream fPlotQueue (filePlotQueue.str ().c_str (), std::ios::out|std::ios::app);
- fPlotQueue << Simulator::Now ().GetSeconds () << " " << qSize << std::endl;
- fPlotQueue.close ();
-
- std::ofstream fPlotQueueAvg (filePlotQueueAvg.str ().c_str (), std::ios::out|std::ios::app);
- fPlotQueueAvg << Simulator::Now ().GetSeconds () << " " << avgQueueSize / checkTimes << std::endl;
- fPlotQueueAvg.close ();
-}
-
-void
-BuildAppsTest (uint32_t test)
-{
- if ( (test == 1) || (test == 3) )
- {
- // SINK is in the right side
- uint16_t port = 50000;
- Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
- PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
- ApplicationContainer sinkApp = sinkHelper.Install (n3n4.Get (1));
- sinkApp.Start (Seconds (sink_start_time));
- sinkApp.Stop (Seconds (sink_stop_time));
-
- // Connection one
- // Clients are in left side
- /*
- * Create the OnOff applications to send TCP to the server
- * onoffhelper is a client that send data to TCP destination
- */
- OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ());
- clientHelper1.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper1.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper1.SetAttribute
- ("DataRate", DataRateValue (DataRate ("10Mb/s")));
- clientHelper1.SetAttribute
- ("PacketSize", UintegerValue (1000));
-
- ApplicationContainer clientApps1;
- AddressValue remoteAddress
- (InetSocketAddress (i3i4.GetAddress (1), port));
- clientHelper1.SetAttribute ("Remote", remoteAddress);
- clientApps1.Add (clientHelper1.Install (n0n2.Get (0)));
- clientApps1.Start (Seconds (client_start_time));
- clientApps1.Stop (Seconds (client_stop_time));
-
- // Connection two
- OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ());
- clientHelper2.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper2.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper2.SetAttribute
- ("DataRate", DataRateValue (DataRate ("10Mb/s")));
- clientHelper2.SetAttribute
- ("PacketSize", UintegerValue (1000));
-
- ApplicationContainer clientApps2;
- clientHelper2.SetAttribute ("Remote", remoteAddress);
- clientApps2.Add (clientHelper2.Install (n1n2.Get (0)));
- clientApps2.Start (Seconds (3.0));
- clientApps2.Stop (Seconds (client_stop_time));
- }
- else // 4 or 5
- {
- // SINKs
- // #1
- uint16_t port1 = 50001;
- Address sinkLocalAddress1 (InetSocketAddress (Ipv4Address::GetAny (), port1));
- PacketSinkHelper sinkHelper1 ("ns3::TcpSocketFactory", sinkLocalAddress1);
- ApplicationContainer sinkApp1 = sinkHelper1.Install (n3n4.Get (1));
- sinkApp1.Start (Seconds (sink_start_time));
- sinkApp1.Stop (Seconds (sink_stop_time));
- // #2
- uint16_t port2 = 50002;
- Address sinkLocalAddress2 (InetSocketAddress (Ipv4Address::GetAny (), port2));
- PacketSinkHelper sinkHelper2 ("ns3::TcpSocketFactory", sinkLocalAddress2);
- ApplicationContainer sinkApp2 = sinkHelper2.Install (n3n5.Get (1));
- sinkApp2.Start (Seconds (sink_start_time));
- sinkApp2.Stop (Seconds (sink_stop_time));
- // #3
- uint16_t port3 = 50003;
- Address sinkLocalAddress3 (InetSocketAddress (Ipv4Address::GetAny (), port3));
- PacketSinkHelper sinkHelper3 ("ns3::TcpSocketFactory", sinkLocalAddress3);
- ApplicationContainer sinkApp3 = sinkHelper3.Install (n0n2.Get (0));
- sinkApp3.Start (Seconds (sink_start_time));
- sinkApp3.Stop (Seconds (sink_stop_time));
- // #4
- uint16_t port4 = 50004;
- Address sinkLocalAddress4 (InetSocketAddress (Ipv4Address::GetAny (), port4));
- PacketSinkHelper sinkHelper4 ("ns3::TcpSocketFactory", sinkLocalAddress4);
- ApplicationContainer sinkApp4 = sinkHelper4.Install (n1n2.Get (0));
- sinkApp4.Start (Seconds (sink_start_time));
- sinkApp4.Stop (Seconds (sink_stop_time));
-
- // Connection #1
- /*
- * Create the OnOff applications to send TCP to the server
- * onoffhelper is a client that send data to TCP destination
- */
- OnOffHelper clientHelper1 ("ns3::TcpSocketFactory", Address ());
- clientHelper1.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper1.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper1.SetAttribute
- ("DataRate", DataRateValue (DataRate ("10Mb/s")));
- clientHelper1.SetAttribute
- ("PacketSize", UintegerValue (1000));
-
- ApplicationContainer clientApps1;
- AddressValue remoteAddress1
- (InetSocketAddress (i3i4.GetAddress (1), port1));
- clientHelper1.SetAttribute ("Remote", remoteAddress1);
- clientApps1.Add (clientHelper1.Install (n0n2.Get (0)));
- clientApps1.Start (Seconds (client_start_time));
- clientApps1.Stop (Seconds (client_stop_time));
-
- // Connection #2
- OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ());
- clientHelper2.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper2.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper2.SetAttribute
- ("DataRate", DataRateValue (DataRate ("10Mb/s")));
- clientHelper2.SetAttribute
- ("PacketSize", UintegerValue (1000));
-
- ApplicationContainer clientApps2;
- AddressValue remoteAddress2
- (InetSocketAddress (i3i5.GetAddress (1), port2));
- clientHelper2.SetAttribute ("Remote", remoteAddress2);
- clientApps2.Add (clientHelper2.Install (n1n2.Get (0)));
- clientApps2.Start (Seconds (2.0));
- clientApps2.Stop (Seconds (client_stop_time));
-
- // Connection #3
- OnOffHelper clientHelper3 ("ns3::TcpSocketFactory", Address ());
- clientHelper3.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper3.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper3.SetAttribute
- ("DataRate", DataRateValue (DataRate ("10Mb/s")));
- clientHelper3.SetAttribute
- ("PacketSize", UintegerValue (1000));
-
- ApplicationContainer clientApps3;
- AddressValue remoteAddress3
- (InetSocketAddress (i0i2.GetAddress (0), port3));
- clientHelper3.SetAttribute ("Remote", remoteAddress3);
- clientApps3.Add (clientHelper3.Install (n3n4.Get (1)));
- clientApps3.Start (Seconds (3.5));
- clientApps3.Stop (Seconds (client_stop_time));
-
- // Connection #4
- OnOffHelper clientHelper4 ("ns3::TcpSocketFactory", Address ());
- clientHelper4.SetAttribute
- ("OnTime", RandomVariableValue (ConstantVariable (1)));
- clientHelper4.SetAttribute
- ("OffTime", RandomVariableValue (ConstantVariable (0)));
- clientHelper4.SetAttribute
- ("DataRate", DataRateValue (DataRate ("40b/s")));
- clientHelper4.SetAttribute
- ("PacketSize", UintegerValue (5 * 8)); // telnet
-
- ApplicationContainer clientApps4;
- AddressValue remoteAddress4
- (InetSocketAddress (i1i2.GetAddress (0), port4));
- clientHelper4.SetAttribute ("Remote", remoteAddress4);
- clientApps4.Add (clientHelper4.Install (n3n5.Get (1)));
- clientApps4.Start (Seconds (1.0));
- clientApps4.Stop (Seconds (client_stop_time));
- }
-}
-
-int
-main (int argc, char *argv[])
-{
- // LogComponentEnable ("RedExamples", LOG_LEVEL_INFO);
- // LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
- // LogComponentEnable ("RedQueue", LOG_LEVEL_FUNCTION);
- LogComponentEnable ("RedQueue", LOG_LEVEL_INFO);
-
- uint32_t redTest;
- std::string redLinkDataRate = "1.5Mbps";
- std::string redLinkDelay = "20ms";
-
- std::string pathOut;
- bool writeForPlot = false;
- bool writePcap = false;
- bool flowMonitor = false;
-
- bool printRedStats = true;
-
- global_start_time = 0.0;
- global_stop_time = 11;
- sink_start_time = global_start_time;
- sink_stop_time = global_stop_time + 3.0;
- client_start_time = sink_start_time + 0.2;
- client_stop_time = global_stop_time - 2.0;
-
- // Configuration and command line parameter parsing
- redTest = 1;
- // Will only save in the directory if enable opts below
- pathOut = "."; // Current directory
- CommandLine cmd;
- cmd.AddValue ("testNumber", "Run test 1, 3, 4 or 5", redTest);
- cmd.AddValue ("pathOut", "Path to save results from --writeForPlot/--writePcap/--writeFlowMonitor", pathOut);
- cmd.AddValue ("writeForPlot", "<0/1> to write results for plot (gnuplot)", writeForPlot);
- cmd.AddValue ("writePcap", "<0/1> to write results in pcapfile", writePcap);
- cmd.AddValue ("writeFlowMonitor", "<0/1> to enable Flow Monitor and write their results", flowMonitor);
-
- cmd.Parse (argc, argv);
- if ( (redTest != 1) && (redTest != 3) && (redTest != 4) && (redTest != 5) )
- {
- NS_ABORT_MSG ("Invalid test number. Supported tests are 1, 3, 4 or 5");
- }
-
- NS_LOG_INFO ("Create nodes");
- NodeContainer c;
- c.Create (6);
- Names::Add ( "N0", c.Get (0));
- Names::Add ( "N1", c.Get (1));
- Names::Add ( "N2", c.Get (2));
- Names::Add ( "N3", c.Get (3));
- Names::Add ( "N4", c.Get (4));
- Names::Add ( "N5", c.Get (5));
- n0n2 = NodeContainer (c.Get (0), c.Get (2));
- n1n2 = NodeContainer (c.Get (1), c.Get (2));
- n2n3 = NodeContainer (c.Get (2), c.Get (3));
- n3n4 = NodeContainer (c.Get (3), c.Get (4));
- n3n5 = NodeContainer (c.Get (3), c.Get (5));
-
- Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpReno"));
- // 42 = headers size
- Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000 - 42));
- Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
- GlobalValue::Bind ("ChecksumEnabled", BooleanValue (false));
-
- uint32_t meanPktSize = 500;
-
- // RED params
- NS_LOG_INFO ("Set RED params");
- Config::SetDefault ("ns3::RedQueue::Mode", StringValue ("Packets"));
- Config::SetDefault ("ns3::RedQueue::MeanPktSize", UintegerValue (meanPktSize));
- Config::SetDefault ("ns3::RedQueue::Wait", BooleanValue (true));
- Config::SetDefault ("ns3::RedQueue::Gentle", BooleanValue (true));
- Config::SetDefault ("ns3::RedQueue::QW", DoubleValue (0.002));
- Config::SetDefault ("ns3::RedQueue::MinTh", DoubleValue (5));
- Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (15));
- Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (25));
-
- if (redTest == 3) // test like 1, but with bad params
- {
- Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (10));
- Config::SetDefault ("ns3::RedQueue::QW", DoubleValue (0.003));
- }
- 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::Ns1Compat", BooleanValue (true));
- Config::SetDefault ("ns3::RedQueue::MinTh", DoubleValue (5 * meanPktSize));
- Config::SetDefault ("ns3::RedQueue::MaxTh", DoubleValue (15 * meanPktSize));
- Config::SetDefault ("ns3::RedQueue::QueueLimit", UintegerValue (25 * meanPktSize));
- }
-
- NS_LOG_INFO ("Install internet stack on all nodes.");
- InternetStackHelper internet;
- internet.Install (c);
-
- NS_LOG_INFO ("Create channels");
- PointToPointHelper p2p;
-
- p2p.SetQueue ("ns3::DropTailQueue");
- p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
- p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
- NetDeviceContainer devn0n2 = p2p.Install (n0n2);
-
- p2p.SetQueue ("ns3::DropTailQueue");
- p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
- p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
- NetDeviceContainer devn1n2 = p2p.Install (n1n2);
-
- p2p.SetQueue ("ns3::RedQueue", // only backbone link has RED queue
- "LinkBandwidth", StringValue (redLinkDataRate),
- "LinkDelay", StringValue (redLinkDelay));
- p2p.SetDeviceAttribute ("DataRate", StringValue (redLinkDataRate));
- p2p.SetChannelAttribute ("Delay", StringValue (redLinkDelay));
- NetDeviceContainer devn2n3 = p2p.Install (n2n3);
-
- p2p.SetQueue ("ns3::DropTailQueue");
- p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
- p2p.SetChannelAttribute ("Delay", StringValue ("4ms"));
- NetDeviceContainer devn3n4 = p2p.Install (n3n4);
-
- p2p.SetQueue ("ns3::DropTailQueue");
- p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
- p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
- NetDeviceContainer devn3n5 = p2p.Install (n3n5);
-
- NS_LOG_INFO ("Assign IP Addresses");
- Ipv4AddressHelper ipv4;
-
- ipv4.SetBase ("10.1.1.0", "255.255.255.0");
- i0i2 = ipv4.Assign (devn0n2);
-
- ipv4.SetBase ("10.1.2.0", "255.255.255.0");
- i1i2 = ipv4.Assign (devn1n2);
-
- ipv4.SetBase ("10.1.3.0", "255.255.255.0");
- i2i3 = ipv4.Assign (devn2n3);
-
- ipv4.SetBase ("10.1.4.0", "255.255.255.0");
- i3i4 = ipv4.Assign (devn3n4);
-
- ipv4.SetBase ("10.1.5.0", "255.255.255.0");
- i3i5 = ipv4.Assign (devn3n5);
-
- // Set up the routing
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
- if (redTest == 5)
- {
- // like in ns2 test, r2 -> r1, have a queue in packet mode
- Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (1));
- Ptr<Queue> queue = nd->GetQueue ();
-
- StaticCast<RedQueue> (queue)->SetMode (RedQueue::PACKETS);
- StaticCast<RedQueue> (queue)->SetTh (5, 15);
- StaticCast<RedQueue> (queue)->SetQueueLimit (25);
- }
-
- BuildAppsTest (redTest);
-
- if (writePcap)
- {
- PointToPointHelper ptp;
- std::stringstream stmp;
- stmp << pathOut << "/red";
- ptp.EnablePcapAll (stmp.str ().c_str ());
- }
-
- Ptr<FlowMonitor> flowmon;
- if (flowMonitor)
- {
- FlowMonitorHelper flowmonHelper;
- flowmon = flowmonHelper.InstallAll ();
- }
-
- if (writeForPlot)
- {
- filePlotQueue << pathOut << "/" << "red-queue.plotme";
- filePlotQueueAvg << pathOut << "/" << "red-queue_avg.plotme";
-
- remove (filePlotQueue.str ().c_str ());
- remove (filePlotQueueAvg.str ().c_str ());
- Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (0));
- Ptr<Queue> queue = nd->GetQueue ();
- Simulator::ScheduleNow (&CheckQueueSize, queue);
- }
-
- Simulator::Stop (Seconds (sink_stop_time));
- Simulator::Run ();
-
- if (flowMonitor)
- {
- std::stringstream stmp;
- stmp << pathOut << "/red.flowmon";
-
- flowmon->SerializeToXmlFile (stmp.str ().c_str (), false, false);
- }
-
- if (printRedStats)
- {
- Ptr<PointToPointNetDevice> nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (0));
- RedQueue::Stats st = StaticCast<RedQueue> (nd->GetQueue ())->GetStats ();
- std::cout << "*** RED stats from Node 2 queue ***" << std::endl;
- std::cout << "\t " << st.unforcedDrop << " drops due prob mark" << std::endl;
- std::cout << "\t " << st.forcedDrop << " drops due hard mark" << std::endl;
- std::cout << "\t " << st.qLimDrop << " drops due queue full" << std::endl;
-
- nd = StaticCast<PointToPointNetDevice> (devn2n3.Get (1));
- st = StaticCast<RedQueue> (nd->GetQueue ())->GetStats ();
- std::cout << "*** RED stats from Node 3 queue ***" << std::endl;
- std::cout << "\t " << st.unforcedDrop << " drops due prob mark" << std::endl;
- std::cout << "\t " << st.forcedDrop << " drops due hard mark" << std::endl;
- std::cout << "\t " << st.qLimDrop << " drops due queue full" << std::endl;
- }
-
- Simulator::Destroy ();
-
- return 0;
-}
--- a/src/network/examples/wscript Wed Dec 21 21:14:09 2011 -0800
+++ b/src/network/examples/wscript Wed Dec 21 21:51:50 2011 -0800
@@ -9,9 +9,3 @@
obj = bld.create_ns3_program('main-packet-tag', ['network'])
obj.source = 'main-packet-tag.cc'
-
- obj = bld.create_ns3_program('red-tests', ['point-to-point', 'internet', 'applications', 'flow-monitor'])
- obj.source = 'red-tests.cc'
-
- obj = bld.create_ns3_program('droptail_vs_red', ['point-to-point', 'point-to-point-layout', 'internet', 'applications'])
- obj.source = 'droptail_vs_red.cc'
--- a/src/network/test/red-queue-test-suite.cc Wed Dec 21 21:14:09 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,283 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright © 2011 Marcos Talau
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Marcos Talau (talau@users.sourceforge.net)
- *
- */
-
-#include "ns3/test.h"
-#include "ns3/red-queue.h"
-#include "ns3/uinteger.h"
-#include "ns3/string.h"
-#include "ns3/double.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-namespace ns3 {
-
-class RedQueueTestCase : public TestCase
-{
-public:
- RedQueueTestCase ();
- virtual void DoRun (void);
-private:
- void Enqueue (Ptr<RedQueue> queue, uint32_t size, uint32_t nPkt);
- void RunRedTest (StringValue mode);
-};
-
-RedQueueTestCase::RedQueueTestCase ()
- : TestCase ("Sanity check on the red queue implementation")
-{
-}
-
-void
-RedQueueTestCase::RunRedTest (StringValue mode)
-{
- uint32_t pktSize = 0;
- // 1 for packets; pktSize for bytes
- uint32_t modeSize = 1;
- double minTh = 2;
- double maxTh = 5;
- uint32_t qSize = 8;
- Ptr<RedQueue> queue = CreateObject<RedQueue> ();
-
- // 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 ("QW", DoubleValue (0.002)), true,
- "Verify that we can actually set the attribute QW");
-
- if (queue->GetMode () == RedQueue::BYTES)
- {
- pktSize = 1000;
- modeSize = pktSize;
- queue->SetTh (minTh * pktSize, maxTh * pktSize);
- queue->SetQueueLimit (qSize * pktSize);
- }
-
- Ptr<Packet> p1, p2, p3, p4, p5, p6, p7, p8;
- p1 = Create<Packet> (pktSize);
- p2 = Create<Packet> (pktSize);
- p3 = Create<Packet> (pktSize);
- p4 = Create<Packet> (pktSize);
- p5 = Create<Packet> (pktSize);
- p6 = Create<Packet> (pktSize);
- p7 = Create<Packet> (pktSize);
- p8 = Create<Packet> (pktSize);
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in there");
- queue->Enqueue (p1);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in there");
- queue->Enqueue (p2);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in there");
- queue->Enqueue (p3);
- queue->Enqueue (p4);
- queue->Enqueue (p5);
- queue->Enqueue (p6);
- queue->Enqueue (p7);
- queue->Enqueue (p8);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 8 * modeSize, "There should be eight packets in there");
-
- Ptr<Packet> p;
-
- p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p != 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 (p->GetUid (), p1->GetUid (), "was this the first packet ?");
-
- p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p != 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 (p->GetUid (), p2->GetUid (), "Was this the second packet ?");
-
- p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p != 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 (p->GetUid (), p3->GetUid (), "Was this the third packet ?");
-
- p = queue->Dequeue ();
- p = queue->Dequeue ();
- p = queue->Dequeue ();
- p = queue->Dequeue ();
- p = queue->Dequeue ();
-
- p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in there");
-
-
- // test 2: more data, but with no drops
- queue = CreateObject<RedQueue> ();
- 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");
- Enqueue (queue, pktSize, 300);
- RedQueue::Stats st = StaticCast<RedQueue> (queue)->GetStats ();
- NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should zero dropped packets due probability mark");
- NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should zero dropped packets due hardmark mark");
- NS_TEST_EXPECT_MSG_EQ (st.qLimDrop, 0, "There should zero dropped packets due queue full");
-
- // save number of drops from tests
- struct d {
- uint32_t test3;
- uint32_t test4;
- uint32_t test5;
- uint32_t test6;
- uint32_t test7;
- } drop;
-
-
- // test 3: more data, now drops due QW change
- queue = CreateObject<RedQueue> ();
- 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 ("QW", DoubleValue (0.020)), true,
- "Verify that we can actually set the attribute QW");
- Enqueue (queue, pktSize, 300);
- st = StaticCast<RedQueue> (queue)->GetStats ();
- drop.test3 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
- NS_TEST_EXPECT_MSG_NE (drop.test3, 0, "There should be some dropped packets");
-
-
- // test 4: reduced maxTh, this causes more drops
- maxTh = 100 * modeSize;
- queue = CreateObject<RedQueue> ();
- 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 ("QW", DoubleValue (0.020)), true,
- "Verify that we can actually set the attribute QW");
- Enqueue (queue, pktSize, 300);
- st = StaticCast<RedQueue> (queue)->GetStats ();
- drop.test4 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
- NS_TEST_EXPECT_MSG_GT (drop.test4, drop.test3, "Test 4 should have more drops than test 3");
-
-
- // test 5: change drop probability to a high value (LInterm)
- maxTh = 150 * modeSize;
- queue = CreateObject<RedQueue> ();
- 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 ("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,
- "Verify that we can actually set the attribute LInterm");
- Enqueue (queue, pktSize, 300);
- st = StaticCast<RedQueue> (queue)->GetStats ();
- drop.test5 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
- NS_TEST_EXPECT_MSG_GT (drop.test5, drop.test3, "Test 5 should have more drops than test 3");
-
-
- // test 6: disable Gentle param
- queue = CreateObject<RedQueue> ();
- 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 ("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,
- "Verify that we can actually set the attribute Gentle");
- Enqueue (queue, pktSize, 300);
- st = StaticCast<RedQueue> (queue)->GetStats ();
- drop.test6 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
- NS_TEST_EXPECT_MSG_GT (drop.test6, drop.test3, "Test 6 should have more drops than test 3");
-
-
- // test 7: disable Wait param
- queue = CreateObject<RedQueue> ();
- 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 ("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,
- "Verify that we can actually set the attribute Wait");
- Enqueue (queue, pktSize, 300);
- st = StaticCast<RedQueue> (queue)->GetStats ();
- drop.test7 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
- NS_TEST_EXPECT_MSG_GT (drop.test7, drop.test3, "Test 7 should have more drops than test 3");
-}
-
-void
-RedQueueTestCase::Enqueue (Ptr<RedQueue> queue, uint32_t size, uint32_t nPkt)
-{
- for (uint32_t i = 0; i < nPkt; i++)
- {
- queue->Enqueue (Create<Packet> (size));
- }
-}
-
-void
-RedQueueTestCase::DoRun (void)
-{
- RunRedTest (StringValue ("Packets"));
- RunRedTest (StringValue ("Bytes"));
- Simulator::Destroy ();
-
-}
-
-static class RedQueueTestSuite : public TestSuite
-{
-public:
- RedQueueTestSuite ()
- : TestSuite ("red-queue", UNIT)
- {
- AddTestCase (new RedQueueTestCase ());
- }
-} g_redQueueTestSuite;
-
-} // namespace ns3
--- a/src/network/wscript Wed Dec 21 21:14:09 2011 -0800
+++ b/src/network/wscript Wed Dec 21 21:51:50 2011 -0800
@@ -47,7 +47,6 @@
'utils/pcap-file-wrapper.cc',
'utils/queue.cc',
'utils/radiotap-header.cc',
- 'utils/red-queue.cc',
'utils/simple-channel.cc',
'utils/simple-net-device.cc',
'helper/application-container.cc',
@@ -65,7 +64,6 @@
'test/packet-test-suite.cc',
'test/packet-metadata-test.cc',
'test/pcap-file-test-suite.cc',
- 'test/red-queue-test-suite.cc',
'test/sequence-number-test-suite.cc',
]
@@ -117,7 +115,6 @@
'utils/generic-phy.h',
'utils/queue.h',
'utils/radiotap-header.h',
- 'utils/red-queue.h',
'utils/sequence-number.h',
'utils/sgi-hashmap.h',
'utils/simple-channel.h',