diff --git a/MininetNetPractice.py b/MininetNetPractice.py index 3a2acbf..a994102 100644 --- a/MininetNetPractice.py +++ b/MininetNetPractice.py @@ -19,7 +19,6 @@ def build_topology(config_file): topo = Topo() 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: for line in file: line = line.strip() diff --git a/MininetTEST.py b/MininetTEST.py index 97055f1..71c4e47 100644 --- a/MininetTEST.py +++ b/MininetTEST.py @@ -22,19 +22,23 @@ def build_topology(config_file): # 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') - 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') # 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 ### - 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, 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.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.128/26 via 161.46.247.254 dev R13') diff --git a/MininetTopo.conf b/MininetTopo.conf index 45ad859..9ed35a1 100644 --- a/MininetTopo.conf +++ b/MininetTopo.conf @@ -1,54 +1,35 @@ -# L'ordine deve rimanee questo - -############# Set hosts ############# -## host name intfIP/mask defRoute ### +######### Set Network Nodes ######### +## host name intfIP/mask defRoute ## +## router name intfIP/mask ## +## switch name ## ##################################### host H4 161.46.247.131/26 161.46.247.129 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 R2 161.46.247.253/30 -## Set switches ## -## switch name ## -################## -# switch s1 -# switch s2 - -#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 ## -########################################################################################################### +# The interface details defined inside +# the node during its creation must be +# reused in the links before new +# interfaces can be defined for the node. +############################################# Set Network Links ############################################ +## 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 - -######################## 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 H4 H41 R2 R23 161.46.247.129/26 - -##################### Set links and router interfaces ##################### -## linkRS ## -##################################################### # linkRS # linkRS - -###### Set links ###### -## linkSS switch1, switch2 ## -###################### # linkSS s2 s1 - -############### Set links ############### -## linkSH switch, host ,host_intfName ### -######################################### # linkSH S1 H1 H11 # linkSH S1 H2 H21 -################## route table ################ -## route name final_destIP/mask nextHop intf ### -################################################ +################## Route Table ################ +## route name final_destIP/mask nextHop intf ## +############################################### route R1 161.46.247.192/27 161.46.247.254 R13 route R1 161.46.247.128/26 161.46.247.254 R13