blob: d74d4440acb763b29b718e6a43288ecf8e61a751 [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 Ronquillo23fb2162017-09-15 14:59:57 -07004Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07005
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070013 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070014
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"""
You Wangdb927a52016-02-26 11:03:28 -080023from mininet.topo import Topo
24from mininet.net import Mininet
25from mininet.node import Host, RemoteController
26from mininet.node import Node
27from mininet.node import CPULimitedHost
28from mininet.link import TCLink
29from mininet.cli import CLI
30from mininet.log import setLogLevel
31from mininet.util import dumpNodeConnections
32from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
33
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070034
You Wangdb927a52016-02-26 11:03:28 -080035class dualStackHost( Host ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070036
You Wangdb927a52016-02-26 11:03:28 -080037 def config( self, v6Addr='1000::1/64', **params ):
38 r = super( Host, self ).config( **params )
39 intf = self.defaultIntf()
40 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
41 return r
42
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070043
You Wangdb927a52016-02-26 11:03:28 -080044class tripleTopo( Topo ):
45
46 def __init__( self, **opts ):
47 "Create a topology."
48
49 # Initialize Topology
50 Topo.__init__( self, **opts )
51
52 s1 = self.addSwitch( 's1' )
53 s2 = self.addSwitch( 's2' )
54 s3 = self.addSwitch( 's3' )
55
56 # ... and now hosts
57 s1_host = self.addHost( 'h1', ip='10.1.0.1/24', cls=dualStackHost, v6Addr='1000::1/64' )
58 s2_host = self.addHost( 'h2', ip='10.1.0.2/24', cls=dualStackHost, v6Addr='1000::2/64' )
59 s3_host = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='1000::3/64' )
60
61 # add edges between switch and corresponding host
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070062 self.addLink( s1, s1_host )
63 self.addLink( s2, s2_host )
64 self.addLink( s3, s3_host )
65 self.addLink( s1, s2 )
66 self.addLink( s1, s3 )
67 self.addLink( s2, s3 )
You Wangdb927a52016-02-26 11:03:28 -080068
69topos = { 'triple': ( lambda: tripleTopo() ) }
70
71# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
72
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070073
You Wangdb927a52016-02-26 11:03:28 -080074def setupNetwork():
75 "Create network"
76 topo = tripleTopo()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070077 # if controller_ip == '':
78 # controller_ip = '10.0.2.2';
You Wangdb927a52016-02-26 11:03:28 -080079 # controller_ip = '127.0.0.1';
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070080 network = Mininet( topo=topo, switch=OVSSwitch, autoSetMacs=True, controller=None )
You Wangdb927a52016-02-26 11:03:28 -080081 network.start()
82 CLI( network )
83 network.stop()
84
85if __name__ == '__main__':
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070086 setLogLevel( 'info' )
87 # setLogLevel( 'debug' )
You Wangdb927a52016-02-26 11:03:28 -080088 setupNetwork()