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
- Lightweight and runs real code (like real Linux hosts)
- Allows fast prototyping of large networks
- Integrates well with OpenFlow and SDN controllers like POX, Ryu, and ONOS
Installation
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)
Single Switch, Multiple Hosts
1 | sudo mn --topo=single,5 |
Linear Topology (Switches connected in a line)
1 | sudo mn --topo=linear,3 |
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 |
show connections
1 | net |
test connectivity
1 | pingall |
show host IP
1 | h1 ifconfig |
test ping between hosts
1 | h1 ping h2 |
exit & clean up
1 | sudo mn -c |
Custom Topology Example (Python Script)
1 | from mininet.topo import Topo |
1 | sudo python3 mytopo.py |
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