Difference between revisions of "Ns-3-Network-Simulator/C3/Dynamic-Routing-Protocol/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || '''Slide:1''' || Welcome to the spoken tutorial on '''Dynamic routing protocols in ns-3'''. |- style="border:1pt...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
|| '''Slide:1'''
 
|| '''Slide:1'''
 
|| Welcome to the spoken tutorial on '''Dynamic routing protocols in ns-3'''.
 
|| Welcome to the spoken tutorial on '''Dynamic routing protocols in ns-3'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 
|| In this tutorial, we will learn to
 
|| In this tutorial, we will learn to
* <div style="margin-left:1.27cm;margin-right:0cm;">Create a multi-path topology</div>
+
* Create a multi-path topology
* <div style="margin-left:1.27cm;margin-right:0cm;">Schedule down times for links</div>
+
* Schedule down times for links
* <div style="margin-left:1.27cm;margin-right:0cm;">Implement OSPF dynamic routing</div>
+
* Implement '''OSPF''' dynamic routing
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''System Requirements'''
 
'''System Requirements'''
 
|| To record this tutorial, I am using:
 
|| To record this tutorial, I am using:
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu Linux 22.04 OS'''</div>
+
* '''Ubuntu Linux operating system version 22.04 '''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''ns-3'''.'''38'''</div>
+
* '''ns-3.38'''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''NetAnim '''visualizer tool</div>
+
* '''NetAnim ''' visualizer tool
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Prerequisite'''
 
'''Prerequisite'''
  
<div style="color:#3c78d8;">'''https://spoken-tutorial.org/'''</div>
+
'''https://spoken-tutorial.org/'''
 
|| To follow this tutorial
 
|| To follow this tutorial
* <div style="margin-left:1.27cm;margin-right:0cm;">You must have basic knowledge of '''Linux '''and '''ns-3'''</div>
+
* You must have basic knowledge of '''Linux ''' and '''ns-3'''
* <div style="margin-left:1.27cm;margin-right:0cm;">For pre-requisite '''Linux '''and '''ns-3''' tutorials, please visit this website</div>
+
* For pre-requisite '''Linux '''and '''ns-3''' tutorials, please visit this website
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Code files'''
 
'''Code files'''
 
||  
 
||  
* <div style="margin-left:1.27cm;margin-right:0cm;">The files used in this tutorial are provided in the '''Code files''' link</div>
+
* The files used in this tutorial are provided in the '''Code files''' link
* <div style="margin-left:1.27cm;margin-right:0cm;">Please download and extract the files</div>
+
* Please download and extract the files
* <div style="margin-left:1.27cm;margin-right:0cm;">Make a copy and then use them while practicing</div>
+
* Make a copy and then use them while practicing
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''What is OSPF Routing?'''
 
'''What is OSPF Routing?'''
 
||  
 
||  
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Open Shortest Path First (OSPF) '''is a link state routing protocol</div>
+
* '''Open Shortest Path First (OSPF) ''' is a link state routing protocol
* <div style="margin-left:1.27cm;margin-right:0cm;">It determines the shortest path between the source and the destination</div>
+
* It determines the shortest path between the source and the destination
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show diagram:
 
|| Show diagram:
  
 
'''Network topology with 6 nodes and four paths'''
 
'''Network topology with 6 nodes and four paths'''
 
|| For this tutorial, we would be creating the following topology:
 
|| For this tutorial, we would be creating the following topology:
* <div style="margin-left:1.27cm;margin-right:0cm;">The topology consists of 6 nodes</div>
+
* The topology consists of 6 nodes
* <div style="margin-left:1.27cm;margin-right:0cm;">Node 0 is the client node</div>
+
* Node 0 is the client node
* <div style="margin-left:1.27cm;margin-right:0cm;">Node 5 is the server node</div>
+
* Node 5 is the server node
* <div style="margin-left:1.27cm;margin-right:0cm;">There are four paths from client to server</div>
+
* There are four paths from client to server
* <div style="margin-left:1.27cm;margin-right:0cm;">Each link is '''point-to-point '''connection </div>
+
* Each link is '''point-to-point '''connection  
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Open the file '''DynamicRouting.cc '''in text editor
 
|| Open the file '''DynamicRouting.cc '''in text editor
 
|| I have created the source file '''DynamicRoutingprotocols.cc''' for this program.
 
|| I have created the source file '''DynamicRoutingprotocols.cc''' for this program.
Line 68: Line 68:
 
Now we will go through the source code in the text editor.
 
Now we will go through the source code in the text editor.
  
The source code contains the required functions to implement '''OSPF dynamic routing.'''
+
The source code contains the required functions to implement '''OSPF dynamic routing'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Config::SetDefault("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue(true))'''
 
