Mininet’s API is built at three primary levels:
* Low-level API: The low-level API consists of the base node and link classes (such as Host,Switch, and Link and their subclasses) which can actually be instantiated individually and used to create a network, but it is a bit unwieldy.
* Mid-level API: The mid-level API adds the Mininet object which serves as a container for nodes and links. It provides a number of methods (such as addHost(), addSwitch(), andaddLink()) for adding nodes and links to a network, as well as network configuration, startup and shutdown (notably start() and stop().)mininet 对象作为一个容器提供了几个功能,如方便的添加节点,链路,配置网络,开启关闭网络等。
* High-level API: The high-level API adds a topology template abstraction, the Topo class, which provides the ability to create reusable, parametrized topology templates. These templates can be passed to the mn command (via the --custom option) and used from the command line.
It is valuable to understand each of the API levels. In general when you want to control nodes and switches directly, you use the low-level API. When you want to start or stop a network, you usually use the mid-level API (notably the Mininet class.)
Things become interesting when you start thinking about creating full networks. Full networks can be created using any of the API levels (as seen in the examples), but usually you will want to pick either the mid-level API (e.g. Mininet.add*()) or the high-level API (Topo.add*()) to create your networks.
Here are examples of creating networks using each API level:
Low-level API: nodes and links
h1 &