@@ -57,12 +57,12 @@ std::string folder;
57
57
Time t;
58
58
std::map<Ptr<PacketSink> ,uint32_t> flows;
59
59
uint32_t n;
60
- std::vector<Ptr<PacketSink> > sink;
61
- std::map<Ptr<PacketSink> ,uint32_t> data;
62
- */
60
+ std::vector<Ptr<PacketSink> > sink;*/
61
+ std::map<uint16_t ,Time> data;
63
62
64
- uint32_t active_flows;
65
63
64
+ uint32_t active_flows;
65
+ Ptr <OutputStreamWrapper> flowstream;
66
66
67
67
static void
68
68
BufferChange (Ptr <OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
@@ -80,15 +80,15 @@ BwChange (Ptr<OutputStreamWrapper> stream, double oldCwnd, double newCwnd)
80
80
81
81
void Sink (Ptr <PacketSink> psink, Ptr <const Packet> p,const Address &ad);
82
82
83
- void StartLog (Ptr <Socket> socket,Ptr <NetDevice> netDev);
84
- void StopFlow (Ptr <PacketSink> p);
83
+ void StartLog (Ptr <Socket> socket,Ptr <NetDevice> netDev, uint16_t port );
84
+ void StopFlow (Ptr <PacketSink> p, uint16_t port );
85
85
void LogState (Ptr <InrppInterface> iface,uint32_t state);
86
86
87
87
int
88
88
main (int argc, char *argv[])
89
89
{
90
90
// t = Simulator::Now();
91
- std::string protocol = " r " ;
91
+ std::string protocol = " i " ;
92
92
// i=0;
93
93
// tracing = true;
94
94
// tracing2 = true;
@@ -101,34 +101,14 @@ main (int argc, char *argv[])
101
101
uint32_t bneck = 1000000000 ;
102
102
uint32_t mean_n_pkts = (0.015 *bneck)/(8 *1500 );
103
103
104
- uint32_t maxPackets = (bneck * 0.05 )/(8 *1500 );
104
+ uint32_t maxPackets = (bneck * 0.05 )/(8 );
105
+
106
+ uint32_t maxTh = maxPackets;
105
107
uint32_t minTh = maxPackets/2 ;
106
- uint32_t maxTh = maxPackets* 0.9 ;
108
+
107
109
std::string folder;
108
110
double load = 0.9 ;
109
111
110
- if (protocol==" t" ){
111
- Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpNewReno::GetTypeId ()));
112
- Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1458 ));
113
-
114
- } else if (protocol==" r" ){
115
- Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpRcp::GetTypeId ()));
116
- Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1446 ));
117
-
118
- } else if (protocol==" i" ){
119
- Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpInrpp::GetTypeId ()));
120
- Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1446 ));
121
- }
122
-
123
- Config::SetDefault (" ns3::TcpSocket::SndBufSize" , UintegerValue (10000000 ));
124
- Config::SetDefault (" ns3::TcpSocket::RcvBufSize" , UintegerValue (10000000 ));
125
- Config::SetDefault (" ns3::InrppCache::MaxCacheSize" , UintegerValue (4000000000 ));
126
- Config::SetDefault (" ns3::InrppCache::HighThresholdCacheSize" , UintegerValue (1250000000 ));
127
- Config::SetDefault (" ns3::InrppCache::LowThresholdCacheSize" , UintegerValue (620000000 ));
128
- Config::SetDefault (" ns3::DropTailQueue::Mode" , EnumValue (DropTailQueue::QUEUE_MODE_BYTES));
129
- Config::SetDefault (" ns3::TcpSocket::DelAckCount" , UintegerValue (1 ));
130
- Config::SetDefault (" ns3::InrppL3Protocol::NumSlot" , UintegerValue (n));
131
- Config::SetDefault (" ns3::InrppInterface::Refresh" , DoubleValue (0.01 ));
132
112
133
113
//
134
114
// Allow the user to override any of the defaults at
@@ -156,6 +136,33 @@ main (int argc, char *argv[])
156
136
if (mean_n_pkts < 30 )
157
137
mean_n_pkts = 30 ;
158
138
139
+
140
+ if (protocol==" t" ){
141
+ Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpNewReno::GetTypeId ()));
142
+ Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1458 ));
143
+
144
+ } else if (protocol==" r" ){
145
+ Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpRcp::GetTypeId ()));
146
+ Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1446 ));
147
+
148
+ } else if (protocol==" i" ){
149
+ maxPackets = maxPackets*2 ;
150
+ Config::SetDefault (" ns3::TcpL4Protocol::SocketType" , TypeIdValue (TcpInrpp::GetTypeId ()));
151
+ Config::SetDefault (" ns3::TcpSocket::SegmentSize" , UintegerValue (1446 ));
152
+ Config::SetDefault (" ns3::InrppCache::MaxCacheSize" , UintegerValue (maxPackets));
153
+ Config::SetDefault (" ns3::InrppCache::HighThresholdCacheSize" , UintegerValue (maxTh));
154
+ Config::SetDefault (" ns3::InrppCache::LowThresholdCacheSize" , UintegerValue (minTh));
155
+ Config::SetDefault (" ns3::InrppL3Protocol::NumSlot" , UintegerValue (n));
156
+ Config::SetDefault (" ns3::InrppInterface::Refresh" , DoubleValue (0.01 ));
157
+
158
+ }
159
+
160
+ Config::SetDefault (" ns3::TcpSocket::SndBufSize" , UintegerValue (10000000 ));
161
+ Config::SetDefault (" ns3::TcpSocket::RcvBufSize" , UintegerValue (10000000 ));
162
+
163
+ Config::SetDefault (" ns3::DropTailQueue::Mode" , EnumValue (DropTailQueue::QUEUE_MODE_BYTES));
164
+ Config::SetDefault (" ns3::TcpSocket::DelAckCount" , UintegerValue (1 ));
165
+
159
166
//
160
167
// Explicitly create the nodes required by the topology (shown above).
161
168
//
@@ -172,24 +179,24 @@ main (int argc, char *argv[])
172
179
173
180
if (protocol==" t" ){
174
181
pointToPoint.SetQueue (" ns3::DropTailQueue" ,
175
- " MaxBytes" , UintegerValue (maxPackets* 1500 ));
182
+ " MaxBytes" , UintegerValue (maxPackets));
176
183
InternetStackHelper inrpp;
177
184
inrpp.Install (nodes.Get (0 ));
178
185
inrpp.Install (nodes.Get (1 ));
179
186
} else if (protocol==" i" ) {
180
187
181
188
pointToPoint.SetQueue (" ns3::InrppTailQueue" ,
182
- " LowerThBytes" , UintegerValue (minTh* 1500 ),
183
- " HigherThBytes" , UintegerValue (maxTh* 1500 ),
184
- " MaxBytes" , UintegerValue (maxPackets* 1500 ));
189
+ " LowerThBytes" , UintegerValue (minTh),
190
+ " HigherThBytes" , UintegerValue (maxTh),
191
+ " MaxBytes" , UintegerValue (maxPackets));
185
192
186
193
InrppStackHelper inrpp;
187
194
inrpp.Install (nodes.Get (0 ));
188
195
inrpp.Install (nodes.Get (1 ));
189
196
} else if (protocol==" r" ){
190
197
191
198
pointToPoint.SetQueue (" ns3::RcpQueue" ,
192
- " MaxBytes" , UintegerValue (maxPackets* 1500 ),
199
+ " MaxBytes" , UintegerValue (maxPackets),
193
200
" DataRate" , StringValue (bottleneck));
194
201
195
202
InternetStackHelper inrpp;
@@ -226,20 +233,46 @@ main (int argc, char *argv[])
226
233
double lambda = ((dr.GetBitRate () * load) / ((mean_n_pkts) * 1500 * 8.0 ));
227
234
for (uint32_t i=0 ;i<n;i++)
228
235
{
229
- if (protocol==" r" )
230
- {
236
+
237
+ NetDeviceContainer sourceLink;
238
+ NetDeviceContainer destLink;
239
+
240
+ if (protocol==" t" ){
241
+ pointToPoint.SetQueue (" ns3::DropTailQueue" ,
242
+ " MaxBytes" , UintegerValue (maxPackets));
243
+ sourceLink = pointToPoint.Install (nodes.Get (2 +i),nodes.Get (0 ));
244
+ destLink = pointToPoint.Install (nodes.Get (1 ),nodes.Get (2 +n+i));
245
+
246
+ InternetStackHelper inrpp;
247
+ inrpp.Install (nodes.Get (2 +i));
248
+ inrpp.Install (nodes.Get (2 +n+i));
249
+ } else if (protocol==" i" ) {
250
+
251
+ pointToPoint.SetQueue (" ns3::InrppTailQueue" ,
252
+ " LowerThBytes" , UintegerValue (minTh),
253
+ " HigherThBytes" , UintegerValue (maxTh),
254
+ " MaxBytes" , UintegerValue (maxPackets));
255
+
256
+ sourceLink = pointToPoint.Install (nodes.Get (2 +i),nodes.Get (0 ));
257
+ destLink = pointToPoint.Install (nodes.Get (1 ),nodes.Get (2 +n+i));
258
+
259
+ InrppStackHelper inrpp;
260
+ inrpp.Install (nodes.Get (2 +i));
261
+ inrpp.Install (nodes.Get (2 +n+i));
262
+ } else if (protocol==" r" ){
263
+
231
264
pointToPoint.SetQueue (" ns3::RcpQueue" ,
232
- " MaxBytes" , UintegerValue (maxPackets* 1500 ),
265
+ " MaxBytes" , UintegerValue (maxPackets),
233
266
" DataRate" , StringValue (bottleneck));
234
- }
235
267
236
- pointToPoint.SetDeviceAttribute (" DataRate" , StringValue (bottleneck));
237
- NetDeviceContainer sourceLink = pointToPoint.Install (nodes.Get (2 +i),nodes.Get (0 ));
238
- NetDeviceContainer destLink = pointToPoint.Install (nodes.Get (1 ),nodes.Get (2 +n+i));
268
+ sourceLink = pointToPoint.Install (nodes.Get (2 +i),nodes.Get (0 ));
269
+ destLink = pointToPoint.Install (nodes.Get (1 ),nodes.Get (2 +n+i));
270
+
271
+ InternetStackHelper inrpp;
272
+ inrpp.Install (nodes.Get (2 +i));
273
+ inrpp.Install (nodes.Get (2 +n+i));
274
+ }
239
275
240
- InternetStackHelper internet;
241
- internet.Install (nodes.Get (2 +i));
242
- internet.Install (nodes.Get (2 +n+i));
243
276
244
277
senders.Add (nodes.Get (2 +i));
245
278
@@ -299,10 +332,10 @@ main (int argc, char *argv[])
299
332
psink->SetCallback (MakeCallback (&StopFlow));
300
333
301
334
302
- AsciiTraceHelper asciiTraceHelper;
303
- std::ostringstream osstr;
304
- osstr << folder << " /netdeviceRx_" <<i<<" .tr" ;
305
- Ptr <OutputStreamWrapper> streamtr = asciiTraceHelper.CreateFileStream (osstr.str ());
335
+ // AsciiTraceHelper asciiTraceHelper;
336
+ // std::ostringstream osstr;
337
+ // osstr << folder << "/netdeviceRx_"<<i<<".tr";
338
+ // Ptr<OutputStreamWrapper> streamtr = asciiTraceHelper.CreateFileStream (osstr.str());
306
339
// DynamicCast<PacketSink> (sinkApps.Get (0))->TraceConnectWithoutContext ("EstimatedBW", MakeBoundCallback (&BwChange, streamtr));
307
340
308
341
@@ -352,6 +385,10 @@ main (int argc, char *argv[])
352
385
Ptr <OutputStreamWrapper> streamtr2 = asciiTraceHelper.CreateFileStream (osstr2.str ());
353
386
txQueue2->GetObject <DropTailQueue>()->TraceConnectWithoutContext (" BytesQueue" , MakeBoundCallback (&BufferChange, streamtr2));
354
387
388
+
389
+ std::ostringstream osstr3;
390
+ osstr3 << folder << " /flows.tr" ;
391
+ flowstream = asciiTraceHelper.CreateFileStream (osstr3.str ());
355
392
//
356
393
// Now, do the actual simulation.
357
394
//
@@ -364,18 +401,23 @@ main (int argc, char *argv[])
364
401
}
365
402
366
403
367
- void StartLog (Ptr <Socket> socket,Ptr <NetDevice> netDev)
404
+ void StartLog (Ptr <Socket> socket,Ptr <NetDevice> netDev, uint16_t port )
368
405
{
369
406
active_flows++;
370
- NS_LOG_LOGIC (" Start flow " << active_flows);
407
+ NS_LOG_LOGIC (" Start flow " << port << " " << active_flows);
371
408
socket->BindToNetDevice (netDev);
409
+ data.insert (std::make_pair (port,Simulator::Now ()));
372
410
373
411
}
374
412
375
- void StopFlow (Ptr <PacketSink> p)
413
+ void StopFlow (Ptr <PacketSink> p, uint16_t port )
376
414
{
377
415
active_flows--;
378
- NS_LOG_LOGIC (" Flow ended " <<active_flows);
416
+ NS_LOG_LOGIC (" Flow ended " << port << " " << active_flows);
417
+
418
+ std::map<uint16_t ,Time>::iterator it = data.find (port);
419
+ if (it!=data.end ())
420
+ *flowstream->GetStream () << Simulator::Now ().GetSeconds () << " \t " << port << " \t " << Simulator::Now ().GetSeconds ()-it->second .GetSeconds () << " \t " << active_flows << std::endl;
379
421
380
422
}
381
423
0 commit comments