|| Highlight '''Config::SetDefault("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue(true))'''
|| Using the '''SetDefault '''method, we first enable dynamic routing.
+
|| Using the '''SetDefault ''' method, we first enable dynamic routing.
  
'''RespondToInterfaceEvents '''enables the '''ns-3''' program to automatically change routes.
+
'''RespondToInterfaceEvents ''' enables the '''ns-3''' program to automatically change routes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight  
 
|| Highlight  
  
Line 82: Line 82:
  
 
|| The node container contains 6 nodes.
 
|| The node container contains 6 nodes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight''' stack.Install(p2pNodes);'''
 
|| Highlight''' stack.Install(p2pNodes);'''
 
 
|| Let’s install an internet stack on the nodes.
 
|| Let’s install an internet stack on the nodes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''NodeContainer n01, n02, n23, n14, n15, n45;'''
 
|| Highlight '''NodeContainer n01, n02, n23, n14, n15, n45;'''
 
|| Next we create 6 more node containers.  
 
|| Next we create 6 more node containers.  
Line 92: Line 91:
 
These containers are for the individual '''point-to-point''' networks.
 
These containers are for the individual '''point-to-point''' networks.
  
The node containers are''' n01''', '''n02''', '''n23''',''' n34''', '''n14''',''' n15''' and '''n45'''.
+
The node containers are ''' n01''', '''n02''', '''n23''',''' n34''', '''n14''',''' n15''' and '''n45'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Address.SetBase'''
 
|| Highlight '''Address.SetBase'''
|| Then we assign base addresses to the '''point-to-point '''networks.
+
|| Then we assign base addresses to the '''point-to-point ''' networks.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
|| Highlight <span style="color:#24292e;">'''10.1.1.0'''</span>
+
|| Highlight '''10.1.1.0'''
 
|| The address of the network between node 0 and node 1 is 10.1.1.0.
 
|| The address of the network between node 0 and node 1 is 10.1.1.0.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''10.1.2.0'''
 
|| Highlight '''10.1.2.0'''
 
|| The address of the network between node 0 and node 2 is 10.1.2.0.
 
|| The address of the network between node 0 and node 2 is 10.1.2.0.
  
Similarly, the addresses for other networks are set.
+
Similarly, the addresses of the other networks are set.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''pointToPoint.Install(n01)'''
 
|| Highlight '''pointToPoint.Install(n01)'''
 
|| The '''Install''' method installs point-to-point channels on the nodes.
 
|| The '''Install''' method installs point-to-point channels on the nodes.
  
 
The nodes are node 0 and node 1 here.
 
The nodes are node 0 and node 1 here.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight''' NetDeviceContainer nd01'''
 
|| Highlight''' NetDeviceContainer nd01'''
|| The '''Install '''method returns an object of '''NetDeviceContainer''' class.
+
|| The '''Install ''' method returns an object of '''NetDeviceContainer''' class.
  
We store it in object nd01.
+
We store it in object '''nd01'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight''' Address.Assign(nd01)'''
 
|| Highlight''' Address.Assign(nd01)'''
|| The '''Assign '''method assigns '''IP addresses''' to the nodes.
+
|| The '''Assign '''method assigns ''' IP addresses''' to the nodes.
  
The''' IP addresses''' are based on the network address..
+
The ''' IP addresses''' are based on the network address.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Ipv4InterfaceContainer i01'''
 
|| Highlight '''Ipv4InterfaceContainer i01'''
|| The '''Assign '''method returns an '''Ipv4InterfaceContainer''' object.
+
|| The '''Assign ''' method returns an '''Ipv4InterfaceContainer''' object.
  
We store it in object i01.
+
We store it in object '''i01'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''uint16_t port = 9'''
 
|| Highlight '''uint16_t port = 9'''
 
|| Next, we set the port number to 9.
 
|| Next, we set the port number to 9.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''OnOffHelper onoff'''
 
|| Highlight '''OnOffHelper onoff'''
 
|| Then we create '''OnOff applications '''to send packets.
 
|| Then we create '''OnOff applications '''to send packets.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''InetSocketAddress(i45.GetAddress(1), port)'''
 
|| Highlight '''InetSocketAddress(i45.GetAddress(1), port)'''
 
|| Here we create a '''UDP socket''' on the remote destination node.
 
|| Here we create a '''UDP socket''' on the remote destination node.
Line 136: Line 135:
 
The socket is created on port 9 of node 5.
 
The socket is created on port 9 of node 5.
  
We get the '''IP address''' of node 5 using the i45 object.
+
We get the '''IP address''' of node 5 using the '''i45''' object.
  
The '''GetAddress '''method is used to get the address of the node with index 1.
+
The '''GetAddress ''' method is used to get the address of the node with index 1.
  
