|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
2 |
/* |
3 |
* Copyright (c) 2013 ResiliNets, ITTC, University of Kansas |
3 |
* Copyright (c) 2013 ResiliNets, ITTC, University of Kansas |
4 |
* |
4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License version 2 as |
6 |
* it under the terms of the GNU General Public License version 2 as |
|
54 |
|
54 |
|
55 |
NS_LOG_COMPONENT_DEFINE ("TcpVariantsComparison"); |
55 |
NS_LOG_COMPONENT_DEFINE ("TcpVariantsComparison"); |
56 |
|
56 |
|
57 |
double old_time = 0.0; |
57 |
bool firstCwnd = true; |
58 |
EventId output; |
58 |
bool firstSshThr = true; |
59 |
Time current = Time::FromInteger(3, Time::S); //Only record cwnd and ssthresh values every 3 seconds |
59 |
Ptr<OutputStreamWrapper> cWndStream; |
60 |
bool first = true; |
60 |
Ptr<OutputStreamWrapper> ssThreshStream; |
|
|
61 |
uint32_t cWndValue; |
62 |
uint32_t ssThreshValue; |
63 |
|
61 |
|
64 |
|
62 |
static void |
65 |
static void |
63 |
OutputTrace () |
66 |
CwndTracer (uint32_t oldval, uint32_t newval) |
64 |
{ |
67 |
{ |
65 |
// *stream->GetStream() << newtime << " " << newval << std::endl; |
68 |
if (firstCwnd) |
66 |
// old_time = newval; |
69 |
{ |
|
|
70 |
*cWndStream->GetStream () << "0.0 " << oldval << std::endl; |
71 |
firstCwnd = false; |
72 |
} |
73 |
*cWndStream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl; |
74 |
cWndValue = newval; |
75 |
|
76 |
if (!firstSshThr) |
77 |
{ |
78 |
*ssThreshStream->GetStream () << Simulator::Now ().GetSeconds () << " " << ssThreshValue << std::endl; |
79 |
} |
67 |
} |
80 |
} |
68 |
|
81 |
|
69 |
static void |
82 |
static void |
70 |
CwndTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval) |
83 |
SsThreshTracer (uint32_t oldval, uint32_t newval) |
71 |
{ |
84 |
{ |
72 |
double new_time = Simulator::Now().GetSeconds(); |
85 |
if (firstSshThr) |
73 |
if (old_time == 0 && first) |
|
|
74 |
{ |
75 |
double mycurrent = current.GetSeconds(); |
76 |
*stream->GetStream() << new_time << " " << mycurrent << " " << newval << std::endl; |
77 |
first = false; |
78 |
output = Simulator::Schedule(current,&OutputTrace); |
79 |
} |
80 |
else |
81 |
{ |
82 |
if (output.IsExpired()) |
83 |
{ |
86 |
{ |
84 |
*stream->GetStream() << new_time << " " << newval << std::endl; |
87 |
*ssThreshStream->GetStream () << "0.0 " << oldval << std::endl; |
85 |
output.Cancel(); |
88 |
firstSshThr = false; |
86 |
output = Simulator::Schedule(current,&OutputTrace); |
|
|
87 |
} |
89 |
} |
88 |
} |
90 |
*ssThreshStream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl; |
|
|
91 |
ssThreshValue = newval; |
92 |
|
93 |
if (!firstCwnd) |
94 |
{ |
95 |
*cWndStream->GetStream () << Simulator::Now ().GetSeconds () << " " << cWndValue << std::endl; |
96 |
} |
89 |
} |
97 |
} |
90 |
|
98 |
|
91 |
static void |
|
|
92 |
SsThreshTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval) |
93 |
{ |
94 |
double new_time = Simulator::Now().GetSeconds(); |
95 |
if (old_time == 0 && first) |
96 |
{ |
97 |
double mycurrent = current.GetSeconds(); |
98 |
*stream->GetStream() << new_time << " " << mycurrent << " " << newval << std::endl; |
99 |
first = false; |
100 |
output = Simulator::Schedule(current,&OutputTrace); |
101 |
} |
102 |
else |
103 |
{ |
104 |
if (output.IsExpired()) |
105 |
{ |
106 |
*stream->GetStream() << new_time << " " << newval << std::endl; |
107 |
output.Cancel(); |
108 |
output = Simulator::Schedule(current,&OutputTrace); |
109 |
} |
110 |
} |
111 |
} |
112 |
|
99 |
|
113 |
static void |
100 |
static void |
114 |
TraceCwnd (std::string cwnd_tr_file_name) |
101 |
TraceCwnd (std::string cwnd_tr_file_name) |
115 |
{ |
102 |
{ |
116 |
AsciiTraceHelper ascii; |
103 |
AsciiTraceHelper ascii; |
117 |
if (cwnd_tr_file_name.compare("") == 0) |
104 |
if (cwnd_tr_file_name.compare ("") == 0) |
118 |
{ |
105 |
{ |
119 |
NS_LOG_DEBUG ("No trace file for cwnd provided"); |
106 |
NS_LOG_DEBUG ("No trace file for cwnd provided"); |
120 |
return; |
107 |
return; |
121 |
} |
108 |
} |
122 |
else |
109 |
else |
123 |
{ |
110 |
{ |
124 |
Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream(cwnd_tr_file_name.c_str()); |
111 |
cWndStream = ascii.CreateFileStream (cwnd_tr_file_name.c_str ()); |
125 |
Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",MakeBoundCallback (&CwndTracer, stream)); |
112 |
Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeCallback (&CwndTracer)); |
126 |
} |
113 |
} |
127 |
} |
114 |
} |
128 |
|
115 |
|
129 |
static void |
116 |
static void |
130 |
TraceSsThresh(std::string ssthresh_tr_file_name) |
117 |
TraceSsThresh (std::string ssthresh_tr_file_name) |
131 |
{ |
118 |
{ |
132 |
AsciiTraceHelper ascii; |
119 |
AsciiTraceHelper ascii; |
133 |
if (ssthresh_tr_file_name.compare("") == 0) |
120 |
if (ssthresh_tr_file_name.compare ("") == 0) |
134 |
{ |
121 |
{ |
135 |
NS_LOG_DEBUG ("No trace file for ssthresh provided"); |
122 |
NS_LOG_DEBUG ("No trace file for ssthresh provided"); |
136 |
return; |
123 |
return; |
137 |
} |
124 |
} |
138 |
else |
125 |
else |
139 |
{ |
126 |
{ |
140 |
Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream(ssthresh_tr_file_name.c_str()); |
127 |
ssThreshStream = ascii.CreateFileStream (ssthresh_tr_file_name.c_str ()); |
141 |
Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",MakeBoundCallback (&SsThreshTracer, stream)); |
128 |
Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",MakeCallback (&SsThreshTracer)); |
142 |
} |
129 |
} |
143 |
} |
130 |
} |
144 |
|
131 |
|
|
162 |
|
149 |
|
163 |
|
150 |
|
164 |
CommandLine cmd; |
151 |
CommandLine cmd; |
165 |
cmd.AddValue("transport_prot", "Transport protocol to use: TcpTahoe, TcpReno, TcpNewReno, TcpWestwood, TcpWestwoodPlus ", transport_prot); |
152 |
cmd.AddValue ("transport_prot", "Transport protocol to use: TcpTahoe, TcpReno, TcpNewReno, TcpWestwood, TcpWestwoodPlus ", transport_prot); |
166 |
cmd.AddValue("error_p", "Packet error rate", error_p); |
153 |
cmd.AddValue ("error_p", "Packet error rate", error_p); |
167 |
cmd.AddValue("bandwidth", "Bottleneck bandwidth", bandwidth); |
154 |
cmd.AddValue ("bandwidth", "Bottleneck bandwidth", bandwidth); |
168 |
cmd.AddValue("access_bandwidth", "Access link bandwidth", access_bandwidth); |
155 |
cmd.AddValue ("access_bandwidth", "Access link bandwidth", access_bandwidth); |
169 |
cmd.AddValue("delay", "Access link delay", access_delay); |
156 |
cmd.AddValue ("delay", "Access link delay", access_delay); |
170 |
cmd.AddValue("tracing", "Flag to enable/disable tracing", tracing); |
157 |
cmd.AddValue ("tracing", "Flag to enable/disable tracing", tracing); |
171 |
cmd.AddValue("tr_name", "Name of output trace file", tr_file_name); |
158 |
cmd.AddValue ("tr_name", "Name of output trace file", tr_file_name); |
172 |
cmd.AddValue("cwnd_tr_name", "Name of output trace file", cwnd_tr_file_name); |
159 |
cmd.AddValue ("cwnd_tr_name", "Name of output trace file", cwnd_tr_file_name); |
173 |
cmd.AddValue("ssthresh_tr_name", "Name of output trace file", ssthresh_tr_file_name); |
160 |
cmd.AddValue ("ssthresh_tr_name", "Name of output trace file", ssthresh_tr_file_name); |
174 |
cmd.AddValue("data", "Number of Megabytes of data to transmit", data_mbytes); |
161 |
cmd.AddValue ("data", "Number of Megabytes of data to transmit", data_mbytes); |
175 |
cmd.AddValue("mtu", "Size of IP packets to send in bytes", mtu_bytes); |
162 |
cmd.AddValue ("mtu", "Size of IP packets to send in bytes", mtu_bytes); |
176 |
cmd.AddValue("num_flows", "Number of flows", num_flows); |
163 |
cmd.AddValue ("num_flows", "Number of flows", num_flows); |
177 |
cmd.AddValue("duration", "Time to allow flows to run in seconds", duration); |
164 |
cmd.AddValue ("duration", "Time to allow flows to run in seconds", duration); |
178 |
cmd.AddValue("run", "Run index (for setting repeatable seeds)", run); |
165 |
cmd.AddValue ("run", "Run index (for setting repeatable seeds)", run); |
179 |
cmd.AddValue("flow_monitor", "Enable flow monitor", flow_monitor); |
166 |
cmd.AddValue ("flow_monitor", "Enable flow monitor", flow_monitor); |
180 |
cmd.Parse (argc, argv); |
167 |
cmd.Parse (argc, argv); |
181 |
|
168 |
|
182 |
SeedManager::SetSeed(1); |
169 |
SeedManager::SetSeed (1); |
183 |
SeedManager::SetRun(run); |
170 |
SeedManager::SetRun (run); |
184 |
|
171 |
|
185 |
// User may find it convenient to enable logging |
172 |
// User may find it convenient to enable logging |
186 |
//LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL); |
173 |
//LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL); |
|
188 |
//LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL); |
175 |
//LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL); |
189 |
|
176 |
|
190 |
// Calculate the ADU size |
177 |
// Calculate the ADU size |
191 |
Header* temp_header = new Ipv4Header(); |
178 |
Header* temp_header = new Ipv4Header (); |
192 |
uint32_t ip_header = temp_header->GetSerializedSize(); |
179 |
uint32_t ip_header = temp_header->GetSerializedSize (); |
193 |
NS_LOG_LOGIC ("IP Header size is: " << ip_header); |
180 |
NS_LOG_LOGIC ("IP Header size is: " << ip_header); |
194 |
delete temp_header; |
181 |
delete temp_header; |
195 |
temp_header = new TcpHeader(); |
182 |
temp_header = new TcpHeader (); |
196 |
uint32_t tcp_header = temp_header->GetSerializedSize(); |
183 |
uint32_t tcp_header = temp_header->GetSerializedSize (); |
197 |
NS_LOG_LOGIC ("TCP Header size is: " << tcp_header); |
184 |
NS_LOG_LOGIC ("TCP Header size is: " << tcp_header); |
198 |
delete temp_header; |
185 |
delete temp_header; |
199 |
uint32_t tcp_adu_size = mtu_bytes - (ip_header + tcp_header); |
186 |
uint32_t tcp_adu_size = mtu_bytes - (ip_header + tcp_header); |
|
204 |
float stop_time = start_time + duration; |
191 |
float stop_time = start_time + duration; |
205 |
|
192 |
|
206 |
// Select TCP variant |
193 |
// Select TCP variant |
207 |
if (transport_prot.compare("TcpTahoe") == 0) |
194 |
if (transport_prot.compare ("TcpTahoe") == 0) |
208 |
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpTahoe::GetTypeId())); |
195 |
{ |
209 |
else if (transport_prot.compare("TcpReno") == 0) |
196 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpTahoe::GetTypeId ())); |
210 |
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpReno::GetTypeId())); |
|
|
211 |
else if (transport_prot.compare("TcpNewReno") == 0) |
212 |
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpNewReno::GetTypeId())); |
213 |
else if (transport_prot.compare("TcpWestwood") == 0) |
214 |
{// the default protocol type in ns3::TcpWestwood is WESTWOOD |
215 |
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId())); |
216 |
Config::SetDefault("ns3::TcpWestwood::FilterType", EnumValue(TcpWestwood::TUSTIN)); |
217 |
} |
197 |
} |
218 |
else if (transport_prot.compare("TcpWestwoodPlus") == 0) |
198 |
else if (transport_prot.compare ("TcpReno") == 0) |
219 |
{ |
199 |
{ |
220 |
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId())); |
200 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpReno::GetTypeId ())); |
221 |
Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS)); |
201 |
} |
222 |
Config::SetDefault("ns3::TcpWestwood::FilterType", EnumValue(TcpWestwood::TUSTIN)); |
202 |
else if (transport_prot.compare ("TcpNewReno") == 0) |
|
|
203 |
{ |
204 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpNewReno::GetTypeId ())); |
205 |
} |
206 |
else if (transport_prot.compare ("TcpWestwood") == 0) |
207 |
{ // the default protocol type in ns3::TcpWestwood is WESTWOOD |
208 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ())); |
209 |
Config::SetDefault ("ns3::TcpWestwood::FilterType", EnumValue (TcpWestwood::TUSTIN)); |
210 |
} |
211 |
else if (transport_prot.compare ("TcpWestwoodPlus") == 0) |
212 |
{ |
213 |
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ())); |
214 |
Config::SetDefault ("ns3::TcpWestwood::ProtocolType", EnumValue (TcpWestwood::WESTWOODPLUS)); |
215 |
Config::SetDefault ("ns3::TcpWestwood::FilterType", EnumValue (TcpWestwood::TUSTIN)); |
223 |
} |
216 |
} |
224 |
else |
217 |
else |
225 |
{ |
218 |
{ |
|
231 |
NodeContainer gateways; |
224 |
NodeContainer gateways; |
232 |
gateways.Create (1); |
225 |
gateways.Create (1); |
233 |
NodeContainer sources; |
226 |
NodeContainer sources; |
234 |
sources.Create(num_flows); |
227 |
sources.Create (num_flows); |
235 |
NodeContainer sinks; |
228 |
NodeContainer sinks; |
236 |
sinks.Create(num_flows); |
229 |
sinks.Create (num_flows); |
237 |
|
230 |
|
238 |
// Configure the error model |
231 |
// Configure the error model |
239 |
// Here we use RateErrorModel with packet error rate |
232 |
// Here we use RateErrorModel with packet error rate |
240 |
Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable>(); |
233 |
Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> (); |
241 |
uv->SetStream (50); |
234 |
uv->SetStream (50); |
242 |
RateErrorModel error_model; |
235 |
RateErrorModel error_model; |
243 |
error_model.SetRandomVariable(uv); |
236 |
error_model.SetRandomVariable (uv); |
244 |
error_model.SetUnit(RateErrorModel::ERROR_UNIT_PACKET); |
237 |
error_model.SetUnit (RateErrorModel::ERROR_UNIT_PACKET); |
245 |
error_model.SetRate(error_p); |
238 |
error_model.SetRate (error_p); |
246 |
|
239 |
|
247 |
PointToPointHelper UnReLink; |
240 |
PointToPointHelper UnReLink; |
248 |
UnReLink.SetDeviceAttribute ("DataRate", StringValue (bandwidth)); |
241 |
UnReLink.SetDeviceAttribute ("DataRate", StringValue (bandwidth)); |
|
262 |
LocalLink.SetDeviceAttribute ("DataRate", StringValue (access_bandwidth)); |
255 |
LocalLink.SetDeviceAttribute ("DataRate", StringValue (access_bandwidth)); |
263 |
LocalLink.SetChannelAttribute ("Delay", StringValue (access_delay)); |
256 |
LocalLink.SetChannelAttribute ("Delay", StringValue (access_delay)); |
264 |
Ipv4InterfaceContainer sink_interfaces; |
257 |
Ipv4InterfaceContainer sink_interfaces; |
265 |
for (int i=0; i<num_flows; i++) |
258 |
for (int i = 0; i < num_flows; i++) |
266 |
{ |
259 |
{ |
267 |
NetDeviceContainer devices; |
260 |
NetDeviceContainer devices; |
268 |
devices = LocalLink.Install(sources.Get(i), gateways.Get(0)); |
261 |
devices = LocalLink.Install (sources.Get (i), gateways.Get (0)); |
269 |
address.NewNetwork(); |
262 |
address.NewNetwork (); |
270 |
Ipv4InterfaceContainer interfaces = address.Assign (devices); |
263 |
Ipv4InterfaceContainer interfaces = address.Assign (devices); |
271 |
devices = UnReLink.Install(gateways.Get(0), sinks.Get(i)); |
264 |
devices = UnReLink.Install (gateways.Get (0), sinks.Get (i)); |
272 |
address.NewNetwork(); |
265 |
address.NewNetwork (); |
273 |
interfaces = address.Assign (devices); |
266 |
interfaces = address.Assign (devices); |
274 |
sink_interfaces.Add(interfaces.Get(1)); |
267 |
sink_interfaces.Add (interfaces.Get (1)); |
275 |
} |
268 |
} |
276 |
|
269 |
|
277 |
NS_LOG_INFO ("Initialize Global Routing."); |
270 |
NS_LOG_INFO ("Initialize Global Routing."); |
|
281 |
Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); |
274 |
Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); |
282 |
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); |
275 |
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); |
283 |
|
276 |
|
284 |
for(uint16_t i=0; i<sources.GetN(); i++) |
277 |
for (uint16_t i = 0; i < sources.GetN (); i++) |
285 |
{ |
278 |
{ |
286 |
AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress(i, 0), port)); |
279 |
AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress (i, 0), port)); |
287 |
|
280 |
|
288 |
if (transport_prot.compare("TcpTahoe") == 0 |
281 |
if (transport_prot.compare ("TcpTahoe") == 0 |
289 |
|| transport_prot.compare("TcpReno") == 0 |
282 |
|| transport_prot.compare ("TcpReno") == 0 |
290 |
|| transport_prot.compare("TcpNewReno") == 0 |
283 |
|| transport_prot.compare ("TcpNewReno") == 0 |
291 |
|| transport_prot.compare("TcpWestwood") == 0 |
284 |
|| transport_prot.compare ("TcpWestwood") == 0 |
292 |
|| transport_prot.compare("TcpWestwoodPlus") == 0) |
285 |
|| transport_prot.compare ("TcpWestwoodPlus") == 0) |
293 |
{ |
286 |
{ |
294 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (tcp_adu_size)); |
287 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (tcp_adu_size)); |
295 |
BulkSendHelper ftp("ns3::TcpSocketFactory", Address()); |
288 |
BulkSendHelper ftp ("ns3::TcpSocketFactory", Address ()); |
296 |
ftp.SetAttribute ("Remote", remoteAddress); |
289 |
ftp.SetAttribute ("Remote", remoteAddress); |
297 |
ftp.SetAttribute ("SendSize", UintegerValue (tcp_adu_size)); |
290 |
ftp.SetAttribute ("SendSize", UintegerValue (tcp_adu_size)); |
298 |
ftp.SetAttribute ("MaxBytes", UintegerValue (int(data_mbytes*1000000))); |
291 |
ftp.SetAttribute ("MaxBytes", UintegerValue (int(data_mbytes * 1000000))); |
299 |
|
292 |
|
300 |
ApplicationContainer sourceApp = ftp.Install (sources.Get(i)); |
293 |
ApplicationContainer sourceApp = ftp.Install (sources.Get (i)); |
301 |
sourceApp.Start (Seconds (start_time*i)); |
294 |
sourceApp.Start (Seconds (start_time * i)); |
302 |
sourceApp.Stop (Seconds (stop_time - 3)); |
295 |
sourceApp.Stop (Seconds (stop_time - 3)); |
303 |
|
296 |
|
304 |
sinkHelper.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTypeId ())); |
297 |
sinkHelper.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTypeId ())); |
305 |
ApplicationContainer sinkApp = sinkHelper.Install (sinks); |
298 |
ApplicationContainer sinkApp = sinkHelper.Install (sinks); |
306 |
sinkApp.Start (Seconds (start_time*i)); |
299 |
sinkApp.Start (Seconds (start_time * i)); |
307 |
sinkApp.Stop (Seconds (stop_time)); |
300 |
sinkApp.Stop (Seconds (stop_time)); |
308 |
} |
301 |
} |
309 |
else |
302 |
else |
|
318 |
{ |
311 |
{ |
319 |
std::ofstream ascii; |
312 |
std::ofstream ascii; |
320 |
Ptr<OutputStreamWrapper> ascii_wrap; |
313 |
Ptr<OutputStreamWrapper> ascii_wrap; |
321 |
if (tr_file_name.compare("") == 0) |
314 |
if (tr_file_name.compare ("") == 0) |
322 |
{ |
315 |
{ |
323 |
NS_LOG_DEBUG ("No trace file provided"); |
316 |
NS_LOG_DEBUG ("No trace file provided"); |
324 |
exit (1); |
317 |
exit (1); |
325 |
} |
318 |
} |
326 |
else |
319 |
else |
327 |
{ |
320 |
{ |
328 |
ascii.open (tr_file_name.c_str()); |
321 |
ascii.open (tr_file_name.c_str ()); |
329 |
ascii_wrap = new OutputStreamWrapper(tr_file_name.c_str(), std::ios::out); |
322 |
ascii_wrap = new OutputStreamWrapper (tr_file_name.c_str (), std::ios::out); |
330 |
} |
323 |
} |
331 |
|
324 |
|
332 |
stack.EnableAsciiIpv4All (ascii_wrap); |
325 |
stack.EnableAsciiIpv4All (ascii_wrap); |
333 |
|
326 |
|
334 |
Simulator::Schedule(Seconds(0.00001), &TraceCwnd, cwnd_tr_file_name); |
327 |
Simulator::Schedule (Seconds (0.00001), &TraceCwnd, cwnd_tr_file_name); |
335 |
Simulator::Schedule(Seconds(0.00001), &TraceSsThresh, ssthresh_tr_file_name); |
328 |
Simulator::Schedule (Seconds (0.00001), &TraceSsThresh, ssthresh_tr_file_name); |
336 |
} |
329 |
} |
337 |
|
330 |
|
338 |
UnReLink.EnablePcapAll("TcpVariantsComparison", true); |
331 |
UnReLink.EnablePcapAll ("TcpVariantsComparison", true); |
339 |
LocalLink.EnablePcapAll("TcpVariantsComparison", true); |
332 |
LocalLink.EnablePcapAll ("TcpVariantsComparison", true); |
340 |
|
333 |
|
341 |
// Flow monitor |
334 |
// Flow monitor |
342 |
FlowMonitorHelper flowHelper; |
335 |
FlowMonitorHelper flowHelper; |
343 |
if (flow_monitor) |
336 |
if (flow_monitor) |
344 |
{ |
337 |
{ |
345 |
flowHelper.InstallAll(); |
338 |
flowHelper.InstallAll (); |
346 |
} |
339 |
} |
347 |
|
340 |
|
348 |
Simulator::Stop (Seconds(stop_time)); |
341 |
Simulator::Stop (Seconds (stop_time)); |
349 |
Simulator::Run (); |
342 |
Simulator::Run (); |
350 |
|
343 |
|
351 |
if (flow_monitor) |
344 |
if (flow_monitor) |
352 |
{ |
345 |
{ |
353 |
flowHelper.SerializeToXmlFile("TcpVariantsComparison.flowmonitor", true, true); |
346 |
flowHelper.SerializeToXmlFile ("TcpVariantsComparison.flowmonitor", true, true); |
354 |
} |
347 |
} |
355 |
|
348 |
|
356 |
Simulator::Destroy (); |
349 |
Simulator::Destroy (); |