Mininet Update

edoardoColi
edoardocoli 1 year ago
parent 6ad1ef7dde
commit 6b5870a48c

@ -19,7 +19,6 @@ def build_topology(config_file):
topo = Topo() topo = Topo()
elements = {} # Dictionary to store nodes elements = {} # Dictionary to store nodes
# elements['Internet'] = topo.addNode('Internet', cls=MyRouter, ip='0.0.0.0/0')
with open(config_file, 'r') as file: with open(config_file, 'r') as file:
for line in file: for line in file:
line = line.strip() line = line.strip()

@ -22,18 +22,22 @@ def build_topology(config_file):
# h1 = topo.addHost('H1', ip='161.46.247.2/25', defaultRoute='via 161.46.247.1') # h1 = topo.addHost('H1', ip='161.46.247.2/25', defaultRoute='via 161.46.247.1')
# h2 = topo.addHost('H2', ip='161.46.247.3/25', defaultRoute='via 161.46.247.1') # h2 = topo.addHost('H2', ip='161.46.247.3/25', defaultRoute='via 161.46.247.1')
s1 = topo.addSwitch('S1') r0 = topo.addNode('R0', cls=MyRouter, ip='163.172.250.12/16')
r1 = topo.addNode('R1', cls=MyRouter, ip='163.172.250.12/28')
r2 = topo.addNode('R2', cls=MyRouter, ip='161.46.247.253/30')
topo.addLink(r0, r1, intfName2='R12', intfName1='R01', params2={'ip' : '163.172.250.12/28'}, params1={'ip' : '163.172.250.12/16'})
topo.addLink(r2, r1, intfName2='R13', intfName1='R21', params2={'ip' : '161.46.247.254/30'}, params1={'ip' : '161.46.247.253/30'})
# s1 = topo.addSwitch('S1')
# h4 = topo.addHost('H4', ip='161.46.247.131/26', defaultRoute='via 161.46.247.129') # h4 = topo.addHost('H4', ip='161.46.247.131/26', defaultRoute='via 161.46.247.129')
# h3 = topo.addHost('H3', ip='161.46.247.196/27', defaultRoute='via 161.46.247.195') # h3 = topo.addHost('H3', ip='161.46.247.196/27', defaultRoute='via 161.46.247.195')
r1 = topo.addNode('R1', cls=MyRouter, ip='161.46.247.1/25')
r2 = topo.addNode('R2', cls=MyRouter, ip='161.46.247.253/30')
### Ordine importante ### ### Ordine importante ###
topo.addLink(r1, s1, intfName1='R11', params1={'ip' : '161.46.247.1/25'})
topo.addLink(r2, r1, intfName2='R13', intfName1='R21', params2={'ip' : '161.46.247.254/30'}, params1={'ip' : '161.46.247.253/30'}) # topo.addLink(r1, s1, intfName1='R11', params1={'ip' : '161.46.247.1/25'})
# topo.addLink(r2, h3, intfName2='H31', intfName1='R22', params1={'ip' : '161.46.247.195/27'}) # topo.addLink(r2, h3, intfName2='H31', intfName1='R22', params1={'ip' : '161.46.247.195/27'})
# topo.addLink(r2, h4, intfName2='H41', intfName1='R23', params1={'ip' : '161.46.247.129/26'}) # topo.addLink(r2, h4, intfName2='H41', intfName1='R23', params1={'ip' : '161.46.247.129/26'})
@ -50,6 +54,9 @@ def run_topology(config_file):
net = Mininet(topo=topo, link=TCLink) net = Mininet(topo=topo, link=TCLink)
net.start() #Starting the network net.start() #Starting the network
(net.getNodeByName('R1')).cmd('ip route add default via 161.172.250.1/26')
(net.getNodeByName('R1')).cmd('ip route add 161.46.247.128/27 via 161.46.247.253')
# (net.getNodeByName('R1')).cmd('ip route add 161.46.247.192/27 via 161.46.247.254 dev R13') # (net.getNodeByName('R1')).cmd('ip route add 161.46.247.192/27 via 161.46.247.254 dev R13')
# (net.getNodeByName('R1')).cmd('ip route add 161.46.247.128/26 via 161.46.247.254 dev R13') # (net.getNodeByName('R1')).cmd('ip route add 161.46.247.128/26 via 161.46.247.254 dev R13')

@ -1,54 +1,35 @@
# L'ordine deve rimanee questo ######### Set Network Nodes #########
## host name intfIP/mask defRoute ##
############# Set hosts ############# ## router name intfIP/mask ##
## host name intfIP/mask defRoute ### ## switch name ##
##################################### #####################################
host H4 161.46.247.131/26 161.46.247.129 host H4 161.46.247.131/26 161.46.247.129
host H3 161.46.247.196/27 161.46.247.195 host H3 161.46.247.196/27 161.46.247.195
######## Set routers ########
## router name intfIP/mask ##
#############################
router R1 161.46.247.254/30 router R1 161.46.247.254/30
router R2 161.46.247.253/30 router R2 161.46.247.253/30
## Set switches ## # The interface details defined inside
## switch name ## # the node during its creation must be
################## # reused in the links before new
# switch s1 # interfaces can be defined for the node.
# switch s2 ############################################# Set Network Links ############################################
#l'interfaccia con cui creo il ruter deve essere la aprima su cui faccio il link
################################################ Set links ################################################
## linkRR router1, router1_intfName, router1_intfIP/mask, router2, router2_intfName, router2_intfIP/mask ## ## linkRR router1, router1_intfName, router1_intfIP/mask, router2, router2_intfName, router2_intfIP/mask ##
########################################################################################################### ## linkRH host, host_intfName, router, router_intfName, router_intfIP/mask ##
## linkRS ##
## linkSS switch1, switch2 ##
## linkSH switch, host ,host_intfName ##
############################################################################################################
linkRR R1 R13 161.46.247.254/30 R2 R21 161.46.247.253/30 linkRR R1 R13 161.46.247.254/30 R2 R21 161.46.247.253/30
######################## Set links and router interfaces #####################
## linkRH host, host_intfName, router, router_intfName, router_intfIP/mask ###
##############################################################################
linkRH H3 H31 R2 R22 161.46.247.195/27 linkRH H3 H31 R2 R22 161.46.247.195/27
linkRH H4 H41 R2 R23 161.46.247.129/26 linkRH H4 H41 R2 R23 161.46.247.129/26
##################### Set links and router interfaces #####################
## linkRS ##
#####################################################
# linkRS # linkRS
# linkRS # linkRS
###### Set links ######
## linkSS switch1, switch2 ##
######################
# linkSS s2 s1 # linkSS s2 s1
############### Set links ###############
## linkSH switch, host ,host_intfName ###
#########################################
# linkSH S1 H1 H11 # linkSH S1 H1 H11
# linkSH S1 H2 H21 # linkSH S1 H2 H21
################## route table ################ ################## Route Table ################
## route name final_destIP/mask nextHop intf ### ## route name final_destIP/mask nextHop intf ##
################################################ ###############################################
route R1 161.46.247.192/27 161.46.247.254 R13 route R1 161.46.247.192/27 161.46.247.254 R13
route R1 161.46.247.128/26 161.46.247.254 R13 route R1 161.46.247.128/26 161.46.247.254 R13

Loading…
Cancel
Save