Please note that the indexing is within the i45 interface.
+
Please note that the indexing is within '''i45''' interface.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''onoff.SetConstantRate(DataRate("2kbps"))'''
 
|| Highlight '''onoff.SetConstantRate(DataRate("2kbps"))'''
 
|| Then, we set the properties for the application.
 
|| Then, we set the properties for the application.
  
The '''data rate '''is set to 2kbps.
+
The '''data rate ''' is set to 2kbps.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''onoff.SetAttribute'''
 
|| Highlight '''onoff.SetAttribute'''
 
|| The '''packet size''' is set to 50 bytes.
 
|| The '''packet size''' is set to 50 bytes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''ApplicationContainer apps = onoff.Install(p2pNodes.Get(0))'''
 
|| Highlight '''ApplicationContainer apps = onoff.Install(p2pNodes.Get(0))'''
 
|| Create an application container.
 
|| Create an application container.
  
Then, install the '''OnOff application '''on node 0.
+
Then, install the '''OnOff application ''' on node 0.
  
 
Here the indexing is in the overall network.
 
Here the indexing is in the overall network.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''apps.Start(Seconds(1.0))'''
 
|| Highlight '''apps.Start(Seconds(1.0))'''
|| Set the start time for the apps to 1 second from the start of simulation.
+
|| Set the start time for the apps to 1 second from the start of the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''apps.Stop(Seconds(16.0))'''
 
|| Highlight '''apps.Stop(Seconds(16.0))'''
|| Similarly set the stop time to 16 seconds from the start of simulation.
+
|| Similarly set the stop time to 16 seconds from the start of the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Ipv4GlobalRoutingHelper '''
 
|| Highlight '''Ipv4GlobalRoutingHelper '''
|| In order to get the routing tables, we create an '''Ipv4GlobalRoutingHelper '''object.
+
|| In order to get the routing tables, we create an '''Ipv4GlobalRoutingHelper ''' object.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Create<OutputStreamWrapper>'''
 
|| Highlight '''Create<OutputStreamWrapper>'''
|| Then we create an output stream, with the class '''OutputStreamWrapper.'''
+
|| Then we create an output stream, with the class '''OutputStreamWrapper'''.
  
The '''OutputStreamWrapper '''encapsulates an output stream.
+
The '''OutputStreamWrapper ''' encapsulates an output stream.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''global-routing.routes'''
 
|| Highlight '''global-routing.routes'''
 
|| The name of the output file is '''global-routing.routes.'''
 
|| The name of the output file is '''global-routing.routes.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''PrintRoutingTableAllAt'''
 
|| Highlight '''PrintRoutingTableAllAt'''
|| The '''PrintRoutingTableAllAt '''sets the time at which the routing tables are printed.
+
|| The '''PrintRoutingTableAllAt ''' sets the time at which the routing tables are printed.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Seconds (2)'''
 
|| Highlight '''Seconds (2)'''
 
|| We print the tables two times.
 
|| We print the tables two times.
  
 
One at 2 seconds.
 
One at 2 seconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Seconds (12)'''
 
|| Highlight '''Seconds (12)'''
 
|| The other at 12 seconds.
 
|| The other at 12 seconds.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''routingStream'''
 
|| Highlight '''routingStream'''
 
|| The routes are printed to the output stream created earlier.
 
|| The routes are printed to the output stream created earlier.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Only narration
 
|| Only narration
 
|| We print the tables two times to observe the dynamic selection of routes.
 
|| We print the tables two times to observe the dynamic selection of routes.
Line 197: Line 196:
  
 
In this program, the network between nodes 1 and 5 will be set down.
 
In this program, the network between nodes 1 and 5 will be set down.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Ptr<Node> n1 = p2pNodes.Get(1)'''
 
|| Highlight '''Ptr<Node> n1 = p2pNodes.Get(1)'''
 
|| Next we create a pointer to the node whose link would be set down.
 
|| Next we create a pointer to the node whose link would be set down.
  
 
In this case, it is node 1.
 
In this case, it is node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''n1->GetObject<Ipv4>'''
 
|| Highlight '''n1->GetObject<Ipv4>'''
|| Then, we get the '''IPv4 '''class object for the node using the '''GetObject '''method.
+
|| Then, we get the '''IPv4 ''' class object for the node using the '''GetObject ''' method.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''ipv4ifIndex1 = 1'''
 
|| Highlight '''ipv4ifIndex1 = 1'''
 
|| Now we need to select the network that has to be set down.
 
|| Now we need to select the network that has to be set down.
Line 220: Line 219:
  
 
Hence, the index is 1 here.
 
