blob: 9b833910e32c37274a40d7755efcc39b877cd767 [file] [log] [blame]
You Wangdb927a52016-02-26 11:03:28 -08001#!/usr/bin/python
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002
You Wangdb927a52016-02-26 11:03:28 -08003"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07004Copyright 2016 Open Networking Foundation (ONF)
5
6Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
7the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
8or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
9
10 TestON is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 2 of the License, or
13 (at your option) any later version.
14
15 TestON is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with TestON. If not, see <http://www.gnu.org/licenses/>.
You Wangdb927a52016-02-26 11:03:28 -080022"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070023
You Wangdb927a52016-02-26 11:03:28 -080024from mininet.topo import Topo
25from mininet.net import Mininet
26from mininet.node import Host, RemoteController
27from mininet.node import Node
28from mininet.node import CPULimitedHost
29from mininet.link import TCLink
30from mininet.cli import CLI
31from mininet.log import setLogLevel
32from mininet.util import dumpNodeConnections
33from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
34
35class dualStackHost( Host ):
36 def config( self, v6Addr='1000::1/64', **params ):
37 r = super( Host, self ).config( **params )
38 intf = self.defaultIntf()
39 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
40 return r
41
42class tripleTopo( Topo ):
43
44 def __init__( self, **opts ):
45 "Create a topology."
46
47 # Initialize Topology
48 Topo.__init__( self, **opts )
49
50 s1 = self.addSwitch( 's1' )
51 s2 = self.addSwitch( 's2' )
52 s3 = self.addSwitch( 's3' )
53
54 # ... and now hosts
55 s1_host = self.addHost( 'h1', ip='10.1.0.1/24', cls=dualStackHost, v6Addr='1000::1/64' )
56 s2_host = self.addHost( 'h2', ip='10.1.0.2/24', cls=dualStackHost, v6Addr='1000::2/64' )
57 s3_host = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='1000::3/64' )
58
59 # add edges between switch and corresponding host
60 self.addLink( s1 , s1_host )
61 self.addLink( s2 , s2_host )
62 self.addLink( s3 , s3_host )
63 self.addLink(s1, s2)
64 self.addLink(s1, s3)
65 self.addLink(s2, s3)
66
67topos = { 'triple': ( lambda: tripleTopo() ) }
68
69# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
70
71def setupNetwork():
72 "Create network"
73 topo = tripleTopo()
74 #if controller_ip == '':
75 #controller_ip = '10.0.2.2';
76 # controller_ip = '127.0.0.1';
77 network = Mininet(topo=topo, switch=OVSSwitch, autoSetMacs=True, controller=None)
78 network.start()
79 CLI( network )
80 network.stop()
81
82if __name__ == '__main__':
83 setLogLevel('info')
84 #setLogLevel('debug')
85 setupNetwork()