40 #include "ns3/core-module.h"
41 #include "ns3/network-module.h"
42 #include "ns3/internet-module.h"
43 #include "ns3/point-to-point-module.h"
44 #include "ns3/applications-module.h"
45 #include "ns3/error-model.h"
46 #include "ns3/tcp-header.h"
47 #include "ns3/udp-header.h"
49 #include "ns3/event-id.h"
50 #include "ns3/flow-monitor-helper.h"
51 #include "ns3/ipv4-global-routing-helper.h"
76 *stream->
GetStream() << new_time <<
" " << mycurrent <<
" " << newval << std::endl;
84 *stream->
GetStream() << new_time <<
" " << newval << std::endl;
98 *stream->
GetStream() << new_time <<
" " << mycurrent <<
" " << newval << std::endl;
106 *stream->
GetStream() << new_time <<
" " << newval << std::endl;
117 if (cwnd_tr_file_name.compare(
"") == 0)
133 if (ssthresh_tr_file_name.compare(
"") == 0)
145 int main (
int argc,
char *argv[])
147 std::string transport_prot =
"TcpWestwood";
148 double error_p = 0.0;
149 std::string bandwidth =
"2Mbps";
150 std::string access_bandwidth =
"10Mbps";
151 std::string access_delay =
"45ms";
152 bool tracing =
false;
153 std::string tr_file_name =
"";
154 std::string cwnd_tr_file_name =
"";
155 std::string ssthresh_tr_file_name =
"";
156 double data_mbytes = 0;
157 uint32_t mtu_bytes = 400;
158 uint16_t num_flows = 1;
159 float duration = 100;
161 bool flow_monitor =
true;
165 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);
167 cmd.
AddValue(
"bandwidth",
"Bottleneck bandwidth", bandwidth);
168 cmd.
AddValue(
"access_bandwidth",
"Access link bandwidth", access_bandwidth);
169 cmd.
AddValue(
"delay",
"Access link delay", access_delay);
170 cmd.
AddValue(
"tracing",
"Flag to enable/disable tracing", tracing);
171 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);
173 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);
175 cmd.
AddValue(
"mtu",
"Size of IP packets to send in bytes", mtu_bytes);
176 cmd.
AddValue(
"num_flows",
"Number of flows", num_flows);
177 cmd.
AddValue(
"duration",
"Time to allow flows to run in seconds", duration);
178 cmd.
AddValue(
"run",
"Run index (for setting repeatable seeds)", run);
179 cmd.
AddValue(
"flow_monitor",
"Enable flow monitor", flow_monitor);
180 cmd.
Parse (argc, argv);
199 uint32_t tcp_adu_size = mtu_bytes - (ip_header + tcp_header);
203 float start_time = 0.1;
204 float stop_time = start_time + duration;
207 if (transport_prot.compare(
"TcpTahoe") == 0)
209 else if (transport_prot.compare(
"TcpReno") == 0)
211 else if (transport_prot.compare(
"TcpNewReno") == 0)
213 else if (transport_prot.compare(
"TcpWestwood") == 0)
218 else if (transport_prot.compare(
"TcpWestwoodPlus") == 0)
234 sources.
Create(num_flows);
257 address.
SetBase (
"10.0.0.0",
"255.255.255.0");
265 for (
int i=0; i<num_flows; i++)
268 devices = LocalLink.
Install(sources.
Get(i), gateways.
Get(0));
273 interfaces = address.
Assign (devices);
274 sink_interfaces.
Add(interfaces.
Get(1));
280 uint16_t
port = 50000;
284 for(uint16_t i=0; i<sources.
GetN(); i++)
288 if (transport_prot.compare(
"TcpTahoe") == 0
289 || transport_prot.compare(
"TcpReno") == 0
290 || transport_prot.compare(
"TcpNewReno") == 0
291 || transport_prot.compare(
"TcpWestwood") == 0
292 || transport_prot.compare(
"TcpWestwoodPlus") == 0)
301 sourceApp.
Start (Seconds (start_time*i));
302 sourceApp.
Stop (Seconds (stop_time - 3));
303 Time check_start (Seconds((start_time*i)+3));
307 sinkApp.
Start (Seconds (start_time*i));
308 sinkApp.
Stop (Seconds (stop_time));
312 NS_LOG_DEBUG (
"Invalid transport protocol " << transport_prot <<
" specified");
322 if (tr_file_name.compare(
"") == 0)
329 ascii.open (tr_file_name.c_str());