Skip to content

Commit 7e80166

Browse files
author
srene
committed
minor updates
1 parent 0e9171b commit 7e80166

15 files changed

+110
-32
lines changed

examples/routing/simple-alternate-routing.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ main (int argc, char *argv[])
5353
{
5454
// Users may find it convenient to turn on explicit debugging
5555
// for selected modules; the below lines suggest how to do this
56-
#if 0
56+
#if 1
5757
LogComponentEnable ("GlobalRoutingHelper", LOG_LOGIC);
5858
LogComponentEnable ("GlobalRouter", LOG_LOGIC);
5959
#endif

scratch/base.cc

+14-13
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,26 @@ void TxPacket (Ipv4Address add, Ptr<const Packet> p);
121121
void LogCache(Ptr<InrppL3Protocol> inrpp);
122122
void LogCacheFlow(Ptr<OutputStreamWrapper> streamtr, Ptr<InrppL3Protocol> ip,Ptr<InrppInterface> iface,uint32_t flow);
123123
void LogFairness();
124+
124125
int
125126
main (int argc, char *argv[])
126127
{
127128
t = Simulator::Now();
128129
i=0;
129130
tracing = false;
130131
tracing2 = true;
131-
uint32_t maxBytes = 1000000;
132+
uint32_t maxBytes = 10000000;
132133
uint32_t stop = 100;
133134
n = 300;
134135
std::string bottleneck="100Mbps";
135-
uint32_t bneck = 100000000;
136+
uint32_t bneck = 100000000;
136137
double time = 0;
137138
uint32_t maxPackets = (bneck * 0.05)/(8);
138139
uint32_t maxTh = maxPackets;
139140
uint32_t minTh = maxPackets/2;
140-
uint32_t hCacheTh = bneck * 12.5;
141-
uint32_t lCacheTh = hCacheTh/2;
142-
uint32_t maxCacheSize = hCacheTh*2;
141+
uint32_t hCacheTh = bneck * 12.5;
142+
uint32_t lCacheTh = hCacheTh/2;
143+
uint32_t maxCacheSize = hCacheTh*2;
143144
protocol = "t";
144145

145146
//
@@ -173,9 +174,10 @@ main (int argc, char *argv[])
173174
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1458));
174175

175176
} else if(protocol=="r"){
176-
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpRcp::GetTypeId ()));
177-
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1434));
177+
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpRcp ::GetTypeId ()));
178+
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1434));
178179
Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (true));
180+
Config::SetDefault ("ns3::RcpQueue::upd_timeslot_", DoubleValue(0.005));
179181

180182

181183
} else if(protocol=="i"){
@@ -214,7 +216,7 @@ main (int argc, char *argv[])
214216

215217
if(protocol=="t"){
216218
pointToPoint.SetQueue ("ns3::DropTailQueue",
217-
"MaxBytes", UintegerValue(maxPackets*100));
219+
"MaxBytes", UintegerValue(maxPackets*1000));
218220
} else if (protocol=="i") {
219221

220222
pointToPoint.SetQueue ("ns3::InrppTailQueue",
@@ -288,7 +290,6 @@ main (int argc, char *argv[])
288290
devices1 = pointToPoint.Install (nodes.Get(1),nodes.Get(2));
289291

290292

291-
292293
//
293294
// We've got the "hardware" in place. Now we need to add IP addresses.
294295
//
@@ -360,7 +361,7 @@ main (int argc, char *argv[])
360361
std::ostringstream osstr3;
361362
osstr3 << folder << "/netdevice_" <<5+i<<".bf";
362363
Ptr<OutputStreamWrapper> streamtr3 = asciiTraceHelper.CreateFileStream (osstr3.str());
363-
txQueue3->GetObject<DropTailQueue>()->TraceConnectWithoutContext ("BytesQueue", MakeBoundCallback (&BufferChange, streamtr3));
364+
if(protocol!="r")txQueue3->GetObject<DropTailQueue>()->TraceConnectWithoutContext ("BytesQueue", MakeBoundCallback (&BufferChange, streamtr3));
364365

365366
tmap.insert(std::make_pair(iSource.GetAddress(0),Simulator::Now()));
366367
}
@@ -578,9 +579,9 @@ main (int argc, char *argv[])
578579
{
579580
std::ostringstream osstr;
580581
osstr << folder << "/inrpp2";
581-
pointToPoint.EnablePcap(osstr.str(),nodes, false);
582-
//pointToPoint.EnablePcap(osstr.str(),senders, false);
583-
//pointToPoint.EnablePcap(osstr.str(),receivers, false);
582+
//pointToPoint.EnablePcap(osstr.str(),nodes, false);
583+
pointToPoint.EnablePcap(osstr.str(),senders, false);
584+
pointToPoint.EnablePcap(osstr.str(),receivers, false);
584585
}
585586

586587
std::ostringstream osstrfct;

scratch/dumbbell.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ main (int argc, char *argv[])
143143
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1458));
144144

