Mininet

Working through

The operation of Mininet is very simple, starting a small test network only needs the following steps

  • Log in to the command line interface of the virtual machine, open wireshark, enable it to run in the background

sudo wireshark &

  • Start Mininet, the command is

sudo mn

and the network topology shown in the figure below will be created by default.

After a short wait, you can enter the command line interface guided by mininet>.

Okay, from now on, we have a controller, a switch (switch), two hosts (host) network, and use wireshark to observe. To view all nodes

mininet> nodes

c0 h2 h3 s1

To view all links

mininet> net

To view a specific link:

mininet> net s1 <-> h2-eth0 h3-eth0

Output the information of each node:

mininet> dump c0: IP=127.0.0.1 intfs= pid=167

To view the network information on switch s1, we only need to execute the ifconfig command, that is,

s1 ifconfig

mininet> h2 ping -c 3 h3


PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.

64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=7.19 ms

64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.239 ms

64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.136 ms

— 10.0.0.3 ping statistics —

3 packets transmitted, 3 received, 0% packet loss, time 2006ms

rtt min/avg/max/mdev = 0.136/2.523/7.194/3.303 ms

After performed, you can view the creation of a new flow entry through the wireshark record Process, this is also the reason that the result of the first ping is too large.

A simpler whole-network mutual ping test command is pingall, which will automatically all host nodes

Perform a ping connection test one by one.

In addition to the interactive way of cli, Mininet also provides more convenient automatic execution of fast

The quick test method, the format is sudo mn --test cmd, it can be automatically started and executed.

The cmd operation will exit automatically after completion.

For example, sudo mn --test pingpair can directly test the host connectivity

Try, sudo mn --test iperf starts performance test directly. In this way It is convenient to get the experimental results directly.

Customize topy

Mininet provides Python API, which can be used to easily customize the topology. Several examples are given in the mininet/custom directory.

A mytopo is defined in the 2host.py file, you can use the --topo option to

Specify to use this topology, the command is

sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall

Similarly, we can use the following Python script to complete a 2-layer tree.