LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2016 NITK Surathkal | 3 * Copyright (c) 2016 NITK Surathkal |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 double minTh = 5; | 43 double minTh = 5; |
44 double maxTh = 15; | 44 double maxTh = 15; |
45 uint32_t pktSize = 512; | 45 uint32_t pktSize = 512; |
46 std::string appDataRate = "10Mbps"; | 46 std::string appDataRate = "10Mbps"; |
47 std::string queueDiscType = "RED"; | 47 std::string queueDiscType = "RED"; |
48 uint16_t port = 5001; | 48 uint16_t port = 5001; |
49 std::string bottleNeckLinkBw = "1Mbps"; | 49 std::string bottleNeckLinkBw = "1Mbps"; |
50 std::string bottleNeckLinkDelay = "50ms"; | 50 std::string bottleNeckLinkDelay = "50ms"; |
51 | 51 |
52 CommandLine cmd; | 52 CommandLine cmd; |
53 cmd.AddValue ("nLeaf", "Number of left and right side leaf nodes", nLeaf); | 53 cmd.AddValue ("nLeaf","Number of left and right side leaf nodes", nLeaf); |
54 cmd.AddValue ("maxPackets","Max Packets allowed in the device queue", maxPacke
ts); | 54 cmd.AddValue ("maxPackets","Max Packets allowed in the device queue", maxPacke
ts); |
55 cmd.AddValue ("queueDiscLimitPackets","Max Packets allowed in the queue disc",
queueDiscLimitPackets); | 55 cmd.AddValue ("queueDiscLimitPackets","Max Packets allowed in the queue disc",
queueDiscLimitPackets); |
56 cmd.AddValue ("queueDiscType", "Set Queue disc type to RED or BLUE", queueDisc
Type); | 56 cmd.AddValue ("queueDiscType", "Set Queue disc type to RED or BLUE", queueDisc
Type); |
57 cmd.AddValue ("appPktSize", "Set OnOff App Packet Size", pktSize); | 57 cmd.AddValue ("appPktSize", "Set OnOff App Packet Size", pktSize); |
58 cmd.AddValue ("appDataRate", "Set OnOff App DataRate", appDataRate); | 58 cmd.AddValue ("appDataRate", "Set OnOff App DataRate", appDataRate); |
59 cmd.AddValue ("modeBytes", "Set Queue disc mode to Packets <false> or bytes <t
rue>", modeBytes); | 59 cmd.AddValue ("modeBytes", "Set Queue disc mode to Packets <false> or bytes <t
rue>", modeBytes); |
60 | 60 |
61 cmd.Parse (argc,argv); | 61 cmd.Parse (argc,argv); |
62 | 62 |
63 if ((queueDiscType != "RED") && (queueDiscType != "BLUE")) | 63 if ((queueDiscType != "RED") && (queueDiscType != "BLUE")) |
64 { | 64 { |
65 std::cout << "Invalid queue disc type: Use --queueDiscType=RED or --queueD
iscType=BLUE" << std::endl; | 65 std::cout << "Invalid queue disc type: Use --queueDiscType=RED or --queueD
iscType=BLUE" << std::endl; |
66 exit (1); | 66 exit (1); |
67 } | 67 } |
68 | 68 |
69 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSiz
e)); | 69 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (pktSiz
e)); |
70 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRat
e)); | 70 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (appDataRat
e)); |
71 | 71 |
72 Config::SetDefault ("ns3::Queue::Mode", StringValue ("QUEUE_MODE_PACKETS")); | 72 Config::SetDefault ("ns3::QueueBase::Mode", StringValue ("QUEUE_MODE_PACKETS")
); |
73 Config::SetDefault ("ns3::Queue::MaxPackets", UintegerValue (maxPackets)); | 73 Config::SetDefault ("ns3::QueueBase::MaxPackets", UintegerValue (maxPackets)); |
74 | 74 |
75 if (!modeBytes) | 75 if (!modeBytes) |
76 { | 76 { |
77 Config::SetDefault ("ns3::BlueQueueDisc::Mode", StringValue ("QUEUE_MODE_P
ACKETS")); | 77 Config::SetDefault ("ns3::BlueQueueDisc::Mode", StringValue ("QUEUE_DISC_M
ODE_PACKETS")); |
78 Config::SetDefault ("ns3::BlueQueueDisc::QueueLimit", UintegerValue (queue
DiscLimitPackets)); | 78 Config::SetDefault ("ns3::BlueQueueDisc::QueueLimit", UintegerValue (queue
DiscLimitPackets)); |
79 Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_MODE_PA
CKETS")); | 79 Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MO
DE_PACKETS")); |
80 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueD
iscLimitPackets)); | 80 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueD
iscLimitPackets)); |
81 } | 81 } |
82 else | 82 else |
83 { | 83 { |
84 Config::SetDefault ("ns3::BlueQueueDisc::Mode", StringValue ("QUEUE_MODE_B
YTES")); | 84 Config::SetDefault ("ns3::BlueQueueDisc::Mode", StringValue ("QUEUE_DISC_M
ODE_BYTES")); |
85 Config::SetDefault ("ns3::BlueQueueDisc::QueueLimit", UintegerValue (queue
DiscLimitPackets * pktSize)); | 85 Config::SetDefault ("ns3::BlueQueueDisc::QueueLimit", UintegerValue (queue
DiscLimitPackets * pktSize)); |
86 Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_MODE_BY
TES")); | 86 Config::SetDefault ("ns3::RedQueueDisc::Mode", StringValue ("QUEUE_DISC_MO
DE_BYTES")); |
87 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueD
iscLimitPackets * pktSize)); | 87 Config::SetDefault ("ns3::RedQueueDisc::QueueLimit", UintegerValue (queueD
iscLimitPackets * pktSize)); |
88 minTh *= pktSize; | 88 minTh *= pktSize; |
89 maxTh *= pktSize; | 89 maxTh *= pktSize; |
90 } | 90 } |
91 | 91 |
92 if (queueDiscType == "RED") | 92 if (queueDiscType == "RED") |
93 { | 93 { |
94 Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (minTh)); | 94 Config::SetDefault ("ns3::RedQueueDisc::MinTh", DoubleValue (minTh)); |
95 Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (maxTh)); | 95 Config::SetDefault ("ns3::RedQueueDisc::MaxTh", DoubleValue (maxTh)); |
96 Config::SetDefault ("ns3::RedQueueDisc::LinkBandwidth", StringValue (bottl
eNeckLinkBw)); | 96 Config::SetDefault ("ns3::RedQueueDisc::LinkBandwidth", StringValue (bottl
eNeckLinkBw)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 clientApps.Add (clientHelper.Install (d.GetRight (i))); | 172 clientApps.Add (clientHelper.Install (d.GetRight (i))); |
173 } | 173 } |
174 clientApps.Start (Seconds (1.0)); // Start 1 second after sink | 174 clientApps.Start (Seconds (1.0)); // Start 1 second after sink |
175 clientApps.Stop (Seconds (15.0)); // Stop before the sink | 175 clientApps.Stop (Seconds (15.0)); // Stop before the sink |
176 | 176 |
177 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); | 177 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
178 | 178 |
179 std::cout << "Running the simulation" << std::endl; | 179 std::cout << "Running the simulation" << std::endl; |
180 Simulator::Run (); | 180 Simulator::Run (); |
181 | 181 |
182 std::cout << "*** Stats from the bottleneck queue disc ***" << std::endl; | 182 QueueDisc::Stats st = queueDiscs.Get (0)->GetStats (); |
183 | 183 |
184 if (queueDiscType == "RED") | 184 if (queueDiscType == "RED") |
185 { | 185 { |
186 RedQueueDisc::Stats st = StaticCast<RedQueueDisc> (queueDiscs.Get (0))->Ge
tStats (); | 186 if (st.GetNDroppedPackets (RedQueueDisc::UNFORCED_DROP) == 0) |
187 if (st.unforcedDrop == 0) | |
188 { | 187 { |
189 std::cout << "There should be some unforced drops" << std::endl; | 188 std::cout << "There should be some unforced drops" << std::endl; |
190 exit (1); | 189 exit (1); |
191 } | 190 } |
192 | 191 } |
193 if (st.qLimDrop != 0) | 192 else |
| 193 { |
| 194 if (st.GetNDroppedPackets (BlueQueueDisc::UNFORCED_DROP) == 0) |
194 { | 195 { |
195 std::cout << "There should be zero drops due to queue full" << std::en
dl; | 196 std::cout << "There should be some unforced drops" << std::endl; |
196 exit (1); | 197 exit (1); |
197 } | 198 } |
198 std::cout << "\t " << st.unforcedDrop << " drops due to prob mark" << std:
:endl; | 199 } |
199 std::cout << "\t " << st.forcedDrop << " drops due to hard mark" << std::e
ndl; | 200 |
200 std::cout << "\t " << st.qLimDrop << " drops due to queue full" << std::en
dl; | 201 if (st.GetNDroppedPackets (QueueDisc::INTERNAL_QUEUE_DROP) != 0) |
201 } | 202 { |
202 else | 203 std::cout << "There should be zero drops due to queue full" << std::endl; |
203 { | 204 exit (1); |
204 BlueQueueDisc::Stats st = StaticCast<BlueQueueDisc> (queueDiscs.Get (0))->
GetStats (); | 205 } |
205 if (st.unforcedDrop == 0 || st.forcedDrop == 0) | 206 |
206 { | 207 std::cout << "*** Stats from the bottleneck " << queueDiscType << " queue disc
***" << std::endl; |
207 std::cout << "There should be some unforced and forced drops" << std::
endl; | 208 std::cout << st << std::endl; |
208 exit (1); | |
209 } | |
210 std::cout << "\t " << st.unforcedDrop << " drops due to prob mark" << std:
:endl; | |
211 std::cout << "\t " << st.forcedDrop << " drops due to queue limit" << std:
:endl; | |
212 } | |
213 | |
214 std::cout << "Destroying the simulation" << std::endl; | 209 std::cout << "Destroying the simulation" << std::endl; |
| 210 |
215 Simulator::Destroy (); | 211 Simulator::Destroy (); |
216 return 0; | 212 return 0; |
217 } | 213 } |
LEFT | RIGHT |