As you can see from the above figure that we have two hosts and
also both the hosts are connected to a
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
- Create a network
- Add controllers
- Adding two hosts
and
- Adding a switch
- As you can see from the above topology we need two links to connect
,
and
- Mininet is doing default configuration on hosts
and
- Mininet is starting a controller c0
- Mininet is starting a switch
- 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 by using the below command
h1 ifconfig -a
Similarly, you can also check interfaces of host by replacing
with
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
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
exit
You can also view links information
links
in the same fashion, To view the number of nodes in a topology
nodes
Shows even more info
dump
in the same way, Shows the connectivity between nodes of the topology
net
Another example
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
python
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
Quit()
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
Cat>simple_python_script.py
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 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
in the final analysis, To exit the nano command to use Ctrl+x
Leave a Reply