You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 2 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 3 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 4 | Copyright 2016 Open Networking Foundation (ONF) |
| 5 | |
| 6 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 7 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 8 | or 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 Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 22 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 23 | |
You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 24 | from mininet.topo import Topo |
| 25 | from mininet.net import Mininet |
| 26 | from mininet.node import Host, RemoteController |
| 27 | from mininet.node import Node |
| 28 | from mininet.node import CPULimitedHost |
| 29 | from mininet.link import TCLink |
| 30 | from mininet.cli import CLI |
| 31 | from mininet.log import setLogLevel |
| 32 | from mininet.util import dumpNodeConnections |
| 33 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 34 | |
| 35 | class 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 | |
| 42 | class 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 | |
| 67 | topos = { 'triple': ( lambda: tripleTopo() ) } |
| 68 | |
| 69 | # HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS |
| 70 | |
| 71 | def 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 | |
| 82 | if __name__ == '__main__': |
| 83 | setLogLevel('info') |
| 84 | #setLogLevel('debug') |
| 85 | setupNetwork() |