blob: a2fe9fe072d45f20126b5783fa52310c2d5151e2 [file] [log] [blame]
GlennRCb3202c52015-08-24 14:43:30 -07001#!/usr/bin/python
2
3"""
4Custom topology for Mininet
5"""
6from mininet.topo import Topo
7from mininet.net import Mininet
8from mininet.node import Host, RemoteController
9from mininet.node import Node
10from mininet.link import TCLink
11from mininet.cli import CLI
12from mininet.log import setLogLevel
13from mininet.util import dumpNodeConnections
14from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
15
16class MyTopo( Topo ):
17
Jon Halle019baa2015-08-27 17:31:10 -070018 def __init__( self ):
19 # Initialize topology
20 Topo.__init__( self )
GlennRCb3202c52015-08-24 14:43:30 -070021
Jon Halle019baa2015-08-27 17:31:10 -070022 host1 = self.addHost('h1', ip='10.1.0.1/24')
23 host2 = self.addHost('h2', ip='10.1.0.2/24')
24 host3 = self.addHost('h3', ip='10.1.0.3/24')
GlennRCb3202c52015-08-24 14:43:30 -070025
Jon Halle019baa2015-08-27 17:31:10 -070026 s1 = self.addSwitch( 's1' )
27 s2 = self.addSwitch( 's2' )
28 s3 = self.addSwitch( 's3' )
GlennRCb3202c52015-08-24 14:43:30 -070029
Jon Halle019baa2015-08-27 17:31:10 -070030 self.addLink(s1, host1)
31 self.addLink(s2, host2)
32 self.addLink(s3, host3)
GlennRCb3202c52015-08-24 14:43:30 -070033
Jon Halle019baa2015-08-27 17:31:10 -070034 self.addLink(s1,s2)
35 self.addLink(s1,s3)
36 self.addLink(s2,s3)
GlennRCb3202c52015-08-24 14:43:30 -070037
Jon Halle019baa2015-08-27 17:31:10 -070038 topos = { 'mytopo': ( lambda: MyTopo() ) }
GlennRCb3202c52015-08-24 14:43:30 -070039
40# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
41
42def setupNetwork():
43 "Create network"
44 topo = MyTopo()
45 network = Mininet(topo=topo, autoSetMacs=True, controller=None)
46 network.start()
47 CLI( network )
48 network.stop()
49
50if __name__ == '__main__':
51 setLogLevel('info')
52 #setLogLevel('debug')
53 setupNetwork()