-
Notifications
You must be signed in to change notification settings - Fork 1
/
dce-gfc-dumbbell.cc
526 lines (447 loc) · 21.8 KB
/
dce-gfc-dumbbell.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2018 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
*
* Authors: Apoorva Bhargava <[email protected]>
* Mohit P. Tahiliani <[email protected]>
*/
#include <iostream>
#include <string>
#include <fstream>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/point-to-point-layout-module.h"
#include "ns3/applications-module.h"
#include "ns3/packet-sink.h"
#include "ns3/traffic-control-module.h"
#include "ns3/log.h"
#include "ns3/random-variable-stream.h"
#include "ns3/gtk-config-store.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/callback.h"
#include "ns3/dce-module.h"
using namespace ns3;
Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
std::string dir = "results/gfc-dumbbell/";
double stopTime = 20;
// ns3 code changes ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static void
CwndChangeA (uint32_t oldCwnd, uint32_t newCwnd)
{
std::ofstream fPlotQueue (dir + "cwndTraces/A.plotme", std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << newCwnd/1446.0 << std::endl;
fPlotQueue.close ();
}
static void
CwndChangeB (uint32_t oldCwnd, uint32_t newCwnd)
{
std::ofstream fPlotQueue (dir + "cwndTraces/B.plotme", std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << newCwnd/1446.0 << std::endl;
fPlotQueue.close ();
}
static void
CwndChangeC (uint32_t oldCwnd, uint32_t newCwnd)
{
std::ofstream fPlotQueue (dir + "cwndTraces/C.plotme", std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << newCwnd/1446.0 << std::endl;
fPlotQueue.close ();
}
static void
CwndChangeD (uint32_t oldCwnd, uint32_t newCwnd)
{
std::ofstream fPlotQueue (dir + "cwndTraces/D.plotme", std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << newCwnd/1446.0 << std::endl;
fPlotQueue.close ();
}
static void
CwndChangeE (uint32_t oldCwnd, uint32_t newCwnd)
{
std::ofstream fPlotQueue (dir + "cwndTraces/E.plotme", std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << newCwnd/1446.0 << std::endl;
fPlotQueue.close ();
}
void
TraceCwnd (uint32_t node, uint32_t cwndWindow,
Callback <void, uint32_t, uint32_t> CwndTrace)
{
Config::ConnectWithoutContext ("/NodeList/" + std::to_string (node) + "/$ns3::TcpL4Protocol/SocketList/" + std::to_string (cwndWindow) + "/CongestionWindow", CwndTrace);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
CheckQueueSize (Ptr<QueueDisc> queue)
{
uint32_t qSize = queue->GetCurrentSize ().GetValue ();
// check queue size every 1/100 of a second
Simulator::Schedule (Seconds (0.001), &CheckQueueSize, queue);
std::ofstream fPlotQueue (std::stringstream (dir + "queue-size.plotme").str ().c_str (), std::ios::out | std::ios::app);
fPlotQueue << Simulator::Now ().GetSeconds () << " " << qSize << std::endl;
fPlotQueue.close ();
}
static void
DropAtQueue (Ptr<OutputStreamWrapper> stream, Ptr<const QueueDiscItem> item)
{
*stream->GetStream () << Simulator::Now ().GetSeconds () << " 1" << std::endl;
}
static void
MarkAtQueue (Ptr<OutputStreamWrapper> stream, Ptr<const QueueDiscItem> item, const char* reason)
{
*stream->GetStream () << Simulator::Now ().GetSeconds () << " 1" << std::endl;
}
void InstallBulkSend (Ptr<Node> node, Ipv4Address address, uint16_t port, std::string sock_factory)
{
BulkSendHelper source (sock_factory, InetSocketAddress (address, port));
source.SetAttribute ("MaxBytes", UintegerValue (0));
ApplicationContainer sourceApps = source.Install (node);
Time timeToStart = Seconds (uv->GetValue (10, 11));
sourceApps.Start (timeToStart);
sourceApps.Stop (Seconds (stopTime));
}
void ns3InstallBulkSend (Ptr<Node> node, Ipv4Address address, uint16_t port,
uint32_t nodeId, uint32_t cwndWindow,
Callback <void, uint32_t, uint32_t> CwndTrace)
{
BulkSendHelper source ("ns3::TcpSocketFactory",
InetSocketAddress (address, port));
source.SetAttribute ("MaxBytes", UintegerValue (0));
ApplicationContainer sourceApps = source.Install (node);
Time timeToStart = Seconds (uv->GetValue (0, 1));
sourceApps.Start (timeToStart);
Simulator::Schedule (timeToStart + Seconds (0.001), &TraceCwnd, nodeId, cwndWindow, CwndTrace);
sourceApps.Stop (Seconds (stopTime));
}
void InstallPacketSink (Ptr<Node> node, uint16_t port, std::string sock_factory, std::string stack)
{
PacketSinkHelper sink (sock_factory, InetSocketAddress (Ipv4Address::GetAny (), port));
ApplicationContainer sinkApps = sink.Install (node);
if (stack == "ns3")
{
sinkApps.Start (Seconds (0.0));
}
else
{
sinkApps.Start (Seconds (10.0));
}
sinkApps.Stop (Seconds (stopTime));
}
static void GetSSStats (Ptr<Node> node, Time at, std::string stack)
{
if (stack == "linux")
{
DceApplicationHelper process;
ApplicationContainer apps;
process.SetBinary ("ss");
process.SetStackSize (1 << 20);
process.AddArgument ("-a");
process.AddArgument ("-e");
process.AddArgument ("-i");
apps.Add (process.Install (node));
apps.Start (at);
}
}
int main (int argc, char *argv[])
{
uint32_t stream = 1;
// changed stack from linux to ns3
std::string stack = "ns3";
std::string sock_factory = "ns3::TcpSocketFactory";
std::string transport_prot = "TcpLp";
// changed linux_prot from vegas to TcpVegas
std::string linux_prot = "lp";
std::string queue_disc_type = "FifoQueueDisc";
bool useEcn = false;
uint32_t dataSize = 1446;
uint32_t delAckCount = 2;
//Enable checksum if linux and ns3 node communicate
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,sizeof(buffer),"%d-%m-%Y-%I-%M-%S",timeinfo);
std::string currentTime (buffer);
CommandLine cmd;
cmd.AddValue ("stream", "Seed value for random variable", stream);
cmd.AddValue ("stack", "Set TCP/IP stack as ns3 or linux", stack);
cmd.AddValue ("transport_prot", "Transport protocol to use: TcpNewReno, "
"TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, "
"TcpBic, TcpYeah, TcpIllinois, TcpWestwood, TcpWestwoodPlus, TcpLedbat, "
"TcpLp", transport_prot);
cmd.AddValue ("linux_prot", "Linux network protocol to use: reno, "
"hybla, highspeed, htcp, vegas, scalable, veno, "
"bic, yeah, illinois, westwood, lp", linux_prot);
cmd.AddValue ("queue_disc_type", "Queue disc type for gateway (e.g. ns3::CoDelQueueDisc)", queue_disc_type);
cmd.AddValue ("useEcn", "Use ECN", useEcn);
cmd.AddValue ("dataSize", "Data packet size", dataSize);
cmd.AddValue ("delAckCount", "Delayed ack count", delAckCount);
cmd.AddValue ("stopTime", "Stop time for applications / simulation time will be stopTime", stopTime);
cmd.Parse (argc,argv);
uv->SetStream (stream);
queue_disc_type = std::string ("ns3::") + queue_disc_type;
if (stack == "ns3")
{
transport_prot = std::string ("ns3::") + transport_prot;
}
TypeId qdTid;
NS_ABORT_MSG_UNLESS (TypeId::LookupByNameFailSafe (queue_disc_type, &qdTid), "TypeId " << queue_disc_type << " not found");
if (stack == "ns3")
{
Config::SetDefault ("ns3::TcpL4Protocol::RecoveryType",
TypeIdValue (TypeId::LookupByName ("ns3::TcpPrrRecovery")));
if (transport_prot.compare ("ns3::TcpWestwoodPlus") == 0)
{
// TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
// the default protocol type in ns3::TcpWestwood is WESTWOOD
Config::SetDefault ("ns3::TcpWestwood::ProtocolType", EnumValue (TcpWestwood::WESTWOODPLUS));
}
else
{
TypeId tcpTid;
NS_ABORT_MSG_UNLESS (TypeId::LookupByNameFailSafe (transport_prot, &tcpTid), "TypeId " << transport_prot << " not found");
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TypeId::LookupByName (transport_prot)));
}
}
NodeContainer leftNodes, rightNodes, routers;
routers.Create (2);
leftNodes.Create (2);
rightNodes.Create (2);
// Create the point-to-point link helpers
PointToPointHelper pointToPointRouter;
pointToPointRouter.SetDeviceAttribute ("DataRate", StringValue ("1Mbps"));
pointToPointRouter.SetChannelAttribute ("Delay", StringValue ("50ms"));
NetDeviceContainer r1r2ND = pointToPointRouter.Install (routers.Get (0), routers.Get (1));
std::vector <NetDeviceContainer> leftToRouter;
std::vector <NetDeviceContainer> routerToRight;
PointToPointHelper pointToPointLeaf;
pointToPointLeaf.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
// Node 1
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("5ms"));
leftToRouter.push_back (pointToPointLeaf.Install (leftNodes.Get (0), routers.Get (0)));
routerToRight.push_back (pointToPointLeaf.Install (routers.Get (1), rightNodes.Get (0)));
// Node 2
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("5ms"));
leftToRouter.push_back (pointToPointLeaf.Install (leftNodes.Get (1), routers.Get (0)));
routerToRight.push_back (pointToPointLeaf.Install (routers.Get (1), rightNodes.Get (1)));
/* // Node 3
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("5ms"));
leftToRouter.push_back (pointToPointLeaf.Install (leftNodes.Get (2), routers.Get (0)));
routerToRight.push_back (pointToPointLeaf.Install (routers.Get (1), rightNodes.Get (2)));
// Node 4
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("5ms"));
leftToRouter.push_back (pointToPointLeaf.Install (leftNodes.Get (3), routers.Get (0)));
routerToRight.push_back (pointToPointLeaf.Install (routers.Get (1), rightNodes.Get (3)));
// Node 5
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("5ms"));
leftToRouter.push_back (pointToPointLeaf.Install (leftNodes.Get (4), routers.Get (0)));
routerToRight.push_back (pointToPointLeaf.Install (routers.Get (1), rightNodes.Get (4)));*/
DceManagerHelper dceManager;
LinuxStackHelper linuxStack;
InternetStackHelper internetStack;
if (stack == "linux")
{
sock_factory = "ns3::LinuxTcpSocketFactory";
dceManager.SetTaskManagerAttribute ("FiberManagerType", StringValue ("UcontextFiberManager"));
dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
linuxStack.Install (leftNodes);
linuxStack.Install (rightNodes);
internetStack.Install (routers);
}
else if (stack == "ns3")
{
internetStack.InstallAll ();
}
Ipv4AddressHelper ipAddresses ("10.0.0.0", "255.255.255.0");
Ipv4InterfaceContainer r1r2IPAddress = ipAddresses.Assign (r1r2ND);
ipAddresses.NewNetwork ();
std::vector <Ipv4InterfaceContainer> leftToRouterIPAddress;
leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [0]));
ipAddresses.NewNetwork ();
leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [1]));
ipAddresses.NewNetwork ();
/* leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [2]));
ipAddresses.NewNetwork ();
leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [3]));
ipAddresses.NewNetwork ();
leftToRouterIPAddress.push_back (ipAddresses.Assign (leftToRouter [4]));
ipAddresses.NewNetwork ();
*/
std::vector <Ipv4InterfaceContainer> routerToRightIPAddress;
routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [0]));
ipAddresses.NewNetwork ();
routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [1]));
ipAddresses.NewNetwork ();
/* routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [2]));
ipAddresses.NewNetwork ();
routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [3]));
ipAddresses.NewNetwork ();
routerToRightIPAddress.push_back (ipAddresses.Assign (routerToRight [4]));*/
if (stack == "linux")
{
dceManager.Install (leftNodes);
dceManager.Install (rightNodes);
dceManager.Install (routers);
linuxStack.SysctlSet (leftNodes, ".net.ipv4.conf.default.forwarding", "1");
linuxStack.SysctlSet (rightNodes, ".net.ipv4.conf.default.forwarding", "1");
linuxStack.SysctlSet (leftNodes, ".net.ipv4.tcp_congestion_control", linux_prot);
linuxStack.SysctlSet (rightNodes, ".net.ipv4.tcp_congestion_control", linux_prot);
linuxStack.SysctlSet (leftNodes, ".net.ipv4.tcp_ecn", "0");
linuxStack.SysctlSet (rightNodes, ".net.ipv4.tcp_ecn", "0");
}
if (stack == "linux")
{
//Static Routing
Ptr<Ipv4> ipv4Router1 = routers.Get (0)->GetObject<Ipv4> ();
Ptr<Ipv4> ipv4Router2 = routers.Get (1)->GetObject<Ipv4> ();
Ipv4StaticRoutingHelper routingHelper;
Ptr<Ipv4StaticRouting> staticRoutingRouter1 = routingHelper.GetStaticRouting (ipv4Router1);
Ptr<Ipv4StaticRouting> staticRoutingRouter2 = routingHelper.GetStaticRouting (ipv4Router2);
//Routing for Router 1
staticRoutingRouter1->AddNetworkRouteTo (Ipv4Address ("10.0.6.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.2"), 1);
staticRoutingRouter1->AddNetworkRouteTo (Ipv4Address ("10.0.7.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.2"), 1);
/* staticRoutingRouter1->AddNetworkRouteTo (Ipv4Address ("10.0.8.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.2"), 1);
staticRoutingRouter1->AddNetworkRouteTo (Ipv4Address ("10.0.9.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.2"), 1);
staticRoutingRouter1->AddNetworkRouteTo (Ipv4Address ("10.0.10.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.2"), 1);*/
//Routing for Router 2
staticRoutingRouter2->AddNetworkRouteTo (Ipv4Address ("10.0.1.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.1"), 1);
staticRoutingRouter2->AddNetworkRouteTo (Ipv4Address ("10.0.2.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.1"), 1);
/* staticRoutingRouter2->AddNetworkRouteTo (Ipv4Address ("10.0.3.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.1"), 1);
staticRoutingRouter2->AddNetworkRouteTo (Ipv4Address ("10.0.4.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.1"), 1);
staticRoutingRouter2->AddNetworkRouteTo (Ipv4Address ("10.0.5.0"), Ipv4Mask ("255.255.255.0"), Ipv4Address ("10.0.0.1"), 1);*/
std::ostringstream cmd_oss;
//Default route for senders
for (uint32_t i = 1; i < 3; i = i + 1)
{
cmd_oss.str ("");
cmd_oss << "route add default via " << (routers.Get (0)->GetObject<Ipv4> ())->GetAddress (i + 1, 0).GetLocal () << " dev sim0";
LinuxStackHelper::RunIp (leftNodes.Get (i - 1), Seconds (0.00001), cmd_oss.str ());
LinuxStackHelper::RunIp (leftNodes.Get (i - 1), Seconds (0.00001), "link set sim0 up");
}
//Default route for receivers
for (uint32_t i = 1; i < 3; i = i + 1)
{
cmd_oss.str ("");
cmd_oss << "route add default via " << (routers.Get (1)->GetObject<Ipv4> ())->GetAddress (i + 1, 0).GetLocal () << " dev sim0";
LinuxStackHelper::RunIp (rightNodes.Get (i - 1), Seconds (0.00001), cmd_oss.str ());
LinuxStackHelper::RunIp (rightNodes.Get (i - 1), Seconds (0.00001), "link set sim0 up");
}
}
else if (stack == "ns3")
{
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
}
dir += (currentTime + "/");
std::string dirToSave = "mkdir -p " + dir;
system (dirToSave.c_str ());
system ((dirToSave + "/pcap/").c_str ());
system ((dirToSave + "/markTraces/").c_str ());
system ((dirToSave + "/queueTraces/").c_str ());
system (("cp -R PlotScripts-gfc-dumbbell/* " + dir + "/pcap/").c_str ());
// added new system line
if(stack == "ns3"){
system ((dirToSave + "/cwndTraces/").c_str ());
}
if (stack == "ns3")
{
Config::SetDefault ("ns3::TcpSocket::SndBufSize", UintegerValue (1 << 20));
Config::SetDefault ("ns3::TcpSocket::RcvBufSize", UintegerValue (1 << 20));
Config::SetDefault ("ns3::TcpSocket::InitialCwnd", UintegerValue (10));
Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (delAckCount));
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (dataSize));
// Config::SetDefault ("ns3::TcpSocketBase::UseEcn", BooleanValue (useEcn));
}
// if(stack == "linux"){
// Config::SetDefault ("ns3::FifoQueueDisc::UseEcn", BooleanValue (useEcn));
// Config::SetDefault ("ns3::FifoQueueDisc::MeanPktSize", UintegerValue (1500));
// Config::SetDefault ("ns3::FifoQueueDisc::Limit", DoubleValue (7.5));
// }
// added other conditions from github
if (stack == "ns3"){
// Config::SetDefault ("ns3::FifoQueueDisc::UseEcn", BooleanValue (useEcn));
// Config::SetDefault ("ns3::FifoQueueDisc::MeanPktSize", UintegerValue (1500));
// Config::SetDefault ("ns3::FifoQueueDisc::A", DoubleValue (0.002013602268));
// Config::SetDefault ("ns3::FifoQueueDisc::B", DoubleValue (0.001342401512));
// Config::SetDefault ("ns3::FifoQueueDisc::W", DoubleValue (400));
// Config::SetDefault ("ns3::FifoQueueDisc::QueueRef", DoubleValue (10));
// Config::SetDefault ("ns3::FifoQueueDisc::Limit", DoubleValue (7.5));
}
Config::SetDefault (queue_disc_type + "::MaxSize", QueueSizeValue (QueueSize ("666p")));
AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> streamWrapper;
TrafficControlHelper tch;
tch.SetRootQueueDisc (queue_disc_type);
QueueDiscContainer qd;
tch.Uninstall (routers.Get (0)->GetDevice (0));
qd.Add (tch.Install (routers.Get (0)->GetDevice (0)).Get (0));
Simulator::ScheduleNow (&CheckQueueSize, qd.Get (0));
streamWrapper = asciiTraceHelper.CreateFileStream (dir + "/queueTraces/drop-0.plotme");
qd.Get (0)->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&DropAtQueue, streamWrapper));
streamWrapper = asciiTraceHelper.CreateFileStream (dir + "/queueTraces/mark-0.plotme");
qd.Get (0)->TraceConnectWithoutContext ("Mark", MakeBoundCallback (&MarkAtQueue, streamWrapper));
uint16_t port = 50000;
InstallPacketSink (rightNodes.Get (0), port, sock_factory, stack); // A Sink 0 Applications
InstallPacketSink (rightNodes.Get (1), port, sock_factory, stack); // B Sink 0 Applications
/*InstallPacketSink (rightNodes.Get (2), port, sock_factory, stack); // C Sink 0 Applications
InstallPacketSink (rightNodes.Get (3), port, sock_factory, stack); // D Sink 0 Applications
InstallPacketSink (rightNodes.Get (4), port, sock_factory, stack); // E Sink 0 Applications*/
if( stack == "linux"){
InstallBulkSend (leftNodes.Get (0), routerToRightIPAddress [0].GetAddress (1), port, sock_factory);
InstallBulkSend (leftNodes.Get (1), routerToRightIPAddress [1].GetAddress (1), port, sock_factory);
/* InstallBulkSend (leftNodes.Get (2), routerToRightIPAddress [2].GetAddress (1), port, sock_factory);
InstallBulkSend (leftNodes.Get (3), routerToRightIPAddress [3].GetAddress (1), port, sock_factory);
InstallBulkSend (leftNodes.Get (4), routerToRightIPAddress [4].GetAddress (1), port, sock_factory);*/
}
if(stack == "ns3"){
ns3InstallBulkSend (leftNodes.Get (0), routerToRightIPAddress [0].GetAddress (1), port, 2, 0, MakeCallback (&CwndChangeA));
ns3InstallBulkSend (leftNodes.Get (1), routerToRightIPAddress [1].GetAddress (1), port, 3, 0, MakeCallback (&CwndChangeB));
/* ns3InstallBulkSend (leftNodes.Get (2), routerToRightIPAddress [2].GetAddress (1), port, 4, 0, MakeCallback (&CwndChangeC));
ns3InstallBulkSend (leftNodes.Get (3), routerToRightIPAddress [3].GetAddress (1), port, 5, 0, MakeCallback (&CwndChangeD));
ns3InstallBulkSend (leftNodes.Get (4), routerToRightIPAddress [4].GetAddress (1), port, 6, 0, MakeCallback (&CwndChangeE));*/
}
if (stack == "linux")
{
for (int j = 0; j < leftNodes.GetN (); j++)
{
for (float i = 10.0; i <= stopTime; i = i + 0.05)
{
GetSSStats (leftNodes.Get (j), Seconds (i), stack);
}
}
}
pointToPointLeaf.EnablePcapAll (dir + "pcap/N", true);
Simulator::Stop (Seconds (stopTime));
Simulator::Run ();
std::ofstream myfile;
myfile.open (dir + "queueStats.txt", std::fstream::in | std::fstream::out | std::fstream::app);
myfile << std::endl;
myfile << "Stat for Queue 1";
myfile << qd.Get (0)->GetStats ();
myfile.close ();
myfile.open (dir + "config.txt", std::fstream::in | std::fstream::out | std::fstream::app);
myfile << "useEcn " << useEcn << "\n";
myfile << "queue_disc_type " << queue_disc_type << "\n";
myfile << "stream " << stream << "\n";
myfile << "stack " << stack << "\n";
(stack == "ns3") ? myfile << "transport_prot " << transport_prot << "\n" : myfile << "linux_prot " << linux_prot << "\n";
myfile << "dataSize " << dataSize << "\n";
myfile << "delAckCount " << delAckCount << "\n";
myfile << "stopTime " << stopTime << "\n";
myfile.close ();
Simulator::Destroy ();
return 0;
}