Hence, the index is 1 here.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Simulator::Schedule(Seconds(5), &Ipv4::SetDown, ipv41, ipv4ifIndex1)'''
 
|| Highlight '''Simulator::Schedule(Seconds(5), &Ipv4::SetDown, ipv41, ipv4ifIndex1)'''
 
|| Then, we schedule the down time for the network to 5 seconds.
 
|| Then, we schedule the down time for the network to 5 seconds.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''AnimationInterface anim'''
 
|| Highlight '''AnimationInterface anim'''
|| Next we create an '''AnimationInterface '''object for '''NetAnim '''animation.
+
|| Next we create an '''AnimationInterface ''' object for '''NetAnim ''' animation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
|| <span style="color:#24292e;">Highlight </span>'''anim.SetConstantPosition'''
+
|| Highlight '''anim.SetConstantPosition'''
|| Then set the positions for the nodes using the '''SetConstantPosition '''function.  
+
|| Then set the positions for the nodes using the '''SetConstantPosition ''' function.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Simulator::Run()'''
 
|| Highlight '''Simulator::Run()'''
|| The '''Run '''function is used to run the simulation
+
|| The '''Run ''' function is used to run the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Simulator::Destroy()'''
 
|| Highlight '''Simulator::Destroy()'''
|| And '''Destroy '''function ends the simulation
+
|| And '''Destroy '''function ends the simulation.
  
 
Close the text editor.
 
Close the text editor.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| 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
  
Type '''mv ~/Downloads/DynamicRouting.cc scratch/DynamicRouting.cc '''to move the source file to '''scratch '''directory.
+
Type '''mv ~/Downloads/DynamicRouting.cc scratch/DynamicRouting.cc '''
 +
 
 
|| Now we will observe the simulation.  
 
|| Now we will observe the simulation.  
  
Using the '''cd '''command, navigate to the installation directory of '''ns-3'''.
+
Using the '''cd ''' command, navigate to the installation directory of '''ns-3'''.
  
 
Go to the '''ns-3.38''' directory.
 
Go to the '''ns-3.38''' directory.
  
Move your source file to the '''scratch '''directory within the '''ns-3.38''' directory.
+
Move your source file to the '''scratch ''' directory within the '''ns-3.38''' directory.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Type ./'''ns3 run scratch/DynamicRouting.cc'''
 
|| Type ./'''ns3 run scratch/DynamicRouting.cc'''
|| Run the command '''dot forward slash''' '''ns3 run space scratch forward slash DynamicRoutingprotocols dot cc.'''
+
|| Run the command '''dot forward slash''' '''ns3 run space scratch forward slash DynamicRoutingprotocols dot cc'''.
  
'''DynamicRoutingprotocols dot cc '''is the name of the source file.  
+
'''DynamicRoutingprotocols dot cc ''' is the name of the source file.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Keep the terminal open and show the output of the command  
 
|| Keep the terminal open and show the output of the command  
 
|| After compilation, there is no output on the terminal.
 
|| After compilation, there is no output on the terminal.
  
 
We shall observe the routing tables in the routes file created earlier.
 
We shall observe the routing tables in the routes file created earlier.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Switch to file manager and open the '''ns-3.38 '''directory.
 
|| Switch to file manager and open the '''ns-3.38 '''directory.
  
Line 266: Line 266:
 
|| The routes file is created in the same directory from which we run the simulation.
 
|| The routes file is created in the same directory from which we run the simulation.
  
In this case, it is '''ns-3.38 '''directory.
+
In this case, it is '''ns-3.38 ''' directory.
  
In the directory, a file with the name '''global-routing.routes '''should appear.
+
In the directory, a file with the name '''global-routing.routes ''' should appear.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Open the '''global-routing.routes '''file.
 
|| Open the '''global-routing.routes '''file.
  
Line 277: Line 277:
  
 
In the file for each node, the following details are shown:
 
