-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathof_simple_topo.py
50 lines (41 loc) · 1.31 KB
/
of_simple_topo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# Copyright 2012 William Yu
#
# Sample network for creating an OpenFlow Static Router.
#
# This is a demonstration file aims to build a simple static router.
# Network A (192.168.1.0/26)
# <--> Switch
# <--> Network B (192.168.1.64/26)
#
from mininet.net import Mininet
from mininet.node import Controller, OVSKernelSwitch, RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.util import createLink
def createStaticRouterNetwork():
info( '*** Creating network for Static Router Example\n' )
# Create an empty network.
net = Mininet(controller=RemoteController, switch=OVSKernelSwitch)
net.addController('c0')
# Creating nodes in the network.
h0 = net.addHost('h0')
s0 = net.addSwitch('s0')
h1 = net.addHost('h1')
# Creating links between nodes in network.
h0int, s0int = createLink(h0, s0)
h1int, s0int = createLink(h1, s0)
# Configuration of IP addresses in interfaces
h0.setIP(h0int, '192.168.1.2', 26)
h1.setIP(h1int, '192.168.1.66', 26)
info( '*** Network state:\n' )
for node in s0, h0, h1:
info( str( node ) + '\n' )
# Start command line
net.start()
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
createStaticRouterNetwork()