blob: 14e28e54e68d4c0f33bfc577baa35d3f895221fb [file] [log] [blame]
kavitha Alagesan373e0552016-11-22 05:22:05 +05301#!/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.node import CPULimitedHost
11from mininet.link import TCLink
12from mininet.cli import CLI
13from mininet.log import setLogLevel
14from mininet.util import dumpNodeConnections
15from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
16
17class MyTopo( Topo ):
18
19 def __init__( self, **opts ):
20 # Initialize topology
21 Topo.__init__( self, **opts)
22
23 # IPv4 hosts
24 host1=self.addHost( 'h1', ip='10.0.0.1/24' )
25 host2=self.addHost( 'h2', ip='10.0.0.2/24' )
26 host3=self.addHost( 'h3', ip='10.0.0.3/24' )
27 host4=self.addHost( 'h4', ip='10.0.0.4/24' )
28
29 s1 = self.addSwitch( 's1' )
30
31 self.addLink(s1, host1)
32 self.addLink(s1, host2)
33 self.addLink(s1, host3)
34 self.addLink(s1, host4)
35
36 topos = { 'mytopo': ( lambda: MyTopo() ) }
37
38def setupNetwork():
39 "Create network"
40 topo = MyTopo()
41 network = Mininet(topo=topo, autoSetMacs=True, autoStaticArp=True, controller=None)
42 network.start()
43 CLI( network )
44 network.stop()
45
46if __name__ == '__main__':
47 setLogLevel('info')
48 #setLogLevel('debug')
49 setupNetwork()