Migrate ALTO user docs to rst
[docs.git] / manuals / user-guide / src / main / asciidoc / nic / NIC_redirect_test_topology.adoc
1 === Simple Mininet topology
2
3 [source,python]
4 ----
5 !/usr/bin/python
6
7 from mininet.topo import Topo
8
9 class SimpleTopology( Topo ):
10     "Simple topology example."
11
12     def __init__( self ):
13         "Create custom topo."
14
15         # <1>
16         Topo.__init__( self )
17
18         # <2>
19         Switch1 = self.addSwitch( 's1' )
20         Switch2 = self.addSwitch( 's2' )
21         Switch3 = self.addSwitch( 's3' )
22         Switch4 = self.addSwitch( 's4' )
23         Host11 = self.addHost( 'h1' )
24         Host12 = self.addHost( 'h2' )
25         Host21 = self.addHost( 'h3' )
26         Host22 = self.addHost( 'h4' )
27         Host23 = self.addHost( 'h5' )
28         Service1 = self.addHost( 'srvc1' ) # <3>
29
30         # <4>
31         self.addLink( Host11, Switch1 )
32         self.addLink( Host12, Switch1 )
33         self.addLink( Host21, Switch2 )
34         self.addLink( Host22, Switch2 )
35         self.addLink( Host23, Switch2 )
36         self.addLink( Switch1, Switch2 )
37         self.addLink( Switch2, Switch4 )
38         self.addLink( Switch4, Switch3 )
39         self.addLink( Switch3, Switch1 )
40         self.addLink( Switch3, Service1 )
41         self.addLink( Switch4, Service1 )
42
43
44 topos = { 'simpletopology': ( lambda: SimpleTopology() ) }
45 ----
46 <1> Initialize topology
47 <2> Add hosts and switches
48 <3> Host used to represent the service
49 <4> Add links
50
51 [quote]
52 Source: https://gist.github.com/vinothgithub15/315d0a427d5afc39f2d7