A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
red-tests.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Authors: Marcos Talau <talau@users.sourceforge.net>
17
* Duy Nguyen <duy@soe.ucsc.edu>
18
*
19
*/
20
40
#include "ns3/core-module.h"
41
#include "ns3/network-module.h"
42
#include "ns3/internet-module.h"
43
#include "ns3/flow-monitor-helper.h"
44
#include "ns3/point-to-point-module.h"
45
#include "ns3/applications-module.h"
46
47
using namespace
ns3;
48
49
NS_LOG_COMPONENT_DEFINE
(
"RedTests"
);
50
51
uint32_t
checkTimes
;
52
double
avgQueueSize
;
53
54
// The times
55
double
global_start_time
;
56
double
global_stop_time
;
57
double
sink_start_time
;
58
double
sink_stop_time
;
59
double
client_start_time
;
60
double
client_stop_time
;
61
62
NodeContainer
n0n2
;
63
NodeContainer
n1n2
;
64
NodeContainer
n2n3
;
65
NodeContainer
n3n4
;
66
NodeContainer
n3n5
;
67
68
Ipv4InterfaceContainer
i0i2
;
69
Ipv4InterfaceContainer
i1i2
;
70
Ipv4InterfaceContainer
i2i3
;
71
Ipv4InterfaceContainer
i3i4
;
72
Ipv4InterfaceContainer
i3i5
;
73
74
std::stringstream
filePlotQueue
;
75
std::stringstream
filePlotQueueAvg
;
76
77
void
78
CheckQueueSize
(
Ptr<Queue>
queue)
79
{
80
uint32_t qSize = StaticCast<RedQueue> (queue)->GetQueueSize ();
81
82
avgQueueSize
+= qSize;
83
checkTimes
++;
84
85
// check queue size every 1/100 of a second
86
Simulator::Schedule
(
Seconds
(0.01), &
CheckQueueSize
, queue);
87
88
std::ofstream fPlotQueue (
filePlotQueue
.str ().c_str (), std::ios::out|std::ios::app);
89
fPlotQueue <<
Simulator::Now
().
GetSeconds
() <<
" "
<< qSize << std::endl;
90
fPlotQueue.close ();
91
92
std::ofstream fPlotQueueAvg (
filePlotQueueAvg
.str ().c_str (), std::ios::out|std::ios::app);
93
fPlotQueueAvg <<
Simulator::Now
().
GetSeconds
() <<
" "
<<
avgQueueSize
/
checkTimes
<< std::endl;
94
fPlotQueueAvg.close ();
95
}
96
97
void
98
BuildAppsTest
(uint32_t
test
)
99
{
100
if
( (test == 1) || (test == 3) )
101
{
102
// SINK is in the right side
103
uint16_t
port
= 50000;
104
Address
sinkLocalAddress (
InetSocketAddress
(
Ipv4Address::GetAny
(), port));
105
PacketSinkHelper
sinkHelper (
"ns3::TcpSocketFactory"
, sinkLocalAddress);
106
ApplicationContainer
sinkApp = sinkHelper.
Install
(
n3n4
.
Get
(1));
107
sinkApp.
Start
(
Seconds
(
sink_start_time
));
108
sinkApp.
Stop
(
Seconds
(
sink_stop_time
));
109
110
// Connection one
111
// Clients are in left side
112
/*
113
* Create the OnOff applications to send TCP to the server
114
* onoffhelper is a client that send data to TCP destination
115
*/
116
OnOffHelper
clientHelper1 (
"ns3::TcpSocketFactory"
,
Address
());
117
clientHelper1.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
118
clientHelper1.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
119
clientHelper1.
SetAttribute
120
(
"DataRate"
,
DataRateValue
(
DataRate
(
"10Mb/s"
)));
121
clientHelper1.
SetAttribute
122
(
"PacketSize"
,
UintegerValue
(1000));
123
124
ApplicationContainer
clientApps1;
125
AddressValue
remoteAddress
126
(
InetSocketAddress
(
i3i4
.
GetAddress
(1),
port
));
127
clientHelper1.
SetAttribute
(
"Remote"
, remoteAddress);
128
clientApps1.
Add
(clientHelper1.
Install
(
n0n2
.
Get
(0)));
129
clientApps1.
Start
(
Seconds
(
client_start_time
));
130
clientApps1.
Stop
(
Seconds
(
client_stop_time
));
131
132
// Connection two
133
OnOffHelper
clientHelper2 (
"ns3::TcpSocketFactory"
,
Address
());
134
clientHelper2.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
135
clientHelper2.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
136
clientHelper2.
SetAttribute
137
(
"DataRate"
,
DataRateValue
(
DataRate
(
"10Mb/s"
)));
138
clientHelper2.
SetAttribute
139
(
"PacketSize"
,
UintegerValue
(1000));
140
141
ApplicationContainer
clientApps2;
142
clientHelper2.
SetAttribute
(
"Remote"
, remoteAddress);
143
clientApps2.
Add
(clientHelper2.
Install
(
n1n2
.
Get
(0)));
144
clientApps2.
Start
(
Seconds
(3.0));
145
clientApps2.
Stop
(
Seconds
(
client_stop_time
));
146
}
147
else
// 4 or 5
148
{
149
// SINKs
150
// #1
151
uint16_t port1 = 50001;
152
Address
sinkLocalAddress1 (
InetSocketAddress
(
Ipv4Address::GetAny
(), port1));
153
PacketSinkHelper
sinkHelper1 (
"ns3::TcpSocketFactory"
, sinkLocalAddress1);
154
ApplicationContainer
sinkApp1 = sinkHelper1.
Install
(
n3n4
.
Get
(1));
155
sinkApp1.
Start
(
Seconds
(
sink_start_time
));
156
sinkApp1.
Stop
(
Seconds
(
sink_stop_time
));
157
// #2
158
uint16_t port2 = 50002;
159
Address
sinkLocalAddress2 (
InetSocketAddress
(
Ipv4Address::GetAny
(), port2));
160
PacketSinkHelper
sinkHelper2 (
"ns3::TcpSocketFactory"
, sinkLocalAddress2);
161
ApplicationContainer
sinkApp2 = sinkHelper2.
Install
(
n3n5
.
Get
(1));
162
sinkApp2.
Start
(
Seconds
(
sink_start_time
));
163
sinkApp2.
Stop
(
Seconds
(
sink_stop_time
));
164
// #3
165
uint16_t port3 = 50003;
166
Address
sinkLocalAddress3 (
InetSocketAddress
(
Ipv4Address::GetAny
(), port3));
167
PacketSinkHelper
sinkHelper3 (
"ns3::TcpSocketFactory"
, sinkLocalAddress3);
168
ApplicationContainer
sinkApp3 = sinkHelper3.
Install
(
n0n2
.
Get
(0));
169
sinkApp3.
Start
(
Seconds
(
sink_start_time
));
170
sinkApp3.
Stop
(
Seconds
(
sink_stop_time
));
171
// #4
172
uint16_t port4 = 50004;
173
Address
sinkLocalAddress4 (
InetSocketAddress
(
Ipv4Address::GetAny
(), port4));
174
PacketSinkHelper
sinkHelper4 (
"ns3::TcpSocketFactory"
, sinkLocalAddress4);
175
ApplicationContainer
sinkApp4 = sinkHelper4.
Install
(
n1n2
.
Get
(0));
176
sinkApp4.
Start
(
Seconds
(
sink_start_time
));
177
sinkApp4.
Stop
(
Seconds
(
sink_stop_time
));
178
179
// Connection #1
180
/*
181
* Create the OnOff applications to send TCP to the server
182
* onoffhelper is a client that send data to TCP destination
183
*/
184
OnOffHelper
clientHelper1 (
"ns3::TcpSocketFactory"
,
Address
());
185
clientHelper1.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
186
clientHelper1.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
187
clientHelper1.
SetAttribute
188
(
"DataRate"
,
DataRateValue
(
DataRate
(
"10Mb/s"
)));
189
clientHelper1.
SetAttribute
190
(
"PacketSize"
,
UintegerValue
(1000));
191
192
ApplicationContainer
clientApps1;
193
AddressValue
remoteAddress1
194
(
InetSocketAddress
(
i3i4
.
GetAddress
(1), port1));
195
clientHelper1.
SetAttribute
(
"Remote"
, remoteAddress1);
196
clientApps1.
Add
(clientHelper1.
Install
(
n0n2
.
Get
(0)));
197
clientApps1.
Start
(
Seconds
(
client_start_time
));
198
clientApps1.
Stop
(
Seconds
(
client_stop_time
));
199
200
// Connection #2
201
OnOffHelper
clientHelper2 (
"ns3::TcpSocketFactory"
,
Address
());
202
clientHelper2.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
203
clientHelper2.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
204
clientHelper2.
SetAttribute
205
(
"DataRate"
,
DataRateValue
(
DataRate
(
"10Mb/s"
)));
206
clientHelper2.
SetAttribute
207
(
"PacketSize"
,
UintegerValue
(1000));
208
209
ApplicationContainer
clientApps2;
210
AddressValue
remoteAddress2
211
(
InetSocketAddress
(
i3i5
.
GetAddress
(1), port2));
212
clientHelper2.
SetAttribute
(
"Remote"
, remoteAddress2);
213
clientApps2.
Add
(clientHelper2.
Install
(
n1n2
.
Get
(0)));
214
clientApps2.
Start
(
Seconds
(2.0));
215
clientApps2.
Stop
(
Seconds
(
client_stop_time
));
216
217
// Connection #3
218
OnOffHelper
clientHelper3 (
"ns3::TcpSocketFactory"
,
Address
());
219
clientHelper3.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
220
clientHelper3.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
221
clientHelper3.
SetAttribute
222
(
"DataRate"
,
DataRateValue
(
DataRate
(
"10Mb/s"
)));
223
clientHelper3.
SetAttribute
224
(
"PacketSize"
,
UintegerValue
(1000));
225
226
ApplicationContainer
clientApps3;
227
AddressValue
remoteAddress3
228
(
InetSocketAddress
(
i0i2
.
GetAddress
(0), port3));
229
clientHelper3.
SetAttribute
(
"Remote"
, remoteAddress3);
230
clientApps3.
Add
(clientHelper3.
Install
(
n3n4
.
Get
(1)));
231
clientApps3.
Start
(
Seconds
(3.5));
232
clientApps3.
Stop
(
Seconds
(
client_stop_time
));
233
234
// Connection #4
235
OnOffHelper
clientHelper4 (
"ns3::TcpSocketFactory"
,
Address
());
236
clientHelper4.
SetAttribute
(
"OnTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1]"
));
237
clientHelper4.
SetAttribute
(
"OffTime"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=0]"
));
238
clientHelper4.
SetAttribute
239
(
"DataRate"
,
DataRateValue
(
DataRate
(
"40b/s"
)));
240
clientHelper4.
SetAttribute
241
(
"PacketSize"
,
UintegerValue
(5 * 8));
// telnet
242
243
ApplicationContainer
clientApps4;
244
AddressValue
remoteAddress4
245
(
InetSocketAddress
(
i1i2
.
GetAddress
(0), port4));
246
clientHelper4.
SetAttribute
(
"Remote"
, remoteAddress4);
247
clientApps4.
Add
(clientHelper4.
Install
(
n3n5
.
Get
(1)));
248
clientApps4.
Start
(
Seconds
(1.0));
249
clientApps4.
Stop
(
Seconds
(
client_stop_time
));
250
}
251
}
252
253
int
254
main
(
int
argc,
char
*argv[])
255
{
256
// LogComponentEnable ("RedExamples", LOG_LEVEL_INFO);
257
// LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
258
// LogComponentEnable ("RedQueue", LOG_LEVEL_FUNCTION);
259
LogComponentEnable
(
"RedQueue"
,
LOG_LEVEL_INFO
);
260
261
uint32_t redTest;
262
std::string redLinkDataRate =
"1.5Mbps"
;
263
std::string redLinkDelay =
"20ms"
;
264
265
std::string pathOut;
266
bool
writeForPlot =
false
;
267
bool
writePcap =
false
;
268
bool
flowMonitor =
false
;
269
270
bool
printRedStats =
true
;
271
272
global_start_time
= 0.0;
273
global_stop_time
= 11;
274
sink_start_time
=
global_start_time
;
275
sink_stop_time
=
global_stop_time
+ 3.0;
276
client_start_time
=
sink_start_time
+ 0.2;
277
client_stop_time
=
global_stop_time
- 2.0;
278
279
// Configuration and command line parameter parsing
280
redTest = 1;
281
// Will only save in the directory if enable opts below
282
pathOut =
"."
;
// Current directory
283
CommandLine
cmd;
284
cmd.
AddValue
(
"testNumber"
,
"Run test 1, 3, 4 or 5"
, redTest);
285
cmd.
AddValue
(
"pathOut"
,
"Path to save results from --writeForPlot/--writePcap/--writeFlowMonitor"
, pathOut);
286
cmd.
AddValue
(
"writeForPlot"
,
"<0/1> to write results for plot (gnuplot)"
, writeForPlot);
287
cmd.
AddValue
(
"writePcap"
,
"<0/1> to write results in pcapfile"
, writePcap);
288
cmd.
AddValue
(
"writeFlowMonitor"
,
"<0/1> to enable Flow Monitor and write their results"
, flowMonitor);
289
290
cmd.
Parse
(argc, argv);
291
if
( (redTest != 1) && (redTest != 3) && (redTest != 4) && (redTest != 5) )
292
{
293
NS_ABORT_MSG
(
"Invalid test number. Supported tests are 1, 3, 4 or 5"
);
294
}
295
296
NS_LOG_INFO
(
"Create nodes"
);
297
NodeContainer
c;
298
c.
Create
(6);
299
Names::Add
(
"N0"
, c.
Get
(0));
300
Names::Add
(
"N1"
, c.
Get
(1));
301
Names::Add
(
"N2"
, c.
Get
(2));
302
Names::Add
(
"N3"
, c.
Get
(3));
303
Names::Add
(
"N4"
, c.
Get
(4));
304
Names::Add
(
"N5"
, c.
Get
(5));
305
n0n2
=
NodeContainer
(c.
Get
(0), c.
Get
(2));
306
n1n2
=
NodeContainer
(c.
Get
(1), c.
Get
(2));
307
n2n3
=
NodeContainer
(c.
Get
(2), c.
Get
(3));
308
n3n4
=
NodeContainer
(c.
Get
(3), c.
Get
(4));
309
n3n5
=
NodeContainer
(c.
Get
(3), c.
Get
(5));
310
311
Config::SetDefault
(
"ns3::TcpL4Protocol::SocketType"
,
StringValue
(
"ns3::TcpReno"
));
312
// 42 = headers size
313
Config::SetDefault
(
"ns3::TcpSocket::SegmentSize"
,
UintegerValue
(1000 - 42));
314
Config::SetDefault
(
"ns3::TcpSocket::DelAckCount"
,
UintegerValue
(1));
315
GlobalValue::Bind
(
"ChecksumEnabled"
,
BooleanValue
(
false
));
316
317
uint32_t meanPktSize = 500;
318
319
// RED params
320
NS_LOG_INFO
(
"Set RED params"
);
321
Config::SetDefault
(
"ns3::RedQueue::Mode"
,
StringValue
(
"QUEUE_MODE_PACKETS"
));
322
Config::SetDefault
(
"ns3::RedQueue::MeanPktSize"
,
UintegerValue
(meanPktSize));
323
Config::SetDefault
(
"ns3::RedQueue::Wait"
,
BooleanValue
(
true
));
324
Config::SetDefault
(
"ns3::RedQueue::Gentle"
,
BooleanValue
(
true
));
325
Config::SetDefault
(
"ns3::RedQueue::QW"
,
DoubleValue
(0.002));
326
Config::SetDefault
(
"ns3::RedQueue::MinTh"
,
DoubleValue
(5));
327
Config::SetDefault
(
"ns3::RedQueue::MaxTh"
,
DoubleValue
(15));
328
Config::SetDefault
(
"ns3::RedQueue::QueueLimit"
,
UintegerValue
(25));
329
330
if
(redTest == 3)
// test like 1, but with bad params
331
{
332
Config::SetDefault
(
"ns3::RedQueue::MaxTh"
,
DoubleValue
(10));
333
Config::SetDefault
(
"ns3::RedQueue::QW"
,
DoubleValue
(0.003));
334
}
335
else
if
(redTest == 5)
// test 5, same of test 4, but in byte mode
336
{
337
Config::SetDefault
(
"ns3::RedQueue::Mode"
,
StringValue
(
"QUEUE_MODE_BYTES"
));
338
Config::SetDefault
(
"ns3::RedQueue::Ns1Compat"
,
BooleanValue
(
true
));
339
Config::SetDefault
(
"ns3::RedQueue::MinTh"
,
DoubleValue
(5 * meanPktSize));
340
Config::SetDefault
(
"ns3::RedQueue::MaxTh"
,
DoubleValue
(15 * meanPktSize));
341
Config::SetDefault
(
"ns3::RedQueue::QueueLimit"
,
UintegerValue
(25 * meanPktSize));
342
}
343
344
NS_LOG_INFO
(
"Install internet stack on all nodes."
);
345
InternetStackHelper
internet;
346
internet.
Install
(c);
347
348
NS_LOG_INFO
(
"Create channels"
);
349
PointToPointHelper
p2p;
350
351
p2p.
SetQueue
(
"ns3::DropTailQueue"
);
352
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(
"10Mbps"
));
353
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(
"2ms"
));
354
NetDeviceContainer
devn0n2 = p2p.
Install
(n0n2);
355
356
p2p.
SetQueue
(
"ns3::DropTailQueue"
);
357
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(
"10Mbps"
));
358
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(
"3ms"
));
359
NetDeviceContainer
devn1n2 = p2p.
Install
(n1n2);
360
361
p2p.
SetQueue
(
"ns3::RedQueue"
,
// only backbone link has RED queue
362
"LinkBandwidth"
,
StringValue
(redLinkDataRate),
363
"LinkDelay"
,
StringValue
(redLinkDelay));
364
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(redLinkDataRate));
365
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(redLinkDelay));
366
NetDeviceContainer
devn2n3 = p2p.
Install
(n2n3);
367
368
p2p.
SetQueue
(
"ns3::DropTailQueue"
);
369
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(
"10Mbps"
));
370
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(
"4ms"
));
371
NetDeviceContainer
devn3n4 = p2p.
Install
(n3n4);
372
373
p2p.
SetQueue
(
"ns3::DropTailQueue"
);
374
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(
"10Mbps"
));
375
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(
"5ms"
));
376
NetDeviceContainer
devn3n5 = p2p.
Install
(n3n5);
377
378
NS_LOG_INFO
(
"Assign IP Addresses"
);
379
Ipv4AddressHelper
ipv4;
380
381
ipv4.
SetBase
(
"10.1.1.0"
,
"255.255.255.0"
);
382
i0i2
= ipv4.
Assign
(devn0n2);
383
384
ipv4.
SetBase
(
"10.1.2.0"
,
"255.255.255.0"
);
385
i1i2
= ipv4.
Assign
(devn1n2);
386
387
ipv4.
SetBase
(
"10.1.3.0"
,
"255.255.255.0"
);
388
i2i3
= ipv4.
Assign
(devn2n3);
389
390
ipv4.
SetBase
(
"10.1.4.0"
,
"255.255.255.0"
);
391
i3i4
= ipv4.
Assign
(devn3n4);
392
393
ipv4.
SetBase
(
"10.1.5.0"
,
"255.255.255.0"
);
394
i3i5
= ipv4.
Assign
(devn3n5);
395
396
// Set up the routing
397
Ipv4GlobalRoutingHelper::PopulateRoutingTables
();
398
399
if
(redTest == 5)
400
{
401
// like in ns2 test, r2 -> r1, have a queue in packet mode
402
Ptr<PointToPointNetDevice>
nd = StaticCast<PointToPointNetDevice> (devn2n3.
Get
(1));
403
Ptr<Queue>
queue = nd->
GetQueue
();
404
405
StaticCast<RedQueue> (queue)->SetMode (
RedQueue::QUEUE_MODE_PACKETS
);
406
StaticCast<RedQueue> (queue)->SetTh (5, 15);
407
StaticCast<RedQueue> (queue)->SetQueueLimit (25);
408
}
409
410
BuildAppsTest
(redTest);
411
412
if
(writePcap)
413
{
414
PointToPointHelper
ptp;
415
std::stringstream stmp;
416
stmp << pathOut <<
"/red"
;
417
ptp.
EnablePcapAll
(stmp.str ().c_str ());
418
}
419
420
Ptr<FlowMonitor>
flowmon;
421
if
(flowMonitor)
422
{
423
FlowMonitorHelper
flowmonHelper;
424
flowmon = flowmonHelper.
InstallAll
();
425
}
426
427
if
(writeForPlot)
428
{
429
filePlotQueue
<< pathOut <<
"/"
<<
"red-queue.plotme"
;
430
filePlotQueueAvg
<< pathOut <<
"/"
<<
"red-queue_avg.plotme"
;
431
432
remove
(
filePlotQueue
.str ().c_str ());
433
remove
(
filePlotQueueAvg
.str ().c_str ());
434
Ptr<PointToPointNetDevice>
nd = StaticCast<PointToPointNetDevice> (devn2n3.
Get
(0));
435
Ptr<Queue>
queue = nd->
GetQueue
();
436
Simulator::ScheduleNow
(&
CheckQueueSize
, queue);
437
}
438
439
Simulator::Stop
(
Seconds
(
sink_stop_time
));
440
Simulator::Run
();
441
442
if
(flowMonitor)
443
{
444
std::stringstream stmp;
445
stmp << pathOut <<
"/red.flowmon"
;
446
447
flowmon->
SerializeToXmlFile
(stmp.str ().c_str (),
false
,
false
);
448
}
449
450
if
(printRedStats)
451
{
452
Ptr<PointToPointNetDevice>
nd = StaticCast<PointToPointNetDevice> (devn2n3.
Get
(0));
453
RedQueue::Stats
st = StaticCast<RedQueue> (nd->
GetQueue
())->GetStats ();
454
std::cout <<
"*** RED stats from Node 2 queue ***"
<< std::endl;
455
std::cout <<
"\t "
<< st.unforcedDrop <<
" drops due prob mark"
<< std::endl;
456
std::cout <<
"\t "
<< st.forcedDrop <<
" drops due hard mark"
<< std::endl;
457
std::cout <<
"\t "
<< st.qLimDrop <<
" drops due queue full"
<< std::endl;
458
459
nd = StaticCast<PointToPointNetDevice> (devn2n3.
Get
(1));
460
st = StaticCast<RedQueue> (nd->
GetQueue
())->GetStats ();
461
std::cout <<
"*** RED stats from Node 3 queue ***"
<< std::endl;
462
std::cout <<
"\t "
<< st.unforcedDrop <<
" drops due prob mark"
<< std::endl;
463
std::cout <<
"\t "
<< st.forcedDrop <<
" drops due hard mark"
<< std::endl;
464
std::cout <<
"\t "
<< st.qLimDrop <<
" drops due queue full"
<< std::endl;
465
}
466
467
Simulator::Destroy
();
468
469
return
0;
470
}
src
network
examples
red-tests.cc
Generated on Fri Dec 21 2012 19:00:43 for ns-3 by
1.8.1.2