Mininet default topology example

Rendered by QuickLaTeX.com

As you can see from the above figure that we have two hosts h_1 and h_2 also both the hosts  are connected to a L_2 switch S

You can launch the above topology on the network by a command mentioned below

sudo mn

At this instant, you can see the command sudo mn creates

  1. Create a network
  2. Add controllers
  3. Adding two hosts h_1 and h_2
  4. Adding a switch S_1
  5. As you can see from the above topology we need two links to connect h_1,h_2 and s_1
  6. Mininet is doing default configuration on hosts h_1 and h_2
  7. Mininet is starting a controller c0
  8. Mininet is starting a switch s_1
  9. In the end, you will get a Mininet prompt where you can interact with the network

You can check the interfaces of the host h_1 by using the below command

h1 ifconfig -a

Similarly, you can also check interfaces of host h_2 by replacing h_1 with h_2

h2 ifconfig -a

You can ping host machine h1 to host machine h2 because there is a link is present in between them

h1 ping h2

Similarly, You can ping host machine h2 to host machine h1 because there is a link is present in between them

h2 ping h1

You can also ping h2 to h1 by using an IP address of h1

h2 ping 10.0.0.1

To exit the ping command use the short key Ctrl+c

To exit the current topology  in the Mininet use the command mentioned below

exit

You can also view links information

links

To view the number of nodes in a topology

nodes

Shows even more info

dump

Shows the connectivity between nodes of the topology

net

Another example

Rendered by QuickLaTeX.com

As you can see, we have another Mininet topology to implement

 so, you can launch the above topology by using the below command

sudo mn --topo=tree,depth=2,fanout=2

The above command shows that it will launch a tree base topology and depth=2 means the height of the tree will be two

Fanout =2 means the children that each node will have will be two

With the help of the above command, the mininet created a network topology by adding four hosts to the network

Finally, you can ping one host to another host in this network topology such

h1 ping h4
h1 ping h3

We can create even more customized or complex topologies by writing python programs and Mininet can execute these python programs to launch a topology

How to compile a python script with Mininet

If you like to create custom topologies with Mininet then you can use python scripts

So, to compile python scripts on Mininet first type the command mentioned below to check whether you have python ide

python

If you see something python versions such as python 3.8.5 or any other version that means you have a python ide

To exit from python-mode

Quit()

Note: that the commands that you use in the linux terminal are also applicable in the Mininet terminal

Let us create a folder for python scripts

mkdir Mininet_scripts

Get in the directory or folder Mininet_scripts

cd Mininet_scripts

Create a python file and edit it

Cat>simple_python_script.py

Type your python script

Print(“this is just a simple script to test”)

Save and exit the python program by a short key  Ctrl+d

Compile the python script

Sudo python simple_python_script.py

If you like to edit the saved program then you can do it by using the below command

nano simple_python_script.py

To exit the nano command to use Ctrl+x

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.