145145
} else if(protocol=="r"){
146-
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpRcp::GetTypeId ()));
146+
// Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpRcp::GetTypeId ()));
147147
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1434));
148148
Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (true));
149149

scratch/inrpp_rocketfuel.cc

100755100644
+13-10
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ main (int argc, char *argv[])
124124
std::string b2g_bottleneck = "20Gbps";
125125
std::string c2g_bottleneck = "20Gbps";
126126

127-
uint32_t bneck = 1000000000;
128-
uint32_t mean_n_pkts = (0.015*bneck)/(8*packetSize);
127+
uint32_t bneck = 1000000000;
128+
uint32_t mean_n_pkts = (0.015*bneck)/(8*packetSize);
129129

130130
uint32_t maxPackets = (bneck * 0.05)/(8);
131131

@@ -171,7 +171,9 @@ main (int argc, char *argv[])
171171

172172
} else if(protocol=="r"){
173173
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpRcp::GetTypeId ()));
174-
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1446));
174+
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1434));
175+
Config::SetDefault ("ns3::TcpSocketBase::Timestamp", BooleanValue (true));
176+
Config::SetDefault ("ns3::RcpQueue::upd_timeslot_", DoubleValue(0.005));
175177

176178
} else if(protocol=="i"){
177179
maxPackets = maxPackets*2;
@@ -219,7 +221,7 @@ main (int argc, char *argv[])
219221
const NodeContainer& BackBoneRouters = topo_reader.GetBackboneRouters();
220222
const NodeContainer& GatewayRouters = topo_reader.GetGatewayRouters();
221223
const NodeContainer& CustomerRouters = topo_reader.GetCustomerRouters();
222-
224+
223225
NS_LOG_INFO("Number of customer (edge) routers: "<<CustomerRouters.GetN());
224226
NS_LOG_INFO("Number of gateway routers: "<<GatewayRouters.GetN());
225227
NS_LOG_INFO("Number of backbone (core) routers: "<<BackBoneRouters.GetN());
@@ -261,15 +263,16 @@ main (int argc, char *argv[])
261263
pointToPoint.SetChannelAttribute ("Delay", StringValue ("5ms"));
262264
AsciiTraceHelper asciiTraceHelper;
263265
//Iterate through all the TopologyReader::Link objects and form the "real" links
264-
std::list<TopologyReader::Link> links = topo_reader.GetLinks();
266+
std::list<TopologyReader::Link> links = topo_reader.GetLinks();
267+
265268
for (std::list<TopologyReader::Link>::iterator it = links.begin(); it != links.end(); it++) {
266269
Ptr<Node> fromNode = it->GetFromNode();
267270
Ptr<Node> toNode = it->GetToNode();
268271
NetDeviceContainer devices = pointToPoint.Install (fromNode, toNode);
269272
//
270273
// We've got the "hardware" in place. Now we need to add IP addresses.
271274
//
272-
NS_LOG_INFO ("Assign IP Addresses.");
275+
//NS_LOG_INFO ("Assign IP Addresses.");
273276
std::stringstream netAddr;
274277
netAddr << "10." << net << "." << (num) << ".0";
275278
Ipv4AddressHelper ipv4;
@@ -314,7 +317,7 @@ main (int argc, char *argv[])
314317
double time = 1.0;
315318

316319
double lambda = ((dr.GetBitRate() * load) / ((mean_n_pkts) * 1500 * 8.0));
317-
320+
318321
m_rv_flow_intval= CreateObject<ExponentialRandomVariable> ();
319322

320323
m_rv_flow_intval->SetAttribute("Mean", DoubleValue(1.0/lambda));
@@ -334,10 +337,10 @@ main (int argc, char *argv[])
334337

335338
for(uint32_t pair = 0; pair < num_customers/2; pair++)
336339
{
337-
Ptr<Node> fromNode = CustomerRouters.Get(2*pair);
340+
Ptr<Node> fromNode = CustomerRouters.Get(2*pair);
338341
Ptr<Node> toNode = CustomerRouters.Get((2*pair)+1);
339342
time = 1.0;
340-
343+
341344
for(uint32_t i=0;i<n;i++)
342345
{
343346
NetDeviceContainer sourceLink;
@@ -418,7 +421,7 @@ main (int argc, char *argv[])
418421

419422
Ptr<BulkSendApplication> bulk = DynamicCast<BulkSendApplication> (sourceApps.Get (0));
420423
bulk->SetCallback(MakeCallback(&StartLog));
421-
bulk->SetNetDevice(sourceLink.Get(0));
424+
bulk->SetNetDevice(sourceLink.Get(1));
422425
Ptr<PacketSink> psink = DynamicCast<PacketSink> (sinkApps.Get (0));
423426
psink->SetCallback(MakeCallback(&StopFlow));
424427
/*

src/applications/model/packet-sink.cc

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ PacketSink::PacketSink ()
7171
NS_LOG_FUNCTION (this);
7272
m_socket = 0;
7373
m_totalRx = 0;
74+
m_currentBW = 0;
75+
m_lastSampleBW = 0;
76+
m_lastBW = 0;
77+
7478
}
7579

7680
PacketSink::~PacketSink()
@@ -239,6 +243,7 @@ void PacketSink::HandleAccept (Ptr<Socket> s, const Address& from)
239243
NS_LOG_FUNCTION (this << s << from);
240244
s->SetRecvCallback (MakeCallback (&PacketSink::HandleRead, this));
241245
m_socketList.push_back (s);
246+
t1 = Simulator::Now();
242247
}
243248

244249
Time PacketSink::GetCompletionTime()

src/inrpp/model/inrpp-interface.cc

+49-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ InrppInterface::TxRx(Ptr<const Packet> p, Ptr<NetDevice> dev1 , Ptr<NetDevice>
173173
m_lastSampleBW = sample_bwe;
174174
m_lastBW = m_currentBW;
175175
t1 = Simulator::Now();
176-
177176
}
177+
m_refreshEvent.Cancel();
178+
m_refreshEvent = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh,this);
178179
} else {
179180

180181
data3+= p->GetSize() * 8;
@@ -190,6 +191,9 @@ InrppInterface::TxRx(Ptr<const Packet> p, Ptr<NetDevice> dev1 , Ptr<NetDevice>
190191
t3 = Simulator::Now();
191192
}
192193

194+
m_refreshEvent3.Cancel();
195+
m_refreshEvent3 = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh3,this);
196+
193197
}
194198

195199
}
@@ -211,6 +215,8 @@ InrppInterface::CalculateFlow(Ptr<const Packet> p)
211215
t2 = Simulator::Now();
212216

213217
}
218+
m_refreshEvent2.Cancel();
219+
m_refreshEvent2 = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh2,this);
214220

215221
if(GetState()==DISABLE_BACK&&m_cache->GetSize()==0)
216222
{
@@ -391,6 +397,11 @@ InrppInterface::SetRate(DataRate bps)
391397
m_bps = bps;
392398
}
393399

400+
DataRate
401+
InrppInterface::GetRate()
402+
{
403+
return m_bps;
404+
}
394405

395406
void
396407
InrppInterface::SetInrppL3Protocol(Ptr<InrppL3Protocol> inrpp)
@@ -584,5 +595,41 @@ InrppInterface::GetEnabled(void)
584595
return m_enabled;
585596
}
586597

587-
} // namespace ns3
598+
void
599+
InrppInterface::Refresh(void)
600+
{
601+
double sample_bwe = 0;
602+
double alpha = 0.6;
603+
m_currentBW = (alpha * m_lastBW) + ((1 - alpha) * ((sample_bwe + m_lastSampleBW) / 2));
604+
m_lastSampleBW = sample_bwe;
605+
m_lastBW = m_currentBW;
606+
t1 = Simulator::Now();
607+
m_refreshEvent = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh,this);
608+
}
609+
610+
void
611+
InrppInterface::Refresh2(void)
612+
{
613+
double sample_bwe = 0;
614+
double alpha = 0.6;
615+
m_currentBW2 = (alpha * m_lastBW2) + ((1 - alpha) * ((sample_bwe + m_lastSampleBW2) / 2));
616+
m_lastSampleBW2 = sample_bwe;
617+
m_lastBW2 = m_currentBW2;
618+
t2 = Simulator::Now();
619+
m_refreshEvent2 = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh2,this);
620+
}
621+
622+
void
623+
InrppInterface::Refresh3(void)
624+
{
625+
double sample_bwe = 0;
626+
double alpha = 0.6;
627+
m_currentBW3 = (alpha * m_lastBW3) + ((1 - alpha) * ((sample_bwe + m_lastSampleBW3) / 2));
628+
m_lastSampleBW3 = sample_bwe;
629+
m_lastBW3 = m_currentBW3;
630+
t3 = Simulator::Now();
631+
m_refreshEvent3 = Simulator::Schedule(Seconds(m_refresh),&InrppInterface::Refresh3,this);
632+
}
633+
}
634+
// namespace ns3
588635

src/inrpp/model/inrpp-interface.h

+10
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ class InrppInterface : public Ipv4Interface
138138

139139
void SetRate(DataRate bps);
140140

141+
DataRate GetRate();
142+
141143
void SendPacket();
142144

143145
void SetInrppL3Protocol(Ptr<InrppL3Protocol> inrpp);
@@ -171,6 +173,9 @@ class InrppInterface : public Ipv4Interface
171173
void TxRx(Ptr<const Packet> p, Ptr<NetDevice> dev1 , Ptr<NetDevice> dev2, Time tr, Time rcv);
172174
void SendResidual();
173175
void Drop(Ptr<const Packet> p);
176+
void Refresh(void);
177+
void Refresh2(void);
178+
void Refresh3(void);
174179

175180
TracedValue<double> m_currentBW; //!< Current value of the estimated BW
176181
double m_lastSampleBW; //!< Last bandwidth sample
@@ -229,6 +234,11 @@ class InrppInterface : public Ipv4Interface
229234
uint32_t m_lastDetoured;
230235

231236
bool m_enabled;
237+
238+
EventId m_refreshEvent; //!< Transmit cached packet event
239+
EventId m_refreshEvent2; //!< Transmit cached packet event
240+
EventId m_refreshEvent3; //!< Transmit cached packet event
241+
232242
};
233243

234244
} // namespace ns3

src/inrpp/model/inrpp-l3-protocol.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ InrppL3Protocol::SendInrppInfo (Ptr<InrppInterface> sourceIface, Ptr<InrppInterf
146146
packet->AddHeader(inrpp);
147147
destDevice->Send (packet, destDevice->GetBroadcast (), InrppL3Protocol::PROT_NUMBER);
148148

149-
Simulator::Schedule (Seconds (0.01),&InrppL3Protocol::SendInrppInfo,this,sourceIface,destIface,infoAddress);
149+
double rate = 1000000/(double) sourceIface->GetRate().GetBitRate();
150+
Simulator::Schedule (Seconds (rate),&InrppL3Protocol::SendInrppInfo,this,sourceIface,destIface,infoAddress);
150151

151152
}
152153

src/inrpp/model/tcp-inrpp.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ TcpInrpp::SendPendingData (bool withAck)
475475
m_nextTxSequence += sz; // Advance next tx sequence
476476

477477
data+= sz * 8;
478+
479+
NS_LOG_LOGIC("Data " << data);
478480
if(Simulator::Now().GetSeconds()-t1.GetSeconds()>0.1){
481+
479482
m_currentBW = data / (Simulator::Now().GetSeconds()-t1.GetSeconds());
480483
data = 0;
481484
double alpha = 0.4;
@@ -496,8 +499,8 @@ TcpInrpp::SendPendingData (bool withAck)
496499
// Try to send more data
497500
if (!m_sendPendingDataEvent.IsRunning ())
498501
{
499-
Time t = Seconds(((double)(m_segmentSize+42)*8)/m_tcpRate);
500-
NS_LOG_LOGIC("Schedule next packet at " << Simulator::Now().GetSeconds()+t.GetSeconds());
502+
Time t = Seconds(((double)(m_segmentSize+54)*8)/m_tcpRate);
503+
NS_LOG_LOGIC("Schedule next packet at " << t.GetSeconds());
501504
m_sendPendingDataEvent = Simulator::Schedule (t, &TcpInrpp::SendPendingData, this, m_connected);
502505
}
503506

src/internet/model/tcp-l4-protocol.cc

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ TcpL4Protocol::SetNode (Ptr<Node> node)
105105
m_node = node;
106106
}
107107

108+
std::vector<Ptr<TcpSocketBase> >
109+
TcpL4Protocol::GetSockets (void) const
110+
{
111+
return m_sockets;
112+
}
113+
108114
/*
109115
* This method is called by AddAgregate and completes the aggregation
110116
* by setting the node in the TCP stack, link it to the ipv4 stack and

src/internet/model/tcp-l4-protocol.h

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ class TcpL4Protocol : public IpL4Protocol {
220220
virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
221221
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const;
222222

223+
virtual std::vector<Ptr<TcpSocketBase> > GetSockets(void) const; //MESF
224+
223225
protected:
224226
virtual void DoDispose (void);
225227
/*

src/rcp/model/rcp-queue.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ TypeId RcpQueue::GetTypeId (void)
127127
MakeDoubleChecker<double> ())
128128
.AddAttribute ("upd_timeslot_",
129129
"The lower threshold number of bytes accepted by this RcpQueue.",
130-
DoubleValue (0.05),
130+
DoubleValue (0.001),
131131
MakeDoubleAccessor (&RcpQueue::upd_timeslot_),
132132
MakeDoubleChecker<double> ())
133133
.AddAttribute ("rate_fact_mode_",

src/rcp/model/tcp-rcp.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ TcpRcp::TcpRcp (void)
9696
m_lastBW(0),
9797
data(0),
9898
m_slot(0),
99-
m_tcpRate(1000),
99+
m_tcpRate(1000000000),
100100
rtt_(1.0),
101101
min_rtt_(1.0),
102102
m_pktsRx(0)

utils.pyc

0 Bytes
Binary file not shown.

wutils.pyc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)