@@ -59,9 +59,8 @@ std::map<Ptr<PacketSink> ,uint32_t> flows;
59
59
uint32_t n;
60
60
std::vector<Ptr<PacketSink> > sink;*/
61
61
std::map<uint16_t ,Time> data;
62
-
62
+ uint32_t packetSize;
63
63
std::string folder;
64
-
65
64
uint32_t active_flows;
66
65
Ptr <OutputStreamWrapper> flowstream;
67
66
@@ -72,12 +71,12 @@ BufferChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwn
72
71
73
72
}
74
73
75
- static void
74
+ /* static void
76
75
BwChange (Ptr<OutputStreamWrapper> stream, double oldCwnd, double newCwnd)
77
76
{
78
77
*stream->GetStream () << Simulator::Now ().GetSeconds () << "\t" << newCwnd << std::endl;
79
78
80
- }
79
+ }*/
81
80
82
81
83
82
void LogCache (Ptr <InrppL3Protocol> inrpp)
@@ -92,37 +91,27 @@ void LogCache(Ptr<InrppL3Protocol> inrpp)
92
91
void Sink (Ptr <PacketSink> psink, Ptr <const Packet> p,const Address &ad);
93
92
94
93
void StartLog (Ptr <Socket> socket,Ptr <NetDevice> netDev, uint16_t port);
95
- void StopFlow (Ptr <PacketSink> p, uint16_t port);
94
+ void StopFlow (Ptr <PacketSink> p, uint16_t port, uint32_t size );
96
95
void LogState (Ptr <InrppInterface> iface,uint32_t state);
97
96
98
97
int
99
98
main (int argc, char *argv[])
100
99
{
101
- // t = Simulator::Now() ;
100
+ packetSize = 1500 ;
102
101
std::string protocol = " i" ;
103
- // i=0;
104
- // tracing = true;
105
- // tracing2 = true;
106
- // uint32_t maxBytes = 10000000;
107
- bool pcap_tracing=true ;
108
- uint32_t stop = 300 ;
109
- uint32_t n = 1000 ;
110
- // double time = 0.01;
111
- std::string bottleneck=" 1Gbps" ;
112
- uint32_t bneck = 1000000000 ;
113
- uint32_t mean_n_pkts = (0.015 *bneck)/(8 *1500 );
114
-
102
+ bool pcap_tracing=false ;
103
+ uint32_t stop = 300 ;
104
+ uint32_t n = 1000 ;
105
+ std::string bottleneck=" 1Gbps" ;
106
+ uint32_t bneck = 1000000000 ;
107
+ uint32_t mean_n_pkts = (0.015 *bneck)/(8 *packetSize);
115
108
uint32_t maxPackets = (bneck * 0.05 )/(8 );
116
-
117
109
uint32_t maxTh = maxPackets;
118
110
uint32_t minTh = maxPackets/2 ;
119
-
120
111
uint32_t hCacheTh = bneck * 10 /8 ;
121
112
uint32_t lCacheTh = hCacheTh/2 ;
122
113
uint32_t maxCacheSize = hCacheTh*2 ;
123
114
double load = 0.8 ;
124
-
125
-
126
115
//
127
116
// Allow the user to override any of the defaults at
128
117
// run-time, via command-line arguments
@@ -221,8 +210,6 @@ main (int argc, char *argv[])
221
210
pointToPoint.SetChannelAttribute (" Delay" , StringValue (" 5ms" ));
222
211
NetDeviceContainer devices = pointToPoint.Install (nodes.Get (0 ),nodes.Get (1 ));
223
212
224
-
225
-
226
213
//
227
214
// We've got the "hardware" in place. Now we need to add IP addresses.
228
215
//
@@ -238,19 +225,18 @@ main (int argc, char *argv[])
238
225
239
226
DataRate dr (bottleneck);
240
227
241
- double lambda = ((dr.GetBitRate () * load) / ((mean_n_pkts) * 1500 * 8.0 ));
242
-
228
+ double lambda = ((dr.GetBitRate () * load) / (mean_n_pkts * packetSize * 8.0 ));
243
229
230
+ NS_LOG_LOGIC (" LAmbda " << packetSize << " " << lambda);
244
231
Ptr <ExponentialRandomVariable> m_rv_flow_intval = CreateObject<ExponentialRandomVariable> ();
245
232
m_rv_flow_intval->SetAttribute (" Mean" , DoubleValue (1.0 /lambda));
246
233
m_rv_flow_intval->SetAttribute (" Stream" , IntegerValue (2 ));
247
234
248
235
Ptr <RandomVariableStream> m_rv_npkts = CreateObject<ParetoRandomVariable> ();
249
- m_rv_npkts->SetAttribute (" Mean" , DoubleValue (mean_n_pkts*1500 ));
236
+ m_rv_npkts->SetAttribute (" Mean" , DoubleValue (mean_n_pkts*packetSize ));
250
237
m_rv_npkts->SetAttribute (" Shape" , DoubleValue (1.2 ));
251
238
m_rv_npkts->SetAttribute (" Stream" , IntegerValue (-1 ));
252
239
253
-
254
240
double time = 1.0 ;
255
241
256
242
for (uint32_t i=0 ;i<n;i++)
@@ -295,7 +281,6 @@ main (int argc, char *argv[])
295
281
inrpp.Install (nodes.Get (2 +n+i));
296
282
}
297
283
298
-
299
284
senders.Add (nodes.Get (2 +i));
300
285
301
286
receivers.Add (nodes.Get (2 +n+i));
@@ -318,8 +303,6 @@ main (int argc, char *argv[])
318
303
NS_LOG_LOGIC (" Ip " << iSource.GetAddress(0 ));
319
304
NS_LOG_LOGIC (" Ip 2 " << iDest.GetAddress(1 ));
320
305
321
-
322
-
323
306
uint32_t packets = m_rv_npkts->GetInteger ();
324
307
325
308
BulkSendHelper source (" ns3::TcpSocketFactory" ,
@@ -345,14 +328,12 @@ main (int argc, char *argv[])
345
328
Ptr <PacketSink> psink = DynamicCast<PacketSink> (sinkApps.Get (0 ));
346
329
psink->SetCallback (MakeCallback (&StopFlow));
347
330
348
-
349
- AsciiTraceHelper asciiTraceHelper;
331
+ /* AsciiTraceHelper asciiTraceHelper;
350
332
std::ostringstream osstr;
351
333
osstr << folder << "/netdeviceRx_"<<i<<".tr";
352
334
Ptr<OutputStreamWrapper> streamtr = asciiTraceHelper.CreateFileStream (osstr.str());
353
335
DynamicCast<PacketSink> (sinkApps.Get (0))->TraceConnectWithoutContext ("EstimatedBW", MakeBoundCallback (&BwChange, streamtr));
354
-
355
-
336
+ */
356
337
num++;
357
338
if (num==256 )
358
339
{
@@ -362,7 +343,6 @@ main (int argc, char *argv[])
362
343
363
344
}
364
345
365
-
366
346
if (pcap_tracing)
367
347
{
368
348
std::ostringstream osstr3;
@@ -377,13 +357,9 @@ main (int argc, char *argv[])
377
357
Ptr <InrppL3Protocol> ip = nodes.Get (0 )->GetObject <InrppL3Protocol> ();
378
358
ip->SetCallback (MakeCallback (&LogState));
379
359
Simulator::Schedule (Seconds (1.0 ),&LogCache,ip);
380
-
381
-
382
360
}else
383
361
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
384
362
385
-
386
-
387
363
AsciiTraceHelper asciiTraceHelper;
388
364
PointerValue ptr;
389
365
devices.Get (0 )->GetAttribute (" TxQueue" , ptr);
@@ -426,18 +402,17 @@ void StartLog(Ptr<Socket> socket,Ptr<NetDevice> netDev, uint16_t port)
426
402
427
403
}
428
404
429
- void StopFlow (Ptr <PacketSink> p, uint16_t port)
405
+ void StopFlow (Ptr <PacketSink> p, uint16_t port, uint32_t size )
430
406
{
431
407
active_flows--;
432
- NS_LOG_LOGIC (" Flow ended " << port << " " << active_flows);
408
+ NS_LOG_LOGIC (" Flow ended " << port << " " << active_flows << " " << size/packetSize );
433
409
434
410
std::map<uint16_t ,Time>::iterator it = data.find (port);
435
411
if (it!=data.end ())
436
- *flowstream->GetStream () << Simulator::Now ().GetSeconds () << " \t " << port << " \t " << Simulator::Now ().GetSeconds ()-it->second .GetSeconds () << " \t " << active_flows << std::endl;
412
+ *flowstream->GetStream () << Simulator::Now ().GetSeconds () << " \t " << port << " \t " << Simulator::Now ().GetSeconds ()-it->second .GetSeconds () << " \t " << size/packetSize << " \t " << active_flows << std::endl;
437
413
438
414
}
439
415
440
-
441
416
void LogState (Ptr <InrppInterface> iface,uint32_t state){
442
417
443
418
NS_LOG_LOGIC (" Inrpp state changed " << iface << " to state " << state);
0 commit comments