From 9a9624e7104a4c14ad2e3bac35085a5c3e707fa0 Mon Sep 17 00:00:00 2001 From: edoardocoli Date: Wed, 21 Jun 2023 16:02:09 +0200 Subject: [PATCH] setup mininet update --- MininetNetPractice.py | 21 ++++++++++++++---- MininetTopo.conf | 50 +++++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/MininetNetPractice.py b/MininetNetPractice.py index a994102..cfe1e1c 100644 --- a/MininetNetPractice.py +++ b/MininetNetPractice.py @@ -25,6 +25,23 @@ def build_topology(config_file): if line.startswith('#'): #Skip comment continue parts = line.split(" ") #Parse the topology file using spaces + if parts[0] == 'N_host': #Parse hosts + host_name = parts[1] + elements[host_name] = topo.addHost(host_name) + + elif parts[0] == 'N_router': #Parse routers + router_name = parts[1] + elements[router_name] = topo.addNode(router_name) + + elif parts[0] == 'N_switch': #Parse switches + switch_name = parts[1] + elements[switch_name] = topo.addSwitch(switch_name) + + elif parts[0] == 'NN_link': #Parse general links nodes to nodes + node1 = parts[1] + node2 = parts[2] + topo.addLink(elements.get(node1), elements.get(node2)) + if parts[0] == 'host': #Parse hosts host_name = parts[1] host_ip = parts[2] @@ -36,10 +53,6 @@ def build_topology(config_file): router_ip = parts[2] elements[router_name] = topo.addNode(router_name, cls=MyRouter, ip=router_ip) - elif parts[0] == 'switch': #Parse switches - switch_name = parts[1] - elements[switch_name] = topo.addSwitch(switch_name) - elif parts[0] == 'linkRR': #Parse links routers to routers router1 = parts[1] router1_intfName = parts[2] diff --git a/MininetTopo.conf b/MininetTopo.conf index 9ed35a1..1e935c9 100644 --- a/MininetTopo.conf +++ b/MininetTopo.conf @@ -1,35 +1,47 @@ ######### Set Network Nodes ######### +## N_host name ## ## host name intfIP/mask defRoute ## +## N_router name ## ## router name intfIP/mask ## -## switch name ## +## N_switch name ## ##################################### -host H4 161.46.247.131/26 161.46.247.129 -host H3 161.46.247.196/27 161.46.247.195 -router R1 161.46.247.254/30 -router R2 161.46.247.253/30 +# host H4 161.46.247.131/26 161.46.247.129 +# host H3 161.46.247.196/27 161.46.247.195 +# router R1 161.46.247.254/30 +# router R2 161.46.247.253/30 -# 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. +N_host h1 +N_host h2 +N_router r1 +N_router r2 +N_router r3 +N_switch s1 +N_switch s2 + +############################################ +## 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 ## +## NN_link node1, node2 ## ############################################################################################################ -linkRR R1 R13 161.46.247.254/30 R2 R21 161.46.247.253/30 -linkRH H3 H31 R2 R22 161.46.247.195/27 -linkRH H4 H41 R2 R23 161.46.247.129/26 -# linkRS -# linkRS -# linkSS s2 s1 -# linkSH S1 H1 H11 -# linkSH S1 H2 H21 +# linkRR R1 R13 161.46.247.254/30 R2 R21 161.46.247.253/30 +# linkRH H3 H31 R2 R22 161.46.247.195/27 +# linkRH H4 H41 R2 R23 161.46.247.129/26 +NN_link r1 s1 +NN_link r2 s2 +NN_link s1 s2 +NN_link h1 s1 +NN_link h2 s2 ################## 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 +# route R1 161.46.247.192/27 161.46.247.254 R13 +# route R1 161.46.247.128/26 161.46.247.254 R13