In the file for each node, the following details are shown:
* <div style="margin-left:1.27cm;margin-right:0cm;">The destination address</div>
+
* The destination address
* <div style="margin-left:1.27cm;margin-right:0cm;">The gateway</div>
+
* The gateway
* <div style="margin-left:1.27cm;margin-right:0cm;">The network mask</div>
+
* The network mask
* <div style="margin-left:1.27cm;margin-right:0cm;">Flags</div>
+
* Flags
* <div style="margin-left:1.27cm;margin-right:0cm;">Metric</div>
+
* Metric
* <div style="margin-left:1.27cm;margin-right:0cm;">Use</div>
+
* Use
* <div style="margin-left:1.27cm;margin-right:0cm;">Interface</div>
+
* Interface
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Destination '''and '''Gateway'''.
 
|| Highlight '''Destination '''and '''Gateway'''.
 
|| The destination address and the gateway are of interest to us.
 
|| The destination address and the gateway are of interest to us.
  
 
These represent the possible paths that the packet can take.
 
These represent the possible paths that the packet can take.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Hover over the table under node 0.
 
|| Hover over the table under node 0.
 
|| As configured earlier, the tables are printed two times.
 
|| As configured earlier, the tables are printed two times.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Highlight '''Time: +2s'''
 
|| Highlight '''Time: +2s'''
 
|| Once at 2 seconds, and the next at 12 seconds.
 
|| Once at 2 seconds, and the next at 12 seconds.
  
 
At 5 seconds, the link between nodes 0 and 1 goes down.
 
At 5 seconds, the link between nodes 0 and 1 goes down.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Scroll down and highlight '''Node: 0, Time: +12s'''
 
|| Scroll down and highlight '''Node: 0, Time: +12s'''
 
|| Hence, at 12 seconds, the routes are different.
 
|| Hence, at 12 seconds, the routes are different.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Hover over the table under node 0.
 
|| Hover over the table under node 0.
 
|| You may inspect the routing tables to see the difference.
 
|| You may inspect the routing tables to see the difference.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Type '''cd ~/ns-allinone-3.38/netanim '''to navigate to the '''netanim '''directory.
 
|| Type '''cd ~/ns-allinone-3.38/netanim '''to navigate to the '''netanim '''directory.
 
|| Now, to visualize the network, we will use '''NetAnim'''.  
 
|| Now, to visualize the network, we will use '''NetAnim'''.  
  
Navigate to the '''netanim '''directory under '''ns-allinone-3.38.'''
+
Navigate to the '''netanim ''' directory under '''ns-allinone-3.38'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Type ./'''NetAnim'''
 
|| Type ./'''NetAnim'''
|| Now type '''dot forward slash NetAnim. '''The '''NetAnim '''window will open.
+
|| Now type '''dot forward slash NetAnim'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
 
|| Click on the '''Open XML trace file '''icon on the top left corner of the window.
+
'''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.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|| 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 '''DynamicRouting.xml '''file.
 
|| In the file picker, navigate to the '''ns-allinone-3.38/ns-3.38 '''directory and select the '''DynamicRouting.xml '''file.
 
|| In the file picker, navigate to the '''ns-3.38 '''directory.
 
|| In the file picker, navigate to the '''ns-3.38 '''directory.
  
 
Select the '''DynamicRouting.xml '''file.
 
Select the '''DynamicRouting.xml '''file.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| On the toolbar, click on the '''Node Size '''drop down button, and select size 10.
 
|| On the toolbar, click on the '''Node Size '''drop down button, and select size 10.
 
|| On the toolbar, click on the '''Node Size '''drop down button.
 
|| On the toolbar, click on the '''Node Size '''drop down button.
  
 
Select size 10.
 
Select size 10.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| On the toolbar, click on the play button
 
|| On the toolbar, click on the play button
|| On the toolbar, click on the play button to view the simulation.
+
|| On the toolbar, click on the '''Play Animation''' button to view the simulation.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Hover the cursor over node 0.
 
|| Hover the cursor over node 0.
 
|| We see the circles representing the nodes.
 
|| We see the circles representing the nodes.
  
 
The packets go from node 0 to node 5, via node 1.
 
The packets go from node 0 to node 5, via node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Move the cursor over the link between node 0 and node 1.
 
|| Move the cursor over the link between node 0 and node 1.
 
|| The lines with arrows represent the transfer of packets.
 
|| The lines with arrows represent the transfer of packets.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Move the cursor from node 0 to node 1.  
 
|| Move the cursor from node 0 to node 1.  
  
Line 345: Line 347:
 
Move the cursor according to the arrows.
 
Move the cursor according to the arrows.
 
|| The packets go from node 0 to node 5, via node 1.
 
|| The packets go from node 0 to node 5, via node 1.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Hover over the ‘'''Sim time’ '''slider on the toolbar.
 
|| Hover over the ‘'''Sim time’ '''slider on the toolbar.
  
Line 354: Line 356:
  
 
This route goes from nodes 2, 3 and 4.
 
This route goes from nodes 2, 3 and 4.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Hover the cursor over the arrows as they move from node 0 to node 5.
 
|| Hover the cursor over the arrows as they move from node 0 to node 5.
  
Line 361: Line 363:
 
|| As we can see, the packets automatically switch to the next available route.
 
|| As we can see, the packets automatically switch to the next available route.
  
The selection of paths is based on the '''OSPF protoco'''l.
+
The selection of paths is based on the '''OSPF protocol'''.
  
 
To learn more about OSPF, please refer to this link
 
To learn more about OSPF, please refer to this link
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:  
 
|| Show slide:  
  
Line 372: Line 374:
  
 
In this tutorial, we have learnt to
 
In this tutorial, we have learnt to
* <div style="margin-left:1.27cm;margin-right:0cm;">Create a multi-path topology</div>
+
* Create a multi-path topology
* <div style="margin-left:1.27cm;margin-right:0cm;">Schedule down times for links</div>
+
* Schedule down times for links
* <div style="margin-left:1.27cm;margin-right:0cm;">Implement '''OSPF dynamic routing'''</div>
+
* Implement '''OSPF dynamic routing'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Assignment'''
 
