Skip to content

Commit 98afe32

Browse files
committed
dumbbell mod
1 parent 56b1fea commit 98afe32

31 files changed

+102
-14050
lines changed

scratch/dumbbell.cc

+96-54
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ std::string folder;
5757
Time t;
5858
std::map<Ptr<PacketSink> ,uint32_t> flows;
5959
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;
6362

64-
uint32_t active_flows;
6563

64+
uint32_t active_flows;
65+
Ptr<OutputStreamWrapper> flowstream;
6666

6767
static void
6868
BufferChange (Ptr<OutputStreamWrapper> stream, uint32_t oldCwnd, uint32_t newCwnd)
@@ -80,15 +80,15 @@ BwChange (Ptr<OutputStreamWrapper> stream, double oldCwnd, double newCwnd)
8080

8181
void Sink(Ptr<PacketSink> psink, Ptr<const Packet> p,const Address &ad);
8282

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);
8585
void LogState(Ptr<InrppInterface> iface,uint32_t state);
8686

8787
int
8888
main (int argc, char *argv[])
8989
{
9090
//t = Simulator::Now();
91-
std::string protocol = "r";
91+
std::string protocol = "i";
9292
//i=0;
9393
//tracing = true;
9494
//tracing2 = true;
@@ -101,34 +101,14 @@ main (int argc, char *argv[])
101101
uint32_t bneck = 1000000000;
102102
uint32_t mean_n_pkts = (0.015*bneck)/(8*1500);
103103

104-
uint32_t maxPackets = (bneck * 0.05)/(8*1500);
104+
uint32_t maxPackets = (bneck * 0.05)/(8);
105+
106+
uint32_t maxTh = maxPackets;
105107
uint32_t minTh = maxPackets/2;
106-
uint32_t maxTh = maxPackets*0.9;
108+
107109
std::string folder;
108110
double load = 0.9;
109111

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));
132112

133113
//
134114
// Allow the user to override any of the defaults at
@@ -156,6 +136,33 @@ main (int argc, char *argv[])
156136
if (mean_n_pkts < 30)
157137
mean_n_pkts = 30;
158138

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+
159166
//
160167
// Explicitly create the nodes required by the topology (shown above).
161168
//
@@ -172,24 +179,24 @@ main (int argc, char *argv[])
172179

173180
if(protocol=="t"){
174181
pointToPoint.SetQueue ("ns3::DropTailQueue",
175-
"MaxBytes", UintegerValue(maxPackets*1500));
182+
"MaxBytes", UintegerValue(maxPackets));
176183
InternetStackHelper inrpp;
177184
inrpp.Install (nodes.Get(0));
178185
inrpp.Install (nodes.Get(1));
179186
} else if (protocol=="i") {
180187

181188
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));
185192

186193
InrppStackHelper inrpp;
187194
inrpp.Install (nodes.Get(0));
188195
inrpp.Install (nodes.Get(1));
189196
} else if (protocol=="r"){
190197

191198
pointToPoint.SetQueue ("ns3::RcpQueue",
192-
"MaxBytes", UintegerValue(maxPackets*1500),
199+
"MaxBytes", UintegerValue(maxPackets),
193200
"DataRate", StringValue (bottleneck));
194201

195202
InternetStackHelper inrpp;
@@ -226,20 +233,46 @@ main (int argc, char *argv[])
226233
double lambda = ((dr.GetBitRate() * load) / ((mean_n_pkts) * 1500 * 8.0));
227234
for(uint32_t i=0;i<n;i++)
228235
{
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+
231264
pointToPoint.SetQueue ("ns3::RcpQueue",
232-
"MaxBytes", UintegerValue(maxPackets*1500),
265+
"MaxBytes", UintegerValue(maxPackets),
233266
"DataRate", StringValue (bottleneck));
234-
}
235267

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+
}
239275

240-
InternetStackHelper internet;
241-
internet.Install (nodes.Get(2+i));
242-
internet.Install (nodes.Get(2+n+i));
243276

244277
senders.Add(nodes.Get(2+i));
245278

@@ -299,10 +332,10 @@ main (int argc, char *argv[])
299332
psink->SetCallback(MakeCallback(&StopFlow));
300333

301334

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());
306339
//DynamicCast<PacketSink> (sinkApps.Get (0))->TraceConnectWithoutContext ("EstimatedBW", MakeBoundCallback (&BwChange, streamtr));
307340

308341

@@ -352,6 +385,10 @@ main (int argc, char *argv[])
352385
Ptr<OutputStreamWrapper> streamtr2 = asciiTraceHelper.CreateFileStream (osstr2.str());
353386
txQueue2->GetObject<DropTailQueue>()->TraceConnectWithoutContext ("BytesQueue", MakeBoundCallback (&BufferChange, streamtr2));
354387

388+
389+
std::ostringstream osstr3;
390+
osstr3 << folder << "/flows.tr";
391+
flowstream = asciiTraceHelper.CreateFileStream (osstr3.str());
355392
//
356393
// Now, do the actual simulation.
357394
//
@@ -364,18 +401,23 @@ main (int argc, char *argv[])
364401
}
365402

366403

367-
void StartLog(Ptr<Socket> socket,Ptr<NetDevice> netDev)
404+
void StartLog(Ptr<Socket> socket,Ptr<NetDevice> netDev, uint16_t port)
368405
{
369406
active_flows++;
370-
NS_LOG_LOGIC("Start flow " << active_flows);
407+
NS_LOG_LOGIC("Start flow " << port << " " << active_flows);
371408
socket->BindToNetDevice(netDev);
409+
data.insert(std::make_pair(port,Simulator::Now()));
372410

373411
}
374412

375-
void StopFlow(Ptr<PacketSink> p)
413+
void StopFlow(Ptr<PacketSink> p, uint16_t port)
376414
{
377415
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;
379421

380422
}
381423

0 commit comments

Comments
 (0)