Skip to content

Evaluation of TCP Variants on Wired Network

 

 About this Example:

This TCP simulation is base on the example code which is available with ns3.  You may refer to the original example file for more details.
In this simple wired TCP example, nodes 1 and 2 will establish an FTP connection with nodes 3 and 4 via the gateway node 0.
 
 
 

Important Sections of the Simulation Script

At the top of the simulation file, the necessary header files are included and some global variables are declared.  In addition to that, some callback functions are declared.  In this example, the two callback functions are used to log the cwnd and rtt dynamics of node 1 which is one of the TCP traffic sources.
 
#include
….. ……. …….
using namespace ns3;
bool firstCwnd = true;
bool firstRtt = true;
Ptr cWndStream;
Ptr rttStream; uint32_t cWndValue;
……. …….
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));
}
……. …….
In the main() section of the code, the nodes are created and loaded with an internet stack and the FTP connection is established between the source and destination nodes. The call back function is scheduled so that cwnd and rtt dynamics will be logged periodically.
 
 
int main (int argc, char *argv[]) {
……. …….
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).

 

WhatsApp Discuss Through WhatsApp