'''Assignment'''
 
|| As an assignment, please do the following:
 
|| As an assignment, please do the following:
* <div style="margin-left:1.27cm;margin-right:0cm;">Modify the code for the below criteria.</div>
+
* Modify the code for the below criteria.
* <div style="margin-left:1.27cm;margin-right:0cm;">Make the link between node 1 and node 4 down at 5 seconds</div>
+
* Make the link between node 1 and node 4 down at 5 seconds
* <div style="margin-left:1.27cm;margin-right:0cm;">Generate an XML file for animation</div>
+
* Generate an XML file for animation
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Assignment - Observation'''
 
'''Assignment - Observation'''
|| <span style="background-color:#ffffff;">In </span><span style="background-color:#ffffff;">'''NetAnim'''</span><span style="background-color:#ffffff;">, you will observe the change in routes after 5 seconds.</span>
+
|| In '''NetAnim''', you will observe the change in routes after 5 seconds.
  
 
The route from node 0 to node 5 through node 4 gets chosen automatically.
 
The route from node 0 to node 5 through node 4 gets chosen automatically.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:  
 
|| Show slide:  
  
 
'''About the Spoken Tutorial Project'''
 
'''About the Spoken Tutorial Project'''
|| <span style="background-color:#ffffff;">The video at the following link summarizes the </span><span style="background-color:#ffffff;">'''Spoken Tutorial project'''</span><span style="background-color:#ffffff;">.</span>
+
|| The video at the following link summarizes the '''Spoken Tutorial project'''.
  
 
Please download and watch it.
 
Please download and watch it.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show Slide:
 
|| Show Slide:
  
<span style="background-color:#ffffff;color:#252525;">'''Spoken Tutorial Workshops'''</span>
+
'''Spoken Tutorial Workshops'''  
|| <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''Spoken Tutorial Project'''</span><span style="background-color:#ffffff;"> team conducts workshops and gives certificates.</span>
+
|| The '''Spoken Tutorial Project''' team conducts workshops and gives certificates.
  
 
For more details, please write to us.
 
For more details, please write to us.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''Answers for THIS Spoken Tutorial'''</div>
+
'''Answers for THIS Spoken Tutorial'''
 
|| Please post your timed queries in this forum.
 
|| Please post your timed queries in this forum.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''FOSSEE Forum'''</div>
+
'''FOSSEE Forum'''
|| <span style="background-color:#ffffff;">For any general or technical questions on </span><span style="background-color:#ffffff;">'''ns-3'''</span><span style="background-color:#ffffff;">, visit the</span><span style="background-color:#ffffff;">''' FOSSEE forum'''</span><span style="background-color:#ffffff;"> and post your question.</span>
+
|| For any general or technical questions on '''ns-3''', visit the''' FOSSEE forum''' and post your question.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide
 
|| Show slide
  
 
'''Acknowledgement'''
 
