Mininet default topology example

Rendered by

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

in reality, 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

in the first place, 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

another key point, To exit the ping command use the short key Ctrl+c

in similar fashion, To exit the current topology  in the Mininet use the command mentioned below


You can also view links information


in the same fashion, To view the number of nodes in a topology


Shows even more info


in the same way, Shows the connectivity between nodes of the topology


Another example

Rendered by

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

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

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

in short, 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


If you see some python version such as python 3.8.5 or any other version that means you have a python ide on your system

this time, To exit from python-mode


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

on this occasion, Let us create a folder for python scripts

mkdir Mininet_scripts

in the first place, Get in the directory or folder Mininet_scripts

cd Mininet_scripts

in the second place, Create a python file and edit it


in the third place, Type your python script

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

in the fourth place, Save and exit the python program by a short key  Ctrl+d

this time, Compile the python script

Sudo python

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


in the final analysis, 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.