A whole network in one command
Mininet is a tool that builds a whole test network, with hosts, switches and links, on one computer in a few seconds. You can try a network design, break it and build it again without buying a single cable.
Software-defined networking research and teaching both rely on it, because the network is only software.
By the end of this lesson
Note
I can build a small test network and check that every host can reach every other.
Key words
| Word | What it means |
|---|---|
| Host | a computer on the network |
| Link | a cable between two devices |
| Topology | the shape of a network: what is joined to what |
| Mininet | a tool that builds a test network from software |
| Ping test | every host pings every other host |
The cells students fill in are left blank in this preview.
A topology says what is joined to what
You describe a network to Mininet by naming its topology. single,4 means one switch with four hosts on it. linear,3 means three switches in a row, each with one host. tree,depth=2,fanout=2 means a tree of switches with two branches at each level.
Mininet names the hosts h1, h2 and so on, and the switches s1, s2 and so on.
Worked example: four topologies, counted
| Topology | Hosts | Switches | Links |
|---|---|---|---|
| single,3 | 3 | 1 | 3 |
| single,4 | 4 | 1 | 4 |
| linear,3 | 3 | 3 | 5 |
| tree,depth=2,fanout=2 | 4 | 3 | 6 |
The cells students fill in are left blank in this preview.
A ping test tries every pair
Mininet can run a ping test for you with --test pingall. Every host pings every other host, and Mininet prints how many pings got no answer.
The word is pingall because it tests all of them. Each host pings each other host, so a pair is tried in both directions.
Worked example: how many pings a test sends
| Hosts | Each host pings | Pings in all |
|---|---|---|
| 2 | 1 other host | 2 x 1 = 2 |
| 3 | 2 other hosts | 3 x 2 = 6 |
| 4 | 3 other hosts | 4 x 3 = 12 |
| 5 | 4 other hosts | 5 x 4 = 20 |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think a ping test tries each pair of hosts once, so 4 hosts would send 6 pings. Each host pings every other host, so each pair is tried in both directions. The count is hosts times one fewer than hosts: 4 hosts send 12 pings.
Run a test network in your lab
Mininet and the lab's controller both want port 6653. If the controller is still running, Mininet stops with the message Please shut down the controller which is running on port 6653.
So the first command stops the lab and frees the port. The next three each build a network, test it and take it down again. Mininet removes every Open vSwitch switch when it stops, br0 too, so the last command builds your lab again.
Stop the lab and free port 6653
sudo sdnlab downShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
The smallest test network
sudo mn --mac --test pingallShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Reading what Mininet printed
Mininet prints a line for each step. It adds a controller, then hosts h1 and h2, then a switch s1, then the links (h1, s1) (h2, s1).
It pings, and the results line says 0% dropped (2/2 received). A first line about resource limits may appear. You can ignore it.
One switch with four hosts
sudo mn --mac --topo single,4 --test pingallShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Three switches in a row
sudo mn --mac --topo linear,3 --test pingallShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Build the lab again
sudo sdnlab flowsShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
What the three tests showed
The four host test ended with 0% dropped (12/12 received), and the three switch test with (6/6 received). Both match the counts in the table.
You can also open Mininet's own prompt with sudo mn --mac --topo single,3. It waits for you to type, so try it in the terminal rather than here, and type exit to leave.