In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to get started with Mininet. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Mininet is a process virtualization network simulation tool developed by Stanford University based on Linux Container architecture, which can create a virtual network containing hosts, switches, controllers and links. The switch supports OpenFlow and has a highly flexible custom software-defined network.
The features implemented by Mininet support OpenFlow, OpenvSwitch and other soft-defined network components to support system-level restore testing, support complex topologies, custom topologies, etc., and provide Python API, which is convenient for multiple people to collaborate and develop good hardware portability and high scalability. Miniet implementation and workflow of network structure with thousands of hosts
The installation method of Mininet is relatively simple. It can be installed in the Linux system through Git source code and its own installation script. Here, I use the default installation of all Mininet-related suites, such as OpenFlow, POX and other tools will be saved in the current user's home directory by default. # git clone git://github.com/mininet/mininet # cd mininet/util/ #. / install.sh-a # ls mininet of-dissector oflops oftest openflow pox
Create network figure 1. Simple network example diagram
Because Mininet supports custom networks, here we first refer to a simple network example as shown in figure 1. By entering the mn command directly into the Mininet network system, you can create a single-layer topology network in which two host and one switch are created by default, and the controller and switch are activated. At the same time, you can also view the link through the command net. First, simply list the examples, such as enabling the Web server and client in the Mininet system. # mn*** Creating network*** Adding controller*** Adding hosts:h2 h3customers * Adding switches:s1*** Adding links: (H2, S1) (h3, S1) * Configuring hostsh2 h3clients * Starting controller*** Starting 1 switchess1*** Starting CLI:mininet >
Enable and disable Web service mininet > H2 python-m SimpleHTTPServer 80 & # enable Web service on host H2 mininet > h3 wget-O-H2 # host h3 download H2 web site content-2013-11-04 00 SimpleHTTPServer 05mininet-http://10.0.0.1/Connecting to 10.0.0.180. Connected.HTTP request sent, awaiting response... 200 OK. Length: 760 [text/html.bash_history.wireshark/install-mininet-vm.shmininet/of-dissector/oflops/oftest/openflow/pox/0K 1.65M=0s2013-11-04 00:05:40 (1.65 MB/s)-written to stdout [760 mininet] mininet > H2 kill% python # Kill web process 10.0.0.2-[04/Nov/2013 00:05:40] "GET / HTTP/1.1" 200-bash: line 23: kill : python: ambiguous job specPing test` on Mininet system Realize the interconnection test of two hosts. `mininet > H2 ping-c4 h3PING 10.0.0.2 (10.0.0.2) 56 (84) bytes of data.64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=1.55 ms64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.094 ms64 bytes from 10.0.0.2: icmp_req=3 ttl=64 time=0.075 ms64 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 3006msrtt min/avg/max/mdev = 0.071, 0.448, 1.553, 0.638 ms` * * View nodes and links * * `mininet > nodesavailable nodes are:c0 h2h3 s1mininet > neth2 h2-eth0:s1-eth2h3 h3-eth0:s1-eth3s1 lo: s1-eth2:h2-eth0 s1-eth3:h3-eth0c0 custom topology
Mininet supports custom topologies. 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 topology with the-topo option:
Figure 2. Custom topology exampl
Because Mininet also supports parameterized topology, you can also create a flexible topology through Python code, configure it according to the parameters passed in by custom, and reuse it in multiple environments. The following is a brief list of the general structure and meaning of the code. #! / usr/bin/python
#! / usr/bin/pythonfrom mininet.topo import Topofrom mininet.net import Mininetfrom mininet.util import dumpNodeConnectionsfrom mininet.log import setLogLevelclass SingleSwitchTopo (Topo): def _ init__ (self, name2, * * opts): Topo.__init__ (self, * * opts) switch = self.addSwitch ('s 1') # add a switch in the topology for h in range (n): host = self.addHost ('h% s'% (h + 1)) # add hosts 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 network net.start () # launch your topology network print "Dumping host connections" dumpNodeConnections (net.hosts) # rollover file connection print "Testing network connectivity" net.pingAll () # all nodes test interconnect net.stop () # stop your network if _ _ name__ = = '_ _ main__':setLogLevel (' info') # sets the Mininet default output level Setting up info will provide some useful information simpleTest () verifies the parameterized topology # python test-single.py*** Creating network*** Adding controller*** Adding hosts:h2 h3 h4 h5 topology * Adding switches:s1*** Adding links: (H2, S1) (h3, S1) (h4, S1) (h5) S1) * Configuring hostsh2 h3h4 h5 cycles * Starting controller*** Starting 1 switchess1Dumping host connectionsh2 h2-eth0:s1-eth2h3 h3-eth0:s1-eth3h4 h4-eth0:s1-eth4h5 h5-eth0:s1-eth5Testing network connectivity*** Ping: testing ping reachabilityh2-> h3h4 h5h3-> H2 h4 h5h4-> h2h3 h5h5-> h2h3 h4 cycles * Results: 0% dropped (12 received) namespace namespace
Typically, the host interface uses a separate namespace namespace, while both the control node and the swap node are in the root namespace (root namespace). If you want all nodes to have their own namespaces, you need to add the-innamespace parameter, that is, execute: mn-innamespace
# mn-- innamespace-- switch user*** Creating network*** Adding controller*** Adding hosts:h2 h3 cycles * Adding switches:s1*** Adding links: (H2, S1) (h3, S1) c0s1bands * Testing control networks1-> c0c0-> S1 cycles * Results: 0 dropped (2 received)
"
* Configuring hostsh2 h3 operations * Starting controller*** Starting 1 switchess1*** Starting CLI:*** Configuring hostsh2 h3 cycles * Starting controller*** Starting 1 switchess1*** Starting CLI:Mininet common operations
Table 1.Mininet common instructions
Name function nodes view all nodes net view link information dump output information of each node H2 ping-c 4 h3 test connectivity between hosts iperf between two nodes use specified simple TCP test iperfudp between two nodes use specified payment order udp to test noecho run interaction window, close response pingpair two hosts will pinghelp each other list command document View command help: help commanddpctl calls switch exit/quit to exit mininet command line hX ifconfig to check the ip address of the current host, such as H2 ifconfigpy/sh executing python expression or running external shell program
Thank you for reading! This is the end of the article on "how to get started with Mininet". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.