470 lines
21 KiB
C++
470 lines
21 KiB
C++
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
/*
|
|
* Copyright (c) 2015 NITK Surathkal
|
|
*
|
|
* 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: Mohit P. Tahiliani (tahiliani@nitk.edu.in)
|
|
*
|
|
*/
|
|
|
|
#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/traffic-control-module.h"
|
|
|
|
using namespace ns3;
|
|
|
|
// Tests to verify the working of *automatically set* parameters in ARED
|
|
class AutoRedQueueDiscTestCase : public TestCase
|
|
{
|
|
public:
|
|
AutoRedQueueDiscTestCase ();
|
|
virtual void DoRun (void);
|
|
private:
|
|
void Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt);
|
|
void RunAutoRedDiscTest (StringValue mode);
|
|
};
|
|
|
|
AutoRedQueueDiscTestCase::AutoRedQueueDiscTestCase ()
|
|
: TestCase ("Sanity check on automatically set parameters of ARED")
|
|
{
|
|
}
|
|
|
|
void
|
|
AutoRedQueueDiscTestCase::RunAutoRedDiscTest (StringValue mode)
|
|
{
|
|
uint32_t pktSize = 0;
|
|
uint32_t modeSize = 1; // 1 for packets; pktSize for bytes
|
|
Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
|
|
|
|
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
|
|
"Verify that we can actually set the attribute Mode");
|
|
|
|
Ipv4Header ipHeader;
|
|
Address dest;
|
|
|
|
if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
|
|
{
|
|
pktSize = 500;
|
|
modeSize = pktSize + ipHeader.GetSerializedSize ();
|
|
}
|
|
|
|
double minTh = 70 * modeSize;
|
|
double maxTh = 150 * modeSize;
|
|
uint32_t qSize = 300 * modeSize;
|
|
|
|
|
|
// test 1: Verify automatic setting of QW. [QW = 0.0 with default LinkBandwidth]
|
|
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.0)), true,
|
|
"Verify that we can actually set the attribute QW");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
uint32_t drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
|
|
|
|
|
|
// 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 ("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,
|
|
"Verify that we can actually set the attribute LinkBandwidth");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
|
|
|
|
|
|
// 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 ("QW", DoubleValue (-1.0)), true,
|
|
"Verify that we can actually set the attribute QW");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
|
|
|
|
|
|
// 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 ("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,
|
|
"Verify that we can actually set the attribute LinkBandwidth");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
|
|
|
|
|
|
// 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 ("QW", DoubleValue (-2.0)), true,
|
|
"Verify that we can actually set the attribute QW");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
uint32_t test5 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_NE (test5, 0, "There should be some dropped packets");
|
|
|
|
|
|
// 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 ("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,
|
|
"Verify that we can actually set the attribute LinkBandwidth");
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
uint32_t test6 = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_GT (test6, test5, "Test 6 should have more drops than Test 5");
|
|
|
|
|
|
// 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");
|
|
if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
|
|
{
|
|
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerValue (modeSize)), true,
|
|
"Verify that we can actually set the attribute MeanPktSize");
|
|
}
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_NE (drops, 0, "There should be some dropped packets");
|
|
NS_TEST_EXPECT_MSG_GT (st.forcedDrop, st.unforcedDrop, "There should be more packets dropped due to hard mark");
|
|
|
|
|
|
// 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 ("LinkBandwidth", DataRateValue (DataRate ("150Mbps"))), true,
|
|
"Verify that we can actually set the attribute LinkBandwidth");
|
|
if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
|
|
{
|
|
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerValue (modeSize)), true,
|
|
"Verify that we can actually set the attribute MeanPktSize");
|
|
}
|
|
queue->Initialize ();
|
|
Enqueue (queue, pktSize, 300);
|
|
st = StaticCast<RedQueueDisc> (queue)->GetStats ();
|
|
drops = st.unforcedDrop + st.forcedDrop + st.qLimDrop;
|
|
NS_TEST_EXPECT_MSG_EQ (drops, 0, "There should be zero dropped packets");
|
|
}
|
|
|
|
void
|
|
AutoRedQueueDiscTestCase::Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt)
|
|
{
|
|
Ipv4Header ipHeader;
|
|
Address dest;
|
|
for (uint32_t i = 0; i < nPkt; i++)
|
|
{
|
|
queue->Enqueue (Create<Ipv4QueueDiscItem> (Create<Packet> (size), dest, 0, ipHeader));
|
|
}
|
|
}
|
|
|
|
void
|
|
AutoRedQueueDiscTestCase::DoRun (void)
|
|
{
|
|
RunAutoRedDiscTest (StringValue ("QUEUE_MODE_PACKETS"));
|
|
RunAutoRedDiscTest (StringValue ("QUEUE_MODE_BYTES"));
|
|
Simulator::Destroy ();
|
|
}
|
|
|
|
|
|
// Tests to verify the working of *adaptive* parameter in ARED
|
|
class AdaptiveRedQueueDiscTestCase : public TestCase
|
|
{
|
|
public:
|
|
AdaptiveRedQueueDiscTestCase ();
|
|
virtual void DoRun (void);
|
|
private:
|
|
void RunAdaptiveRedDiscTest (StringValue mode);
|
|
};
|
|
|
|
AdaptiveRedQueueDiscTestCase::AdaptiveRedQueueDiscTestCase ()
|
|
: TestCase ("Sanity check on adaptive parameter of ARED")
|
|
{
|
|
}
|
|
|
|
void
|
|
AdaptiveRedQueueDiscTestCase::RunAdaptiveRedDiscTest (StringValue mode)
|
|
{
|
|
uint32_t pktSize = 1000;
|
|
uint32_t modeSize = 1; // 1 for packets; pktSize for bytes
|
|
std::string aredLinkDataRate = "1.5Mbps";
|
|
std::string aredLinkDelay = "20ms";
|
|
|
|
double global_start_time = 0.0;
|
|
double global_stop_time = 7.0;
|
|
double sink_start_time = global_start_time;
|
|
double sink_stop_time = global_stop_time + 3.0;
|
|
double client_start_time = global_start_time + 1.5;
|
|
double client_stop_time = global_stop_time - 2.0;
|
|
|
|
NodeContainer n0n2;
|
|
NodeContainer n1n2;
|
|
NodeContainer n2n3;
|
|
NodeContainer n3n4;
|
|
NodeContainer n3n5;
|
|
|
|
Ipv4InterfaceContainer i0i2;
|
|
Ipv4InterfaceContainer i1i2;
|
|
Ipv4InterfaceContainer i2i3;
|
|
Ipv4InterfaceContainer i3i4;
|
|
Ipv4InterfaceContainer i3i5;
|
|
|
|
NodeContainer c;
|
|
c.Create (6);
|
|
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::TcpNewReno"));
|
|
// 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 = 1000;
|
|
|
|
Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> ();
|
|
|
|
NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
|
|
"Verify that we can actually set the attribute Mode");
|
|
|
|
Ipv4Header ipHeader;
|
|
|
|
if (queue->GetMode () == Queue::QUEUE_MODE_BYTES)
|
|
{
|
|
modeSize = pktSize + ipHeader.GetSerializedSize ();
|
|
}
|
|
|
|
uint32_t qSize = 25 * modeSize;
|
|
|
|
Config::SetDefault ("ns3::RedQueueDisc::ARED", BooleanValue (true));
|
|
Config::SetDefault ("ns3::RedQueueDisc::LInterm", DoubleValue (10.0));
|
|
Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (qSize));
|
|
Config::SetDefault ("ns3::RedQueueDisc::MeanPktSize", UintegerValue (meanPktSize + ipHeader.GetSerializedSize ()));
|
|
Config::SetDefault ("ns3::RedQueueDisc::TargetDelay", TimeValue (Seconds (0.2)));
|
|
|
|
InternetStackHelper internet;
|
|
internet.Install (c);
|
|
|
|
TrafficControlHelper tchPfifo;
|
|
uint16_t handle = tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
|
|
tchPfifo.AddInternalQueues (handle, 3, "ns3::DropTailQueue", "MaxPackets", UintegerValue (1000));
|
|
|
|
TrafficControlHelper tchRed;
|
|
tchRed.SetRootQueueDisc ("ns3::RedQueueDisc", "LinkBandwidth", StringValue (aredLinkDataRate),
|
|
"LinkDelay", StringValue (aredLinkDelay));
|
|
|
|
PointToPointHelper p2p;
|
|
|
|
NetDeviceContainer devn0n2;
|
|
NetDeviceContainer devn1n2;
|
|
NetDeviceContainer devn2n3;
|
|
NetDeviceContainer devn3n4;
|
|
NetDeviceContainer devn3n5;
|
|
|
|
QueueDiscContainer queueDiscs;
|
|
|
|
p2p.SetQueue ("ns3::DropTailQueue");
|
|
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
|
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
|
devn0n2 = p2p.Install (n0n2);
|
|
tchPfifo.Install (devn0n2);
|
|
|
|
p2p.SetQueue ("ns3::DropTailQueue");
|
|
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
|
p2p.SetChannelAttribute ("Delay", StringValue ("3ms"));
|
|
devn1n2 = p2p.Install (n1n2);
|
|
tchPfifo.Install (devn1n2);
|
|
|
|
p2p.SetQueue ("ns3::DropTailQueue");
|
|
p2p.SetDeviceAttribute ("DataRate", StringValue (aredLinkDataRate));
|
|
p2p.SetChannelAttribute ("Delay", StringValue (aredLinkDelay));
|
|
devn2n3 = p2p.Install (n2n3);
|
|
// only backbone link has ARED queue disc
|
|
queueDiscs = tchRed.Install (devn2n3);
|
|
|
|
p2p.SetQueue ("ns3::DropTailQueue");
|
|
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
|
p2p.SetChannelAttribute ("Delay", StringValue ("4ms"));
|
|
devn3n4 = p2p.Install (n3n4);
|
|
tchPfifo.Install (devn3n4);
|
|
|
|
p2p.SetQueue ("ns3::DropTailQueue");
|
|
p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
|
p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
|
|
devn3n5 = p2p.Install (n3n5);
|
|
tchPfifo.Install (devn3n5);
|
|
|
|
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 ();
|
|
|
|
// 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", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
|
clientHelper1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
|
clientHelper1.SetAttribute ("PacketSize", UintegerValue (pktSize));
|
|
clientHelper1.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mbps")));
|
|
|
|
// Connection two
|
|
OnOffHelper clientHelper2 ("ns3::TcpSocketFactory", Address ());
|
|
clientHelper2.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
|
clientHelper2.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
|
clientHelper2.SetAttribute ("PacketSize", UintegerValue (pktSize));
|
|
clientHelper2.SetAttribute ("DataRate", DataRateValue (DataRate ("100Mbps")));
|
|
|
|
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));
|
|
|
|
ApplicationContainer clientApps2;
|
|
clientHelper2.SetAttribute ("Remote", remoteAddress);
|
|
clientApps2.Add (clientHelper2.Install (n1n2.Get (0)));
|
|
clientApps2.Start (Seconds (client_start_time));
|
|
clientApps2.Stop (Seconds (client_stop_time));
|
|
|
|
Simulator::Stop (Seconds (sink_stop_time));
|
|
Simulator::Run ();
|
|
|
|
RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queueDiscs.Get (0))->GetStats ();
|
|
|
|
NS_TEST_EXPECT_MSG_LT (st.unforcedDrop, st.forcedDrop, "forcedDrop should be more than unforcedDrop");
|
|
|
|
Simulator::Destroy ();
|
|
}
|
|
|
|
void
|
|
AdaptiveRedQueueDiscTestCase::DoRun (void)
|
|
{
|
|
RunAdaptiveRedDiscTest (StringValue ("QUEUE_MODE_PACKETS"));
|
|
RunAdaptiveRedDiscTest (StringValue ("QUEUE_MODE_BYTES"));
|
|
Simulator::Destroy ();
|
|
}
|
|
|
|
static class AredQueueDiscTestSuite : public TestSuite
|
|
{
|
|
public:
|
|
AredQueueDiscTestSuite ()
|
|
: TestSuite ("adaptive-red-queue-disc", UNIT)
|
|
{
|
|
AddTestCase (new AutoRedQueueDiscTestCase (), TestCase::QUICK); // Tests for automatically set parameters of ARED
|
|
AddTestCase (new AdaptiveRedQueueDiscTestCase (), TestCase::QUICK); // Tests for adaptive parameter of ARED
|
|
}
|
|
} g_aredQueueDiscTestSuite;
|