Mininet-4
In our last blog, we added a new H4 and opened the hub function
s0.cmd("brctl setageing br0 0")
#!/usr/bin/env pythonfrom mininet.cli Import clifrom mininet.net import mininetfrom mininet.link import Link,TCLinkif ' __ main__ ' = = __name__: Net = mininet (link=tclink) h1 = Net.addhost (' H1 ', ip= "192.168.10.1/24", mac= "00:00:00:00:00:01") H2 = Net.addhost (' H2 ', ip= "192.168.10.2/24", mac= "00:00:00:00:00:02") h3 = Net.addhost (' h3 ', ip= "192.168.20.1/24", mac= " 00:00:00:00:00:03 ") h4 = Net.addhost (' h4 ', ip=" 192.168.10.3/24 ", mac=" 00:00:00:00:00:04 ") R0 = Net.addhost (' r0 ') S0 = Net . Addhost (' S0 ') Net.addlink (H1, S0) Net.addlink (H2, S0) Net.addlink (S0, R0) Net.addlink (R0, H3) Net.addlink (S0, H4) Net.bu ILD () R0.cmd ("Echo 1 >/proc/sys/net/ipv4/ip_forward") r0.cmd (' ifconfig r0-eth0 192.168.10.254 netmask 255.255.255.0 ') r0.cmd (' ifconfig r0-eth1 192.168.20.254 netmask 255.255.255.0 ') h1.cmd ("IP route add default via 192.168.10.254 Dev h1- Eth0 ") h2.cmd (" IP rotue add default via 192.168.10.254 dev H2-eth0 ") h3.cmd (" IP route add default via 192.168.20.254 Dev H 3-eth0 ") h4.cmd (" IP route add defauLt via 192.168.10.254 Dev H4-eth0 ") s0.cmd (" Brctl addbr br0 ") s0.cmd (" Brctl addif br0 s0-eth0 ") s0.cmd (" Brctl addif br0 S0 -eth1 ") s0.cmd (" Brctl addif br0 s0-eth2 ") s0.cmd (" Brctl addif br0 s0-eth3 ") s0.cmd (" Brctl setageing br0 0 ") s0.cmd (" ifconf IG br0 up ") CLI (NET) net.stop ()
Mininet (lightweight software defined network and test platform) four