Difference between revisions of "Ns-3-Network-Simulator/C2/Connecting-multiple-networks-with-routers/English"
(Created page with " {| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide:1''' <div style="color:#000000;">'''Welcome'''</div> || <span style="color:#000000;">Welcome to the...") |
|||
Line 7: | Line 7: | ||
|| '''Narration''' | || '''Narration''' | ||
|- | |- | ||
− | || ''' | + | || ''' Show slide''' |
− | + | '''Welcome''' | |
− | || | + | || Welcome to the spoken tutorial on '''Connecting Multiple Networks with Router'''. |
− | |- | + | |- |
− | || Show | + | || Show slide: |
− | + | '''Learning Outcomes''' | |
|| In this tutorial, we will learn to | || In this tutorial, we will learn to | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |- | + | * Create a '''star''' topology with 4 nodes |
− | || Show slide: | + | * Create a '''CSMA''' bus topology with 4 nodes |
+ | * Configure client and server applications on the nodes | ||
+ | * Connect two networks | ||
+ | * Route packets from one network to the other | ||
+ | * Visualize the network using '''NetAnim''' | ||
+ | |||
+ | |- | ||
+ | || '''Show slide''': | ||
'''System Requirements''' | '''System Requirements''' | ||
|| To record this tutorial, I am using: | || To record this tutorial, I am using: | ||
− | |||
− | |||
− | |||
− | + | * '''Ubuntu Linux 22.04 OS''' | |
− | || Show slide: | + | * '''ns-3.38''' |
+ | * '''NetAnim '''visualizer tool | ||
+ | |||
+ | |- | ||
+ | || '''Show slide''': | ||
'''Prerequisite''' | '''Prerequisite''' | ||
− | + | [https://www.spoken-tutorial.org/ https://www.spoken-tutorial.org] | |
|| To follow this tutorial: | || To follow this tutorial: | ||
− | |||
− | |||
− | |||
− | + | * You must have basic knowledge of using Linux terminal | |
− | || Show slide: | + | * You must know how to create a '''point-to-point''' and '''CSMA''' network in '''ns-3''' |
+ | |||
+ | * For pre-requisite Linux and '''ns-3 ''' tutorials, please visit this website | ||
+ | |||
+ | |- | ||
+ | || '''Show slide''': | ||
'''Code files''' | '''Code files''' | ||
|| | || | ||
− | * | + | * The files used in this tutorial are provided in the '''Code files''' link. |
− | * | + | * Please download and extract the files. |
− | * | + | * Make a copy and then use them while practicing. |
− | |- | + | |- |
|| Show diagram: Network topology with a '''star '''and a '''CSMA '''network | || Show diagram: Network topology with a '''star '''and a '''CSMA '''network | ||
|| For this tutorial, we would be creating the following topology: | || For this tutorial, we would be creating the following topology: | ||
− | |||
− | |||
− | |||
− | + | * A '''star''' network topology with 4 nodes and network address 10.1.1.0 | |
+ | * A '''CSMA''' '''bus''' network topology with 4 nodes and 10.2.0.0 address | ||
+ | * A '''point-to-point''' network between the two networks, with address 10.3.0.0. | ||
+ | |||
+ | |- | ||
|| Open the file '''router.cc '''in the text editor. | || Open the file '''router.cc '''in the text editor. | ||
|| I have already created the source file '''router.cc''' for this program. | || I have already created the source file '''router.cc''' for this program. | ||
Line 68: | Line 73: | ||
The source code creates a star, and a CSMA network. | The source code creates a star, and a CSMA network. | ||
− | |- | + | |- |
− | || | + | || Highlight '''uint32_t nCsma = 3''' |
− | || First, | + | || First, we set the number of nodes in the '''CSMA''' network to 3. |
− | |- | + | |- |
− | || | + | || Highlight '''uint32_t nSpokes = 4''' |
− | || Then we set | + | || Then we set the number of nodes in the '''star''' network to 4. |
These variables can be named as per your program. | These variables can be named as per your program. | ||
− | |- | + | |- |
|| Highlight '''pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));''' | || Highlight '''pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));''' | ||
Line 83: | Line 88: | ||
The '''data rate '''for the point-to-point connections is set to 5 mbps. | The '''data rate '''for the point-to-point connections is set to 5 mbps. | ||
− | |- | + | |- |
|| Highlight '''pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));''' | || Highlight '''pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));''' | ||
'''uint16_t port = 50000;''' | '''uint16_t port = 50000;''' | ||
|| The channel '''delay''' is set to 2 milliseconds. | || The channel '''delay''' is set to 2 milliseconds. | ||
− | |- | + | |- |
|| Highlight '''uint16_t port = 50000;''' | || Highlight '''uint16_t port = 50000;''' | ||
|| The hub’s '''port''' is set to 50000. | || The hub’s '''port''' is set to 50000. | ||
− | |- | + | |- |
− | || | + | || Highlight '''PointToPointStarHelper star(nSpokes, pointToPoint)''' |
− | || | + | || Then we create a '''PointToPointStarHelper''' object to create a star network. |
The '''PointToPointStarHelper '''class is a helper class for initializing star networks. | The '''PointToPointStarHelper '''class is a helper class for initializing star networks. | ||
− | |- | + | |- |
|| Highlight '''star.InstallStack''' | || Highlight '''star.InstallStack''' | ||
− | || The '''InstallStack '''method installs an internet stack on the nodes. | + | || The '''InstallStack ''' method installs an internet stack on the nodes. |
− | |- | + | |- |
|| Highlight '''star.AssignIpv4Addresses''' | || Highlight '''star.AssignIpv4Addresses''' | ||
− | || The '''AssignIpv4Addresses '''method assigns IP addresses to the nodes. | + | || The '''AssignIpv4Addresses ''' method assigns IP addresses to the nodes. |
− | Here | + | Here we assign IP address 10.1.1.0 to the '''star''' network. |
− | |- | + | |- |
|| Highlight '''packetSinkHelper.Install''' | || Highlight '''packetSinkHelper.Install''' | ||
− | || '''PacketSinkHelper '''class is used to install a packet sink on the hub. | + | || '''PacketSinkHelper ''' class is used to install a packet sink on the hub. |
− | A '''packet sink '''enables the hub to receive packets from other nodes. | + | A '''packet sink ''' enables the hub to receive packets from other nodes. |
− | |- | + | |- |
|| Highlight '''hubApp.Start '''and '''hubApp.Stop''' | || Highlight '''hubApp.Start '''and '''hubApp.Stop''' | ||
− | || Here we | + | || Here we set the start and stop times for the hub. |
− | |- | + | |- |
|| Highlight '''NodeContainer p2pNodes''' | || Highlight '''NodeContainer p2pNodes''' | ||
− | || | + | || Then we create a node container for the '''point-to-point''' network. |
− | |- | + | |- |
|| Highlight '''p2pNodes.Add(star.GetSpokeNode(3))''' | || Highlight '''p2pNodes.Add(star.GetSpokeNode(3))''' | ||
|| Add the 4<sup>th</sup> node with index 3 to the node container. | || Add the 4<sup>th</sup> node with index 3 to the node container. | ||
− | |- | + | |- |
|| Highlight '''p2pNodes.Create(1)''' | || Highlight '''p2pNodes.Create(1)''' | ||
− | || Create one node using the '''Create '''method. | + | || Create one node using the '''Create ''' method. |
− | |- | + | |- |
|| Highlight '''NodeContainer csmaNodes''' | || Highlight '''NodeContainer csmaNodes''' | ||
− | || | + | || Similarly create a node container for the '''CSMA''' network. |
− | |- | + | |- |
|| Highlight '''csmaNodes.Add(p2pNodes.Get(1))''' | || Highlight '''csmaNodes.Add(p2pNodes.Get(1))''' | ||
|| Add the previously created node in the '''point-to-point''' network to the container. | || Add the previously created node in the '''point-to-point''' network to the container. | ||
− | |- | + | |- |
|| Highlight '''csmaNodes.Create(nCsma)''' | || Highlight '''csmaNodes.Create(nCsma)''' | ||
− | || Then create additional nodes using the '''Create '''method. | + | || Then create additional nodes using the '''Create ''' method. |
− | |- | + | |- |
|| Highlight '''pointToPoint.Install(p2pNodes)''' | || Highlight '''pointToPoint.Install(p2pNodes)''' | ||
− | || | + | || Next, install net devices on the '''point-to-point''' network nodes. |
− | |- | + | |- |
|| Highlight '''csma.SetChannelAttribute''' | || Highlight '''csma.SetChannelAttribute''' | ||
− | || Set the '''DataRate '''and '''Delay '''attributes for the channel. | + | || Set the '''DataRate ''' and '''Delay ''' attributes for the channel. |
− | |- | + | |- |
|| Highlight '''csma.Install(csmaNodes)''' | || Highlight '''csma.Install(csmaNodes)''' | ||
− | || | + | || Similarly install net devices on the '''CSMA''' network nodes. |
− | |- | + | |- |
|| Highlight '''stack.Install(csmaNodes)''' | || Highlight '''stack.Install(csmaNodes)''' | ||
− | || | + | || Then install an internet stack on the '''CSMA''' network nodes. |
− | |- | + | |- |
|| Highlight '''address.Assign(p2pDevices)''' | || Highlight '''address.Assign(p2pDevices)''' | ||
− | || | + | || Now we will assign the address 10.3.0.0 to the '''Point-to-Point''' network. |
− | |- | + | |- |
|| Highlight '''address.Assign(csmaDevices)''' | || Highlight '''address.Assign(csmaDevices)''' | ||
|| And assign the address 10.2.0.0 to the '''CSMA''' network. | || And assign the address 10.2.0.0 to the '''CSMA''' network. | ||
− | |- | + | |- |
|| Highlight '''echoServer.Install(csmaNodes.Get(2))''' | || Highlight '''echoServer.Install(csmaNodes.Get(2))''' | ||
− | || | + | || Next we install an echo server application on the third node of the '''CSMA''' network. |
− | |- | + | |- |
|| Only narration | || Only narration | ||
|| By zero indexing, its index is 2. | || By zero indexing, its index is 2. | ||
− | |- | + | |- |
|| Highlight '''serverApps.Start(Seconds(1.0))''' | || Highlight '''serverApps.Start(Seconds(1.0))''' | ||
− | || Now | + | || Now set the start of the server application to 1 second. |
− | |- | + | |- |
|| Highlight '''serverApps.Stop(Seconds(10.0))''' | || Highlight '''serverApps.Stop(Seconds(10.0))''' | ||
|| Next, set the stop time to 10 seconds after the start of the simulation. | || Next, set the stop time to 10 seconds after the start of the simulation. | ||
− | |- | + | |- |
|| Highlight '''echoClient(csmaInterfaces.GetAddress(2), 9);''' | || Highlight '''echoClient(csmaInterfaces.GetAddress(2), 9);''' | ||
− | || | + | || Similarly, we install an echo client application. |
− | |- | + | |- |
|| Only narration | || Only narration | ||
|| The target server is node 3 of the '''CSMA''' network. | || The target server is node 3 of the '''CSMA''' network. | ||
− | |- | + | |- |
|| Only narration | || Only narration | ||
|| The port is set to 9. | || The port is set to 9. | ||
− | |- | + | |- |
|| Highlight '''echoClient.Install(star.GetSpokeNode(1))''' | || Highlight '''echoClient.Install(star.GetSpokeNode(1))''' | ||
− | || Then we | + | || Then we Install the client application on node 2 of the '''star''' network. |
− | |- | + | |- |
− | || Highlight | + | || Highlight '''PopulateRoutingTables()''' |
|| The '''PopulateRoutingTables '''method of the '''Ipv4GlobalRoutingHelper '''class enables routing. | || The '''PopulateRoutingTables '''method of the '''Ipv4GlobalRoutingHelper '''class enables routing. | ||
− | + | |- | |
− | |- | + | || Highlight '''BoundingBox''' |
− | || | + | |
|| The '''BoundingBox''' method sets the positions for the nodes of the star network. | || The '''BoundingBox''' method sets the positions for the nodes of the star network. | ||
− | |- | + | |- |
− | || | + | || Highlight '''AnimationInterface anim ("router.xml")''' |
|| Next we specify the name for the '''XML''' output file. | || Next we specify the name for the '''XML''' output file. | ||
Here the name of the file is '''router.xml.''' | Here the name of the file is '''router.xml.''' | ||
− | |- | + | |- |
|| Highlight the lines: | || Highlight the lines: | ||
Line 198: | Line 202: | ||
|| Then we set the position of the nodes using the '''SetConstantPosition '''method. | || Then we set the position of the nodes using the '''SetConstantPosition '''method. | ||
− | |- | + | |- |
− | || Highlight | + | || Highlight '''Simulator::Run()''' |
− | || | + | || The '''Run''' function is used to run the simulation. |
− | |- | + | |- |
− | || | + | || Highlight '''Simulator::Destroy()''' |
− | || The '''Destroy | + | || The '''Destroy '''function ends the simulation. |
Now close the text editor. | Now close the text editor. | ||
− | |- | + | |- |
− | || | + | || Press Ctrl,Alt and T keys |
− | + | ||
− | Press Ctrl,Alt and T keys | + | |
Type '''cd ns-allinone-3.38/ns-3.38 '''to navigate to the ns3 installation directory | Type '''cd ns-allinone-3.38/ns-3.38 '''to navigate to the ns3 installation directory | ||
Line 215: | Line 217: | ||
Type '''mv ~/Downloads/router.cc scratch/router.cc '''to move the source file to '''scratch '''directory. | Type '''mv ~/Downloads/router.cc scratch/router.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. | + | Open the terminal by pressing Ctrl, Alt and T keys simultaneously. |
Using the '''cd '''command, navigate to the installation directory of '''ns-3'''. | Using the '''cd '''command, navigate to the installation directory of '''ns-3'''. | ||
Line 226: | Line 228: | ||
The '''ns3 '''batch file is configured to run files from the '''scratch '''directory. | The '''ns3 '''batch file is configured to run files from the '''scratch '''directory. | ||
− | |- | + | |- |
− | || | + | || Type ./'''ns3 run scratch/router.cc''' |
− | || | + | || Run the command '''dot forward slash ns3 space run space scratch forward slash router'''. |
'''router dot cc''' is the name of the source file. | '''router dot cc''' is the name of the source file. | ||
− | |- | + | |- |
− | | | + | || Keep the terminal open and show the output of the command |
− | || | + | || After compilation, we get the details of each packet transfer. |
− | |- | + | |- |
− | || | + | || Navigate to '''netanim-3.109 '''directory under '''ns-allinone-3.38''' |
− | || | + | || Now, to visualize the network, we will use '''NetAnim'''. |
Navigate to the '''netanim-3.109 '''directory under '''ns-allinone-3.38''' | Navigate to the '''netanim-3.109 '''directory under '''ns-allinone-3.38''' | ||
− | |- | + | |- |
− | || | + | || Type ./'''NetAnim''' |
− | || | + | || Now type '''dot slash NetAnim. ''' |
− | + | The '''NetAnim''' window will open. | |
− | |- | + | |- |
− | || | + | || Click on the Open''' XML trace file '''icon on the top left corner of the window. |
− | || | + | || Click on the Open''' XML trace file '''icon on the top left corner of the window. |
− | |- | + | |- |
− | || | + | || In the file picker, navigate to the '''ns-allinone-3.38/ns-3.38 '''directory and select the '''router.xml '''file. |
− | || | + | || In the file picker, navigate to the '''ns-allinone-3.38/ns-3.38 '''directory. |
Select the '''router dot xml '''file. | Select the '''router dot xml '''file. | ||
− | |- | + | |- |
− | || | + | || On the toolbar, click on the '''Node Size '''drop down button, select size 10. |
− | || | + | || On the toolbar, click on the '''Node Size '''drop down button. |
Select size 10. | Select size 10. | ||
− | |- | + | |- |
− | | | + | || On the toolbar, click on the play button |
− | || | + | || On the toolbar, click on the play animation button to view the simulation. |
We see here that the circles represent the nodes. | We see here that the circles represent the nodes. | ||
Line 268: | Line 270: | ||
We see that the hub is connected to all the nodes of the star network. | We see that the hub is connected to all the nodes of the star network. | ||
− | The directed | + | The directed line show the packet transfers between the networks. |
− | |- | + | |- |
− | || Show slide: | + | || '''Show slide''': |
− | ''' | + | '''Summary''' |
|| This brings us to the end of the tutorial. Let us summarize. | || This brings us to the end of the tutorial. Let us summarize. | ||
In this tutorial, we have learnt to | In this tutorial, we have learnt to | ||
− | * | + | * Create a '''star''' topology with 4 nodes |
− | * | + | * Create a '''CSMA''' bus topology with 4 nodes |
− | * | + | * Configure client and server applications on the nodes |
− | * | + | * Connect two networks |
− | * | + | * Route packets from one network to the other |
− | * | + | * Visualize the network using '''NetAnim''' |
− | |- | + | |- |
− | || Show | + | || '''Show slide''': |
− | + | '''Assignment''' | |
− | || As an assignment, please do the following:* | + | || As an assignment, please do the following:* Write an '''ns-3 '''program with two '''CSMA '''networks |
− | * | + | * Both networks should have 4 nodes |
− | * | + | * Assign '''IP address '''10.1.0.0 to first network |
− | * | + | * Assign '''IP address '''10.2.0.0 to second network |
− | * | + | * Route packets from node 2 of the first network to node 3 of the second network |
− | |- | + | |- |
− | || Show slide: | + | || '''Show slide''': |
Assignment - Observation | Assignment - Observation | ||
Line 300: | Line 302: | ||
Observe the transfer of packets between the networks. | Observe the transfer of packets between the networks. | ||
− | |- | + | |- |
− | || Show slide: | + | || '''Show slide''': |
Assignment - Observation | Assignment - Observation | ||
Line 307: | Line 309: | ||
On playing the animation, the arrows will show the direction of packet transfer. | On playing the animation, the arrows will show the direction of packet transfer. | ||
− | |- | + | |-''' |
− | || Show slide: | + | || Show slide''': |
'''About the Spoken Tutorial Project''' | '''About the Spoken Tutorial Project''' | ||
− | || | + | || The video at the following link summarizes the '''Spoken Tutorial project'''. |
− | + | ||
Please download and watch it. | Please download and watch it. | ||
− | |- | + | |- |
− | || Show Slide: | + | || '''Show Slide''': |
− | + | '''Spoken Tutorial Workshops''' | |
− | || | + | || The '''Spoken Tutorial Project''' team conducts workshops and gives certificates. |
For more details, please write to us. | 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 | + | || '''Show slide''' |
'''Acknowledgement''' | '''Acknowledgement''' | ||
− | || | + | || '''Spoken Tutorial''' Project was established by the '''Ministry of Education, Government of India'''. |
− | + | ||
− | |- | + | |- |
− | || Show slide | + | || '''Show slide''' |
'''Acknowledgement''' | '''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: | + | || '''Show slide''': |
'''Thank You''' | '''Thank You''' | ||
− | || | + | || This is '''Josiga, '''a FOSSEE summer fellow 2023, IIT Bombay signing off. |
− | + | Thanks for joining. | |
|- | |- | ||
|} | |} |
Latest revision as of 18:04, 13 March 2024
Visual Cue | Narration |
Show slide
Welcome |
Welcome to the spoken tutorial on Connecting Multiple Networks with Router. |
Show slide:
Learning Outcomes |
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 a star and a CSMA network | For this tutorial, we would be creating the following topology:
|
Open the file router.cc in the text editor. | I have already created the source file router.cc for this program.
Now we will go through the source code in the text editor. It contains the required functions to implement routing. The source code creates a star, and a CSMA network. |
Highlight uint32_t nCsma = 3 | First, we set the number of nodes in the CSMA network to 3. |
Highlight uint32_t nSpokes = 4 | Then we set the number of nodes in the star network to 4.
These variables can be named as per your program. |
Highlight pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps")); | We will set the following parameters for the star network.
The data rate for the point-to-point connections is set to 5 mbps. |
Highlight pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
uint16_t port = 50000; |
The channel delay is set to 2 milliseconds. |
Highlight uint16_t port = 50000; | The hub’s port is set to 50000. |
Highlight PointToPointStarHelper star(nSpokes, pointToPoint) | Then we create a PointToPointStarHelper object to create a star network.
The PointToPointStarHelper class is a helper class for initializing star networks. |
Highlight star.InstallStack | The InstallStack method installs an internet stack on the nodes. |
Highlight star.AssignIpv4Addresses | The AssignIpv4Addresses method assigns IP addresses to the nodes.
Here we assign IP address 10.1.1.0 to the star network. |
Highlight packetSinkHelper.Install | PacketSinkHelper class is used to install a packet sink on the hub.
A packet sink enables the hub to receive packets from other nodes. |
Highlight hubApp.Start and hubApp.Stop | Here we set the start and stop times for the hub. |
Highlight NodeContainer p2pNodes | Then we create a node container for the point-to-point network. |
Highlight p2pNodes.Add(star.GetSpokeNode(3)) | Add the 4th node with index 3 to the node container. |
Highlight p2pNodes.Create(1) | Create one node using the Create method. |
Highlight NodeContainer csmaNodes | Similarly create a node container for the CSMA network. |
Highlight csmaNodes.Add(p2pNodes.Get(1)) | Add the previously created node in the point-to-point network to the container. |
Highlight csmaNodes.Create(nCsma) | Then create additional nodes using the Create method. |
Highlight pointToPoint.Install(p2pNodes) | Next, install net devices on the point-to-point network nodes. |
Highlight csma.SetChannelAttribute | Set the DataRate and Delay attributes for the channel. |
Highlight csma.Install(csmaNodes) | Similarly install net devices on the CSMA network nodes. |
Highlight stack.Install(csmaNodes) | Then install an internet stack on the CSMA network nodes. |
Highlight address.Assign(p2pDevices) | Now we will assign the address 10.3.0.0 to the Point-to-Point network. |
Highlight address.Assign(csmaDevices) | And assign the address 10.2.0.0 to the CSMA network. |
Highlight echoServer.Install(csmaNodes.Get(2)) | Next we install an echo server application on the third node of the CSMA network. |
Only narration | By zero indexing, its index is 2. |
Highlight serverApps.Start(Seconds(1.0)) | Now set the start of the server application to 1 second. |
Highlight serverApps.Stop(Seconds(10.0)) | Next, set the stop time to 10 seconds after the start of the simulation. |
Highlight echoClient(csmaInterfaces.GetAddress(2), 9); | Similarly, we install an echo client application. |
Only narration | The target server is node 3 of the CSMA network. |
Only narration | The port is set to 9. |
Highlight echoClient.Install(star.GetSpokeNode(1)) | Then we Install the client application on node 2 of the star network. |
Highlight PopulateRoutingTables() | The PopulateRoutingTables method of the Ipv4GlobalRoutingHelper class enables routing. |
Highlight BoundingBox | The BoundingBox method sets the positions for the nodes of the star network. |
Highlight AnimationInterface anim ("router.xml") | Next we specify the name for the XML output file.
Here the name of the file is router.xml. |
Highlight the lines:
anim.SetConstantPosition(p2pNodes.Get(1),400,200); anim.SetConstantPosition(csmaNodes.Get(1),600,150); anim.SetConstantPosition(csmaNodes.Get(2),700,150); anim.SetConstantPosition(csmaNodes.Get(3),700,150); |
Then we set the position of the nodes using the SetConstantPosition method. |
Highlight Simulator::Run() | The Run function is used to run the simulation. |
Highlight Simulator::Destroy() | The Destroy function ends the simulation.
Now close the text editor. |
Press Ctrl,Alt and T keys
Type cd ns-allinone-3.38/ns-3.38 to navigate to the ns3 installation directory Type mv ~/Downloads/router.cc scratch/router.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. The ns3 batch file is configured to run files from the scratch directory. |
Type ./ns3 run scratch/router.cc | Run the command dot forward slash ns3 space run space scratch forward slash router.
router dot cc is the name of the source file. |
Keep the terminal open and show the output of the command | After compilation, we get the details of each packet transfer. |
Navigate to netanim-3.109 directory under ns-allinone-3.38 | Now, to visualize the network, we will use NetAnim.
Navigate to the netanim-3.109 directory under ns-allinone-3.38 |
Type ./NetAnim | Now type dot slash NetAnim.
The NetAnim window will open. |
Click on the Open XML trace file icon on the top left corner of the window. | Click on the Open XML trace file icon on the top left corner of the window. |
In the file picker, navigate to the ns-allinone-3.38/ns-3.38 directory and select the router.xml file. | In the file picker, navigate to the ns-allinone-3.38/ns-3.38 directory.
Select the router dot xml file. |
On the toolbar, click on the Node Size drop down button, select size 10. | On the toolbar, click on the Node Size drop down button.
Select size 10. |
On the toolbar, click on the play button | On the toolbar, click on the play animation button to view the simulation.
We see here that the circles represent the nodes. The lines represent the connection between the nodes. We see that the hub is connected to all the nodes of the star network. The directed line show the packet transfers between the networks. |
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:* Write an ns-3 program with two CSMA networks
|
Show slide:
Assignment - Observation |
In the terminal, you will get this output.
Observe the transfer of packets between the networks. |
Show slide:
Assignment - Observation |
In the window, you can observe two CSMA networks.
On playing the animation, the arrows will show the direction of packet transfer. |
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 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 Josiga, a FOSSEE summer fellow 2023, IIT Bombay signing off.
|