Ns-3-Network-Simulator/C3/Creating-TCP/UDP-flow-with-Star-Topology/English
Visual Cue | Narration |
Slide:1 | Welcome to Spoken tutorial on creating TCP/UDP flow with star topology. |
Show Slide:
Learning Objectives |
In this tutorial, we will learn to
|
Show Slide:
System Requirements |
To record this tutorial, I am using
|
Show slide:
Pre-requisites |
To follow this tutorial
|
Show Slide:
Code Files |
|
Show slide:
Star topology |
For this tutorial, we would be creating the following topology.
A star topology network with five point to point links. The hub will be a part of all the links and hence, will have five IP addresses. |
Show Slide:
Classes and Methods |
Let’s look at the classes and methods used to create TCP and UDP flows.
|
Open code editor | I have created the source file flow2final.cc for this program.
The source code contains the required functions to create,
Now we will go through the source file for the program. |
Highlight Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (137)); | To build star topology let us set up default values for the size of the packets. |
Highlight Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("1400 kb/s")); | We shall also set the value for data rate to be 1400 kbps as the default value. |
Only narration | Let us build a star topology with p2p connections.
For that we shall use the PointToPointHelper class. |
Highlight InternetStackHelper internet;
star.InstallStack (internet); |
Then let us install the internet stack on all the nodes. |
Highlight PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); | Next, we shall create a packet sink to receive the packets on the hub. |
Highlight ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); | Then let us create a container to receive the packets on the hub. |
Only narration | Further, we create an on-off application to send TCP/UDP traffic to the hub. |
Highlight OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); | The address of the hub is fetched for sending the TCP traffic to it. |
Highlight OnTime and then OffTime | Now, we set the ontime to 1 and offtime to 0.
Next, we fetch the port of the hub from the spoke node. Also let us set the attribute type to Remote. Then install the OnOffHelper on the spoke node. |
Highlight OnOffHelper clientHelper("ns3::UdpSocketFactory", Address()); | The address of the hub is fetched for receiving the UDP traffic from node 2. |
Only Narration | We then follow the same procedure as we did for TCP.
Now pause the tutorial and repeat the same procedure for UDP. |
Highlight Ptr<FlowMonitor> flowMonitor; | Then, Initialize flow monitor for tracing. |
HIghlight FlowMonitorHelper flowHelper;
flowMonitor= flowHelper.InstallAll(); |
We shall then install a flow monitor on all the spoke nodes. |
Highlight Simulator::Run() | Now, the Run() function is used to run the simulation. |
HIghlight Ptr<Ipv4FlowClassifier> classifier=DynamicCast<Ipv4FlowClassifier> (flowHelper.GetClassifier()); | Let us now create an object of the Ipv4FlowClassifier class.
The created object returns a pointer to the flow classifier. |
Highlight std::map<FlowId,FlowMonitor::FlowStats> stats=flowMonitor->GetFlowStats(); | To store the information about the network flow, let us use this command. |
Highlight the entire for loop.
Highlight iter->first Highlight iter->second |
Let’s retrieve the details of the flow using a for loop.
iter arrow first is used to collect the ID of the flow. iter arrow second is used to collect the data associated with the flow. We will analyze the type of flow and print the delay and throughput. |
Highlight Simulator::Destroy() | The Destroy() function ends the simulation. |
Press Ctrl, Alt and T keys
Navigate to the ns-allinone-3.38/ns3.38 directory Type mv ~/Downloads/flow2final.cc scratch/flow2final.cc to move the source file to scratch directory. |
Now we will observe the simulation.
Open the terminal by pressing Ctrl, Alt and T keys simultaneously. Using the cd command, navigate to the installation directory of ns-3. Go to the ns-3.38 directory. Move your source file to the scratch directory within the ns-3.38 directory. |
Type ./ns3 run scratch/flow2final.cc
Highlight throughput and delay |
Run the command ./ns3 space run space scratch/flow2final.cc command.
flow2final.cc is the name of the source file. After compilation, we see the details of TCP and UDP flows. We also see the throughput and delay of the flow. |
Show Slide: Summary | This brings us to the end of this tutorial.
Let us summarize. In this tutorial, we have
|
Show Slide: Assignment | As an assignment, please do the following:
|
Show Slide:
Assignment- Observations |
In the terminal, you will observe this output with TCP flow. |
Show Slide:
About 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 was established 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 Arun Santhosh, a FOSSEE Summer Fellow 2023, IIT Bombay signing off.
Thank you for joining. |