'''Acknowledgement'''
|| <span style="color:#252525;">'''Spoken Tutorial'''</span><span style="color:#252525;"> Project was established by the </span><span style="color:#252525;">'''Ministry of Education, Government of India'''</span><span style="color:#252525;">.</span>
+
|| '''Spoken Tutorial''' Project was established by the '''Ministry of Education, Government of India'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide
 
|| Show slide
  
 
'''Acknowledgement'''
 
'''Acknowledgement'''
|| <span style="color:#252525;">We thank </span><span style="color:#252525;">'''Dr.Moyukh Laha'''</span><span style="color:#252525;"> from </span><span style="color:#252525;">'''IIT Kharagpur'''</span><span style="color:#252525;"> for his domain support.</span>
+
|| We thank '''Dr.Moyukh Laha''' from '''IIT Kharagpur''' for his domain support.
  
<span style="color:#252525;">We would also like to thank </span><span style="color:#252525;">'''Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi '''</span><span style="color:#252525;">from</span><span style="color:#252525;">''' VIT, Chennai '''</span><span style="color:#252525;">for their support</span>
+
We would also like to thank '''Dr. R. Radha, Dr. X. Anita, and Dr. T. Subbulakshmi '''from''' VIT, Chennai '''for their support
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-
 
|| Show slide:
 
|| Show slide:
  
 
'''Thank You'''
 
'''Thank You'''
|| <span style="background-color:#ffffff;">This is </span><span style="background-color:#ffffff;">'''Josiga, '''</span><span style="background-color:#ffffff;">a FOSSEE summer fellow 2023, IIT Bombay signing off.</span>
+
|| This is '''Josiga, '''a FOSSEE summer fellow 2023, IIT Bombay signing off.
  
  

Latest revision as of 14:49, 22 March 2024

Visual Cue Narration
Slide:1 Welcome to the spoken tutorial on Dynamic routing protocols in ns-3.
Show slide:

Learning Objectives

In this tutorial, we will learn to
  • Create a multi-path topology
  • Schedule down times for links
  • Implement OSPF dynamic routing
Show slide:

System Requirements

To record this tutorial, I am using:
  • Ubuntu Linux operating system version 22.04
  • ns-3.38
  • NetAnim visualizer tool
Show slide:

Prerequisite

https://spoken-tutorial.org/

To follow this tutorial
  • You must have basic knowledge of Linux and ns-3
  • For pre-requisite Linux and ns-3 tutorials, please visit this website
Show slide:

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 slide:

What is OSPF Routing?

  • Open Shortest Path First (OSPF) is a link state routing protocol
  • It determines the shortest path between the source and the destination
Show diagram:

Network topology with 6 nodes and four paths

For this tutorial, we would be creating the following topology:
  • The topology consists of 6 nodes
  • Node 0 is the client node
  • Node 5 is the server node
  • There are four paths from client to server
  • Each link is point-to-point connection
Open the file DynamicRouting.cc in text editor I have created the source file DynamicRoutingprotocols.cc for this program.

Now we will go through the source code in the text editor.

The source code contains the required functions to implement OSPF dynamic routing.

Highlight Config::SetDefault("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue(true)) Using the SetDefault method, we first enable dynamic routing.

RespondToInterfaceEvents enables the ns-3 program to automatically change routes.

Highlight

NodeContainer p2pNodes

p2pNodes.Create(6)

The node container contains 6 nodes.
Highlight stack.Install(p2pNodes); Let’s install an internet stack on the nodes.
Highlight NodeContainer n01, n02, n23, n14, n15, n45; Next we create 6 more node containers.

These containers are for the individual point-to-point networks.

The node containers are n01, n02, n23, n34, n14, n15 and n45.

Highlight Address.SetBase Then we assign base addresses to the point-to-point networks.
Highlight 10.1.1.0 The address of the network between node 0 and node 1 is 10.1.1.0.
Highlight 10.1.2.0 The address of the network between node 0 and node 2 is 10.1.2.0.

Similarly, the addresses of the other networks are set.

Highlight pointToPoint.Install(n01) The Install method installs point-to-point channels on the nodes.

The nodes are node 0 and node 1 here.

Highlight NetDeviceContainer nd01 The Install method returns an object of NetDeviceContainer class.

We store it in object nd01.

Highlight Address.Assign(nd01) The Assign method assigns IP addresses to the nodes.

The IP addresses are based on the network address.

Highlight Ipv4InterfaceContainer i01 The Assign method returns an Ipv4InterfaceContainer object.

We store it in object i01.

Highlight uint16_t port = 9 Next, we set the port number to 9.
Highlight OnOffHelper onoff Then we create OnOff applications to send packets.
Highlight InetSocketAddress(i45.GetAddress(1), port) Here we create a UDP socket on the remote destination node.

The socket is created on port 9 of node 5.

We get the IP address of node 5 using the i45 object.

The GetAddress method is used to get the address of the node with index 1.

Please note that the indexing is within i45 interface.

Highlight onoff.SetConstantRate(DataRate("2kbps")) Then, we set the properties for the application.

The data rate is set to 2kbps.

Highlight onoff.SetAttribute The packet size is set to 50 bytes.
Highlight ApplicationContainer apps = onoff.Install(p2pNodes.Get(0)) Create an application container.

Then, install the OnOff application on node 0.

Here the indexing is in the overall network.

Highlight apps.Start(Seconds(1.0)) Set the start time for the apps to 1 second from the start of the simulation.
Highlight apps.Stop(Seconds(16.0)) Similarly set the stop time to 16 seconds from the start of the simulation.
Highlight Ipv4GlobalRoutingHelper In order to get the routing tables, we create an Ipv4GlobalRoutingHelper object.
Highlight Create<OutputStreamWrapper> Then we create an output stream, with the class OutputStreamWrapper.

The OutputStreamWrapper encapsulates an output stream.

Highlight global-routing.routes The name of the output file is global-routing.routes.
Highlight PrintRoutingTableAllAt The PrintRoutingTableAllAt sets the time at which the routing tables are printed.
Highlight Seconds (2) We print the tables two times.

One at 2 seconds.

Highlight Seconds (12) The other at 12 seconds.
Highlight routingStream The routes are printed to the output stream created earlier.
Only narration We print the tables two times to observe the dynamic selection of routes.

Between the two prints, we shall make the shortest link down.

Then, the next shortest link would be selected dynamically.

In this program, the network between nodes 1 and 5 will be set down.

Highlight Ptr<Node> n1 = p2pNodes.Get(1) Next we create a pointer to the node whose link would be set down.

In this case, it is node 1.

Highlight n1->GetObject<Ipv4> Then, we get the IPv4 class object for the node using the GetObject method.
Highlight ipv4ifIndex1 = 1 Now we need to select the network that has to be set down.

A single node can be connected to multiple networks.

We need to specify the index of the network.

The network indexes start from 1.

For this tutorial, we are deactivating the link between nodes 0 and 1.

It is the first network for node 1.

Hence, the index is 1 here.

Highlight Simulator::Schedule(Seconds(5), &Ipv4::SetDown, ipv41, ipv4ifIndex1) Then, we schedule the down time for the network to 5 seconds.
Highlight AnimationInterface anim Next we create an AnimationInterface object for NetAnim animation.
Highlight anim.SetConstantPosition Then set the positions for the nodes using the SetConstantPosition function.
Highlight Simulator::Run() The Run function is used to run the simulation.
Highlight Simulator::Destroy() And Destroy function ends the simulation.

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/DynamicRouting.cc scratch/DynamicRouting.cc

Now we will observe the simulation.

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/DynamicRouting.cc Run the command dot forward slash ns3 run space scratch forward slash DynamicRoutingprotocols dot cc.

DynamicRoutingprotocols dot cc is the name of the source file.

Keep the terminal open and show the output of the command After compilation, there is no output on the terminal.

We shall observe the routing tables in the routes file created earlier.

Switch to file manager and open the ns-3.38 directory.

Select the global-routing.routes file.

The routes file is created in the same directory from which we run the simulation.

In this case, it is ns-3.38 directory.

In the directory, a file with the name global-routing.routes should appear.

Open the global-routing.routes file.

Highlight Node: 0, Time: +2s

Open the file by double clicking on it.

In the file for each node, the following details are shown:

  • The destination address
  • The gateway
  • The network mask
  • Flags
  • Metric
  • Use
  • Interface
Highlight Destination and Gateway. The destination address and the gateway are of interest to us.

These represent the possible paths that the packet can take.

Hover over the table under node 0. As configured earlier, the tables are printed two times.
Highlight Time: +2s Once at 2 seconds, and the next at 12 seconds.

At 5 seconds, the link between nodes 0 and 1 goes down.

Scroll down and highlight Node: 0, Time: +12s Hence, at 12 seconds, the routes are different.
Hover over the table under node 0. You may inspect the routing tables to see the difference.
Type cd ~/ns-allinone-3.38/netanim to navigate to the netanim directory. Now, to visualize the network, we will use NetAnim.

Navigate to the netanim directory under ns-allinone-3.38.

Type ./NetAnim Now type dot forward slash NetAnim.

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 DynamicRouting.xml file. In the file picker, navigate to the ns-3.38 directory.

Select the DynamicRouting.xml file.

On the toolbar, click on the Node Size drop down button, and 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.
Hover the cursor over node 0. We see the circles representing the nodes.

The packets go from node 0 to node 5, via node 1.

Move the cursor over the link between node 0 and node 1. The lines with arrows represent the transfer of packets.
Move the cursor from node 0 to node 1.

Then move the cursor from node 1 to node 5.

Move the cursor according to the arrows.

The packets go from node 0 to node 5, via node 1.
Hover over the ‘Sim time’ slider on the toolbar.

Wait for it to cross 5 seconds.

After 5 seconds, the link between nodes 0 and 1 gets down.

Before the link was set down, path 0-1-5 was the shortest.

This route goes from nodes 2, 3 and 4.

Hover the cursor over the arrows as they move from node 0 to node 5.

https://en.wikipedia.org/wiki/Open_Shortest_Path_First

As we can see, the packets automatically switch to the next available route.

The selection of paths is based on the OSPF protocol.

To learn more about OSPF, please refer to this link

Show slide:

Summary

This brings us to the end of the tutorial. Let us summarize.

In this tutorial, we have learnt to

  • Create a multi-path topology
  • Schedule down times for links
  • Implement OSPF dynamic routing
Show slide:

Assignment

As an assignment, please do the following:
  • Modify the code for the below criteria.
  • Make the link between node 1 and node 4 down at 5 seconds
  • Generate an XML file for animation
Show slide:

Assignment - Observation

In NetAnim, you will observe the change in routes after 5 seconds.

The route from node 0 to node 5 through node 4 gets chosen automatically.

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.


Thanks for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat