-
Notifications
You must be signed in to change notification settings - Fork 1
/
topology.py
34 lines (27 loc) · 953 Bytes
/
topology.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
# Network topology that will be used to test my firewall rules
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.cli import CLI
from mininet.node import RemoteController
class my_topo(Topo):
def build(self):
s1 = self.addSwitch('s1')
h1 = self.addHost('h1',mac='00:00:00:00:00:01',ip='10.0.1.10/24')
h2 = self.addHost('h2',mac='00:00:00:00:00:02',ip='10.0.1.20/24')
h3 = self.addHost('h3',mac='00:00:00:00:00:03',ip='10.0.1.30/24')
h4 = self.addHost('h4',mac='00:00:00:00:00:04',ip='10.0.1.40/24')
self.addLink(h1,s1)
self.addLink(h2,s1)
self.addLink(h3,s1)
self.addLink(h4,s1)
def configure():
topo = my_topo()
net = Mininet(topo=topo, controller=RemoteController)
net.start()
h1, h2, h3, h4 = net.get('h1', 'h2', 'h3', 'h4')
CLI(net)
net.stop()
if __name__ == '__main__':
configure()