Difference between revisions of "Ns-3-Network-Simulator/C3/Analyzing-TCP-Congestion-window/English"
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide:1''''' '''Welcome''' || Welcome to the spoken tutorial on''' Analyzing''' '''TCP Congestion''' '''Window...") |
(No difference)
|
Revision as of 14:56, 17 April 2024
Visual Cue | Narration |
Slide:1
Welcome |
Welcome to the spoken tutorial on Analyzing TCP Congestion Window. |
Show slide:
Outline |
In this tutorial, we will learn to
|
Show slide:
System Requirements |
To record this tutorial, I am using
|
Show slide:
Prerequisite |
To follow this tutorial:
|
Show slide:
Code files |
|
Show diagram:
Network topology with two nodes |
The network topology consists of two nodes.
They are connected using a point-to-point link.
|
Show slide:
Classes and Methods |
Let’s have a look at the classes and methods.
These would be needed to apply TCP New Reno congestion control.
|
Show slide:
Tutorial App |
We shall be using a pre-coded application file, tutorial-app.cc.
in this tutorial. The application instance sends packets to the server node continuously. |
Show slide:
Trace sources |
This program uses the CongestionWindow trace source.
It tracks the changes in the congestion window size. Now we will go through the steps required to use the TutorialApp class in our program. |
Open a terminal by pressing Ctrl, Alt and T keys simultaneously. | Open a terminal by pressing Ctrl, Alt and T keys simultaneously. |
Type cd ns-allinone-3.38/ns-3.38 | Type cd ns-allinone-3.38 forward slash ns-3.38 as shown. |
Type cp examples/tutorial/tutorial-app.cc src/applications/model | Now we will copy the required files.
These folders and files are created by default when ns-3 is installed. First we copy the file tutorial-app.cc. Let us copy the file tutorial-app.cc which is available under examples/tutorial folder. |
Only narration | The destination is the model directory under the src/applications directory.
The src directory stores the header files and the associated source files. These files can be imported in our program. |
Type cp examples/tutorial/tutorial-app.h src/applications/model | Now we copy the file tutorial-app.h.
It is a header file. It contains the required definitions for the TutorialApp class. |
Only narration | Once the files are copied, we need to edit the CMakeLists.txt file.
The CMakeLists.txt file lists the files that will be compiled during the build process. We need to add the files we copied to the CMakeLists.txt file. |
Type gedit src/applications/CMakeLists.txt | Using your favorite text editor, edit the CMakeLists.txt file.
It is present under the applications directory, which is under the src directory. We are using the gedit text editor. |
Under the SOURCE_FILES header, add the line: model/tutorial-app.cc after the last entry (usually model/udp-trace-client.cc) | In the text editor, find the SOURCE_FILES header.
After the last line under the header, add the line model/tutorial-app.cc. |
Under the HEADER_FILES header, add the line: model/tutorial-app.h after the last entry (usually model/tutorial-app.h) | Now find the HEADER_FILES header.
After the last line under the header, add the line model/tutorial-app.h. |
Save the file and close the text editor. | Save the file and close the text editor. |
Switch to the terminal window.
Type ./ns3 configure |
In the terminal, type ./ns3 configure.
This command scans for any changes in the build files. |
Type ./ns3 build | Now type ./ns3 build to start the build process.
This command scans the CMakeLists.txt file for new changes and builds the ns-3 program again. Pause the video here and wait for the build process to finish. It could take several minutes. Now the tutorial-app.h header file is ready to be used in our program. |
Open the file tcp-congestion.cc in the text editor | Now we will take a look at the code for the program.
I have created the source file tcp-congestion.cc for this program. The source code contains the required functions to implement a point-to-point network. Download this file from the Code files section and open it in a text editor. |
Highlight #include “ns3/tutorial-app.h” | We have used this header file which we built earlier.. |
Highlight CwndChange | The CwndChange function is a callback function.
It acts as a trace sink for the CongestionWindow trace source. The function prints the old and new sizes of the congestion window. |
Highlight GetStream | It also writes these values to the output file using the GetStream function. |
Only narration | For demonstration, we will be creating a point-to-point network. |
Highlight csmaNodes.Create(2) | The network consists of 2 nodes. |
Highlight DataRate and then Delay | We set the data rate to 5 Mbps and the delay to 2 milliseconds. |
Highlight Ptr<RateErrorModel> | Next, we create a pointer to an object of the RateErrorModel class. |
Highlight em->SetAttribute | Then set the error rate to 0.00001. |
Highlight devices.Get(1)->SetAttribute("ReceiveErrorModel", PointerValue(em)); | For this program, node 2, with index 1 is the receiver node.
On the receiver node, set the ReceiveErrorModel attribute. The value of the attribute is the pointer we created earlier. |
Highlight SetBase | The IP address of the network is set to 10.1.1.0 with subnet mask 255.255.255.0. |
Highlight packetSinkHelper.Install | To receive packets, we create a packet sink on the receiver node.
We shall have the first node, with index 0 as the sender node. It will then send the packets to the receiver node, node 2. |
Highlight Socket::CreateSocket | Create a socket on node 1 using the CreateSocket method. |
Highlight Config::Set | Then set the socket type using the set method. |
Highlight Ptr<TutorialApp> app | Now let’s create an instance of the TutorialApp class. |
Highlight Setup(ns3TcpSocket, sinkAddress, 1040, 1000, DataRate("1Mbps")) | The app uses the socket we created earlier. |
Highlight nodes.Get(0)->AddApplication(app); | Further, let’s add the application to the first node of the CSMA network. |
Highlight app->SetStartTime(Seconds(1.)) | Then we will set the start and stop times for the application. |
Highlight AsciiTraceHelper | The AsciiTraceHelper object creates an output file stream. |
Highlight TraceConnectWithoutContext | Then we connect the stream to the CongestionWindow trace source. |
Highlight GnuplotHelper plotHelper | Next, we create an object of the GnuplotHelper class. |
Highlight plotHelper.ConfigurePlot | Configure the parameters for the plot.
The first argument is the file name prefix. The second argument is the plot title. Here it is TCP Window Size vs Time’. The third and fourth arguments are the x-axis and y-axis labels respectively. |
Highlight plotHelper.PlotProbe | Using the PlotProbe method, we set attributes for the probe.
These include:
The probeName and probeTrace values were set previously. The FileHelper class object writes packet byte count over time. |
Highlight Simulator::Run() | Finally we use the Run and Destroy for running and stopping the simulation. |
Open terminal and navigate to the ns-3.38 directory | Let’s run the simulation for the program.
Navigate to the ns-3.38 directory. |
Type ./ns3 run scratch/tcp-congestion.cc | Run the source script using the run command.
Here the name of the source file is tcp-congestion.cc. The output shows the time at which the change occurs in the size of the window. Also available in the output are the old and new window sizes. Now we shall observe the plot of the congestion window change. On running the simulation, a file with cwnd extension is created. |
Open ns-3.38 directory and highlight the tcp-congestion.cwnd file | You can find the file in the ns-3.38 directory.
The name of the file is the one specified in the CreateFileStream function. Here the name of the file is tcp-congestion.cwnd. The cwnd file is used to provide the values for the plot. |
Open the congestion.plt file | Using the commands displayed, we configure the plot.
Let us first download the congestion.plt file from the code files section. Make sure that the file is in the same directory. The commands in this file will configure the plot. |
Show terminal | Make sure the file is in the same directory as the cwnd file. |
Type sudo apt install gnuplot | To generate the plot, we use the gnuplot command.
To install it, type sudo apt install gnuplot in the terminal. If it is already installed, proceed to the next command. |
Type gnuplot congestion.plt | Next, we generate the plot using the command gnuplot congestion.plt. |
Switch to the file manager window.
Show the congestion.png file |
An image file is generated in the same directory with the plot. |
Open congestion.png file | The plot shows the change in the size of the congestion window over time. |
Show slide:
Summary |
This brings us to the end of the tutorial. Let us summarize.
In this tutorial, we have learnt to
|
Show slide: Assignment | As an assignment, please do the following
|
Show slide:
Assignment - Observation |
In the terminal, observe the change in congestion window size over time. |
Show slide:
Assignment - Observation |
The image generated by gnuplot depicts the change in congestion window size. |
Show slide:
About the Spoken Tutorial Project |
The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it.
|
Show Slide:
Spoken Tutorial Workshops |
The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us.
|
Show Slide:
Answers for THIS Spoken Tutorial
|
Please post your timed queries in this forum. |
Show Slide:
FOSSEE Forum
|
For any general or technical questions on ns-3, visit the FOSSEE forum and post your question. |
Show slide:
Acknowledgement |
Spoken Tutorial Project is funded by the Ministry of Education, Government of India. |
Show slide:
Acknowledgement |
We thank Dr.Moyukh Laha from IIT Kharagpur for his domain support.
We would also like to thank Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi from VIT, Chennai for their support. |
Show slide:
Thank You |
This is Karthik Chandrasekhar, a FOSSEE summer fellow 2023, IIT Bombay signing off.
Thanks for joining.
|