-
Notifications
You must be signed in to change notification settings - Fork 1
/
flownet2.py~
115 lines (78 loc) · 3.13 KB
/
flownet2.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/python
"""
This example shows how to create an empty Mininet object
(without a topology object) and add nodes to it manually.
"""
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.log import setLogLevel, info
import time
import json
import os
import socket
import Parse
def MudNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=Controller )
info( '*** Adding controller\n' )
net.addController( 'c0' )
info( '*** Adding MUD Architecture Blocks\n' )
hrs = net.addHost( 'RadServer', ip='192.168.0.11' )
hms = net.addHost( 'MUDServer', ip='192.168.0.12' )
hrc = net.addHost( 'RadClient', ip='192.168.0.2', mac = '00:00:00:00:00:02' )
h1 = net.addHost( 'h1', ip='192.168.0.1', mac = '00:00:00:00:00:01' ) #Desktop connected to home network
#h2 = net.addHost( 'h2', ip='192.168.0.2', mac = '00:00:00:00:00:02' ) #IoT Device LED Light connected to home network
h3 = net.addHost( 'h3', ip='', mac ='00:00:00:00:00:03' ) ####### IP address allowed for communication
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's3' )
s4 = net.addSwitch( 's4' )
info( '*** Creating links\n' )
net.addLink( hrs, s3 )
net.addLink( hms, s3 )
net.addLink( hrc, s3 )
#net.addLink( h1, s4 )
#net.addLink( h2, s4 )
#net.addLink( h3, s4 )
info( '*** Starting network\n')
net.start()
#hrs.cmdPrint('sudo radiusd -X > radbug.txt 2>&1 &')
#hrs.cmd('sleep 15')
#hms.cmdPrint('python -m SimpleHTTPServer 80 &')
#hms.cmd('sleep 5')
#hrc.cmdPrint('sudo echo "User-Name=Merkle, User-Password=MUDinmud, Cisco-MUD-URI=http://10.0.0.2/mud/lighting-example.json" | /usr/local/bin/radclient -x 10.0.0.1 auth testingMUD')
#s3.cmdPrint('ifconfig')
#net.stop()
os.system("sleep 2")
################################################################################
#x,y = Parse.ACL()
#print('Inbound access entry: '+str(x))
print('////////////////////////')
#print('Outbound access entry: '+str(y))
net.get('h3').cmd('ifconfig h3-eth0 128.59.105.24')
net.delNode(hrs)
net.delNode(hms)
net.get('h1').cmd('ifconfig h1-eth0 192.168.0.1')
net.addLink(s4, net.get('h1'))
s4.attach('s4-eth0')
net.addLink(s4,s3)
s4.attach('s4-eth1')
s3.attach('s3-eth4')
net.addLink(s4, net.get('h3'))
s4.attach('s4-eth2')
h3.cmdPrint('route add default gw 128.59.105.254 h3-eth0')
h3.cmdPrint('arp -s 128.59.105.254 00:00:00:00:33:33')
h1.cmdPrint('route add default gw 192.168.0.254 h1-eth0')
h1.cmdPrint('arp -s 192.168.0.254 00:00:00:00:00:11:11')
s3.cmdPrint('route add default gw 192.168.0.254 h2-eth0')
s3.cmdPrint('arp -s 192.168.0.254 00:00:00:00:00:11:11')
h3.cmdPrint('sudo python -m SimpleHTTPServer 80 &')
#os.system("more tables.txt")
os.system("ovs-ofctl add-flows s4 tables.txt")
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stoping network' )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
MudNet()