blob: 9f578551b92b1bb4552673d1537a8ce940d3fd67 [file] [log] [blame]
carlosmscabralf40ecd12013-02-01 18:15:58 -02001#!/usr/bin/python
2
3"""
4This example shows how to create an empty Mininet object
5(without a topology object) and add nodes to it manually.
6"""
7
8from mininet.net import Mininet
9from mininet.node import Controller
10from mininet.cli import CLI
11from mininet.log import setLogLevel, info
12
13def emptyNet():
14
15 "Create an empty network and add nodes to it."
16
17 net = Mininet( controller=Controller )
18
19 info( '*** Adding controller\n' )
20 net.addController( 'c0' )
21
22 info( '*** Adding hosts\n' )
23 h1 = net.addHost( 'h1', ip='10.0.0.1' )
24 h2 = net.addHost( 'h2', ip='10.0.0.2' )
25
26 info( '*** Adding switch\n' )
27 s3 = net.addSwitch( 's3' )
28
29 info( '*** Creating links\n' )
30 h1.linkTo( s3 )
31 h2.linkTo( s3 )
32
33 info( '*** Starting network\n')
34 net.start()
35
36 info( '*** Running CLI\n' )
37 CLI( net )
38
39 info( '*** Stopping network' )
40 net.stop()
41
42if __name__ == '__main__':
43 setLogLevel( 'info' )
44 emptyNet()