About this Example:
Important Sections of the Simulation Script
….. ……. …….
using namespace ns3;
bool firstCwnd = true;
bool firstRtt = true;
Ptr
Ptr
……. …….
static void TraceCwnd (std::string cwnd_tr_file_name) {
AsciiTraceHelper ascii;
cWndStream = ascii.CreateFileStream (cwnd_tr_file_name.c_str ());
Config::ConnectWithoutContext (“/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow”, MakeCallback (&CwndTracer));
}
static void TraceRtt (std::string rtt_tr_file_name) {
AsciiTraceHelper ascii; rttStream = ascii.CreateFileStream (rtt_tr_file_name.c_str ());
Config::ConnectWithoutContext (“/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/RTT”, MakeCallback (&RttTracer));
}
……. …….
……. …….
Config::SetDefault (“ns3::TcpL4Protocol::SocketType”, TypeIdValue (TcpNewReno::GetTypeId ()));
……. …….
// Create gateways, sources, and sinks NodeContainer gateways; gateways.Create (1);
NodeContainer sources; sources.Create (num_flows);
NodeContainer sinks; sinks.Create (num_flows);
……. …….
InternetStackHelper stack; stack.InstallAll ();
……. …….
for (uint16_t i = 0; i < sources.GetN (); i++) {
AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress (i, 0), port));
Config::SetDefault (“ns3::TcpSocket::SegmentSize”, UintegerValue (tcp_adu_size));
BulkSendHelper ftp (“ns3::TcpSocketFactory”, Address ());
ftp.SetAttribute (“Remote”, remoteAddress);
ftp.SetAttribute (“SendSize”, UintegerValue (tcp_adu_size));
ftp.SetAttribute (“MaxBytes”, UintegerValue (int(data_mbytes * 1000000)));
ApplicationContainer sourceApp = ftp.Install (sources.Get (i));
sourceApp.Start (Seconds (start_time * i));
sourceApp.Stop (Seconds (stop_time – 3));
sinkApp.Start (Seconds (start_time * i));
sinkApp.Stop (Seconds (stop_time)); }
……. …….
Simulator::Schedule (Seconds (0.00001), &TraceCwnd, prefix_file_name + “-cwnd.data”);
Simulator::Schedule (Seconds (0.00001), &TraceRtt, prefix_file_name + “-rtt.data”);
……. …….
Simulator::Stop (Seconds (stop_time));
Simulator::Run ();
……. …….
Simulator::Destroy (); return 0;
}
The Example topology Visualized with NetAnim
Comparison of cwnd Dynamics of TcpWestwood and TcpNewReno
The following xgraph plot shows the cwnd dynamics of TcpWestwood and TcpNewReno
Comparison of rtt Dynamics of TCP Westwood and TcpNewReno
The following xgraph plot shows the rtt dynamics of TCP Westwood and TcpNewReno
Conclusion
The cwnd and rtt dynamics on a wired without much congestion is somewhat ideal. So that we are getting almost saw-tooth like graphs that we generally see on textbooks. But if we use the same TCP variants under wireless networks then we can not expect this kind of graph with uniform fluctuation. In our future article, we will experiment with TCP on a Wireless Mobile Adhoc Network(MANET).