What is Mininet?

Mininet is a lightweight network emulator that creates a virtual network with hosts, switches, links, and controllers all on a single machine. It’s widely used in Software-Defined Networking (SDN) research and education.
mininet

Key Features

  1. Lightweight and runs real code (like real Linux hosts)
  2. Allows fast prototyping of large networks
  3. Integrates well with OpenFlow and SDN controllers like POX, Ryu, and ONOS

Installation

mininet download

Basic Concepts

  • Host: virtual end device (eg, h1, h2)
  • Switch: OpenFlow-enabled switch (eg, s1)
  • Controller: Manages forwarding rules (eg, POX, Ryu)
  • Link: Virtual cable between nodes

Simple Command

Mininet Command Structure

Mininet commands fall into three categories:

  • Network Startup Parameters – –topo, –custom, –switch, –controller, –mac, etc.
  • Interactive CLI Commands – net, nodes, pingall, dump, iperf, etc.
  • External Parameters – -c (cleanup), -h (help), etc.

create simple topology

1
sudo mn

This launches the default topology (2 hosts, 1 switch, 1 controller)
default topology

Single Switch, Multiple Hosts

1
sudo mn --topo=single,5

Linear Topology (Switches connected in a line)

1
2
sudo mn --topo=linear,3
sudo mn --topo=linear,3,2

Tree Topology (Hierarchical switches)

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

depth: Number of switch levels
fanout: Number of child switches/hosts per parent

list all nodes

1
nodes

list all nodes

show connections

1
net

show connections

test connectivity

1
pingall

test connectivity

show host IP

1
h1 ifconfig

show host IP

test ping between hosts

1
h1 ping h2

test ping between hosts

exit & clean up

1
sudo mn -c

exit & clean up

Custom Topology Example (Python Script)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.link import TCLink

class MyTopo(Topo):
def build(self):
h1 = self.addHost('h1')
h2 = self.addHost('h2')
s1 = self.addSwitch('s1')
self.addLink(h1, s1)
self.addLink(h2, s1)

if __name__ == '__main__':
topo = MyTopo()
net = Mininet(topo=topo, controller=Controller)
net.start()
CLI(net)
net.stop()
1
sudo python3 mytopo.py

exampl

more info: mininet

Conclusion

Mininet is an essential tool for learning and experimenting with SDN and virtual networking. It supports:

  • Real Linux networking code
  • Python scripting for custom topologies
  • Integration with external SDN controllers
  • Fast and scalable virtual testing