SDN’s full name is Software Defined Network, which is a new innovative network architecture in the current Internet. Its core technology OpenFlow separates the control plane and data plane of network equipment to achieve network traffic control. Flexible control provides a good platform for networks and applications. Mininet is a lightweight software-defined network and test platform; it uses lightweight virtualization technology to make a single system look like a complete network running the thought kernel system and user code, which can also be simply understood as A process-based virtualization platform in the SDN network system. It supports various protocols such as OpenFlow and OpenvSwith. Mininet can also simulate a complete network host, link and switch on the same computer and facilitates interactive development, testing and Demonstrations, especially those using OpenFlow and SDN technologies; it is also possible to migrate code from this process virtualization platform to a real environment.
Features implemented by MininetThe installation method of Mininet is relatively simple. It can be installed in the Linux system through the Git source code and the built-in installation script. Here I use the default installation of all Mininet-related related packages, such as: OpenFlow, POX and other tools will be saved by default. In the current user's home directory.
<br>
# git clone git://github.com/mininet/mininet<br>
# cd mininet/util/<br>
# ./install.sh -a<br>
#ls<br>
mininet of-dissector oflops oftest openflow pox<br>
Figure 1. Simple network example diagram
Since Mininet supports custom networks, here is a simple network example as shown in Figure 1. Enter the mn command directly in the Mininet network system to create a single-layer topology network in this system, from which two hosts are created by default. and a switch, and the controller and switch are activated. At the same time, you can also check the link status through the command net. First, a simple example is listed, such as enabling the web server and client in the Mininet system.
<br>
#mn<br>
*** Creating network<br>
*** Adding controller<br>
*** Adding hosts:<br>
h1 h2<br>
*** Adding switches:<br>
s1<br>
*** Adding links:<br>
(h1, s1) (h2, s1)<br>
*** Configuring hosts<br>
h1 h2<br>
*** Starting controller<br>
*** Starting 1 switches<br>
s1<br>
*** Starting CLI:<br>
mininet><br>
Enable and turn off Web services
It is easy to establish a Web server in the Mininet environment. From the following example, you can see that a Web server is established from host1 and obtains HTTP requests from another Host to the Web server.
<br>
mininet> h1 python -m SimpleHTTPServer 80 & #Open Web service on host h1<br>
mininet> h2 wget -O - h1 #Download h1 web site content on host h2<br>
--2013-11-04 00:05:40-- http://10.0.0.1/<br>
Connecting to 10.0.0.1:80... connected.<br>
HTTP request sent, awaiting response... 200 OK<br>
…………<br>
Length: 760 [text/html<br>
<br>
<title>Directory listing for /</title>
0K 100% 1.65M=0s
2013-11-04 00:05:40 (1.65 MB/s) - written to stdout [760/760]
mininet> h1 kill %python # Kill the web process
10.0.0.2 - - [04/Nov/2013 00:05:40] "GET / HTTP/1.1" 200 -
bash: line 23: kill: python: ambiguous job spec
Ping test
On the Mininet system, realize the interconnection test between two hosts.
<br>
mininet> h1 ping -c4 h2<br>
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.<br>
64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=1.55 ms<br>
64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.094 ms<br>
64 bytes from 10.0.0.2: icmp_req=3 ttl=64 time=0.075 ms<br>
64 bytes from 10.0.0.2: icmp_req=4 ttl=64 time=0.071 ms
--- 10.0.0.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 0.071/0.448/1.553/0.638 ms
View nodes and links
<br>
mininet> nodes<br>
available nodes are:<br>
c0 h1 h2 s1<br>
mininet> net<br>
h1 h1-eth0:s1-eth1<br>
h2 h2-eth0:s1-eth2<br>
s1 lo: s1-eth1:h1-eth0 s1-eth2:h2-eth0<br>
c0<br>
Mininet supports custom topology. An example is given in the mininet/custom directory. If a mytopo is defined in the topo-2sw-2host.py file, you can specify the use of this through the --topo option. Topology:
Figure 2. Custom topology example
Since Mininet also supports parameterized topology, a flexible topology can be created through Python code, which can also be configured according to custom parameters passed in, and can be reused in multiple environments. The general structure of its code is briefly listed below. and meaning.
<br>
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
class SingleSwitchTopo(Topo):
def __init__(self, n=2, **opts):
Topo.__init__(self, **opts)
switch = self.addSwitch('s1') #Add a switch in the topology
for h in range(n):
host = self.addHost('h%s' % (h 1)) #Add host to the topology
self.addLink(host, switch) #Add two-way connection topology
def simpleTest():
topo = SingleSwitchTopo(n=4)
net = Mininet(topo) #Main class to create and manage networks
net.start() #Start your topology network
print "Dumping host connections"
dumpNodeConnections(net.hosts) #Dump file connection
print "Testing network connectivity"
net.pingAll() #All nodes test interconnection with each other
net.stop() #Stop your network
if __name__ == '__main__':
setLogLevel('info') #Set Mininet default output level, set info it will provide some useful information
simpleTest()
<br>
# python test-single.py<br>
*** Creating network<br>
*** Adding controller<br>
*** Adding hosts:<br>
h1 h2 h3 h4<br>
*** Adding switches:<br>
s1<br>
*** Adding links:<br>
(h1, s1) (h2, s1) (h3, s1) (h4, s1)<br>
*** Configuring hosts<br>
h1 h2 h3 h4<br>
*** Starting controller<br>
*** Starting 1 switches<br>
s1<br>
Dumping host connections<br>
h1 h1-eth0:s1-eth1<br>
h2 h2-eth0:s1-eth2<br>
h3 h3-eth0:s1-eth3<br>
h4 h4-eth0:s1-eth4<br>
Testing network connectivity<br>
*** Ping: testing ping reachability<br>
h1 -> h2 h3 h4<br>
h2 -> h1 h3 h4<br>
h3 -> h1 h2 h4<br>
h4 -> h1 h2 h3<br>
*** Results: 0% dropped (12/12 received)
Normally, the host interface has an independent namespace, and the control node and switching node are both in the root namespace. If you want all nodes to have their own namespace, you need to add the --innamespace parameter, that is, execute: mn --innamespace
<br>
# mn --innamespace --switch user<br>
*** Creating network<br>
*** Adding controller<br>
*** Adding hosts:<br>
h1 h2<br>
*** Adding switches:<br>
s1<br>
*** Adding links:<br>
(h1, s1) (h2, s1)<br>
c0 s1<br>
*** Testing control network<br>
s1 -> c0<br>
c0 -> s1<br>
*** Results: 0% dropped (2/2 received)
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1
*** Starting CLI:
Table 1. Mininet common instructions
The above is the detailed content of Mininet of SDN network system. For more information, please follow other related articles on the PHP Chinese website!