ben
ben

Reputation: 1

Problem with static routes for 3 node mesh network in mininet

3 node mesh network diagram image

I have the above network in mininet. The command pingall in the mininet cli has the following output:

mininet> pingall
*** Ping: testing ping reachability
rA -> rB X hA hB X 
rB -> rA rC hA hB hC 
rC -> X rB X hB hC 
hA -> rA rB rC hB hC 
hB -> rA rB rC hA hC 
hC -> rA rB rC hA hB 
*** Results: 13% dropped (26/30 received)

This is suggesting to me that the static routes between router A and router C aren't working.

Here are each router's forwarding table:

Router A:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.1.0        0.0.0.0         255.255.255.0   U     0      0        0 rA-eth0
10.0.2.0        10.0.255.253    255.255.255.0   UG    0      0        0 rA-eth1
10.0.3.0        10.0.255.253    255.255.255.0   UG    0      0        0 rA-eth1
10.0.255.0      0.0.0.0         255.255.255.0   U     0      0        0 rA-eth1
Router B:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.1.0        10.0.255.254    255.255.255.0   UG    0      0        0 rB-eth1
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 rB-eth0
10.0.3.0        10.0.254.253    255.255.255.0   UG    0      0        0 rB-eth2
10.0.254.0      0.0.0.0         255.255.255.0   U     0      0        0 rB-eth2
10.0.255.0      0.0.0.0         255.255.255.0   U     0      0        0 rB-eth1
Router C:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.1.0        10.0.254.254    255.255.255.0   UG    0      0        0 rC-eth1
10.0.2.0        10.0.254.254    255.255.255.0   UG    0      0        0 rC-eth1
10.0.3.0        0.0.0.0         255.255.255.0   U     0      0        0 rC-eth0
10.0.254.0      0.0.0.0         255.255.255.0   U     0      0        0 rC-eth1

And the forwarding table for each host is just to that hosts router as the default route.

And finally, here is my code which makes the network and sets up the static routes:

def setup_network():
    net = Mininet(controller=None, link=TCLink)
    
    # Create routers
    routerA = net.addHost('rA', ip='10.0.1.254/24')
    routerB = net.addHost('rB', ip='10.0.2.254/24')
    routerC = net.addHost('rC', ip='10.0.3.254/24')
    
    # Create hosts
    hostA = net.addHost('hA', ip='10.0.1.1/24')
    hostB = net.addHost('hB', ip='10.0.2.1/24')
    hostC = net.addHost('hC', ip='10.0.3.1/24')
    
    # Add links between routers and hosts
    net.addLink(hostA, routerA, intfName1='hA-eth0', intfName2='rA-eth0')
    net.addLink(routerA, routerB, intfName1='rA-eth1', intfName2='rB-eth1')
    net.addLink(routerB, hostB, intfName1='rB-eth0', intfName2='hB-eth0')
    net.addLink(routerB, routerC, intfName1='rB-eth2', intfName2='rC-eth1')
    net.addLink(routerC, hostC, intfName1='rC-eth0', intfName2='hC-eth0')
    
    # Start the network
    net.start()

    routerA.cmd('sysctl net.ipv4.ip_forward=1')
    routerB.cmd('sysctl net.ipv4.ip_forward=1')
    routerC.cmd('sysctl net.ipv4.ip_forward=1')
    
    # Configure routers with IP addresses
    routerA.cmd('ifconfig rA-eth0 10.0.1.254/24 up')
    routerA.cmd('ifconfig rA-eth1 10.0.255.254/24 up')
    routerB.cmd('ifconfig rB-eth0 10.0.2.254/24 up')
    routerB.cmd('ifconfig rB-eth1 10.0.255.253/24 up')
    routerB.cmd('ifconfig rB-eth2 10.0.254.254/24 up')
    routerC.cmd('ifconfig rC-eth0 10.0.3.254/24 up')
    routerC.cmd('ifconfig rC-eth1 10.0.254.253/24 up')

    # configure hosts with IP addresses
    hostA.cmd('ifconfig hA-eth0 10.0.1.1/24 up')
    hostB.cmd('ifconfig hB-eth0 10.0.2.1/24 up')
    hostC.cmd('ifconfig hC-eth0 10.0.3.1/24 up')
    
    # format of ip route add:
    # ip route ad <dest> via <nexthop/interface on next hop> dev <what interface to go out of to get to next hop>

    # Configure static routes on routers
    routerA.cmd('ip route add 10.0.2.0/24 via 10.0.255.253 dev rA-eth1')
    routerA.cmd('ip route add 10.0.3.0/24 via 10.0.255.253 dev rA-eth1')
    routerB.cmd('ip route add 10.0.1.0/24 via 10.0.255.254 dev rB-eth1')
    routerB.cmd('ip route add 10.0.3.0/24 via 10.0.254.253 dev rB-eth2')
    routerC.cmd('ip route add 10.0.1.0/24 via 10.0.254.254 dev rC-eth1')
    routerC.cmd('ip route add 10.0.2.0/24 via 10.0.254.254 dev rC-eth1')

    # Configure static routes on hosts
    # by default always go to the node's router
    hostA.cmd('ip route add default via 10.0.1.254 dev hA-eth0')
    hostB.cmd('ip route add default via 10.0.2.254 dev hB-eth0')
    hostC.cmd('ip route add default via 10.0.3.254 dev hC-eth0')
    
    # Open Mininet CLI
    CLI(net)
    
    # Stop the network
    net.stop()

if __name__ == '__main__':
    setup_network()

I've been setting up interfaces and static routes manually, which is very tedious even with 3 nodes. After I've fixed this problem, are there any algorithms for creating the interfaces and nodes for a mesh network if I just have a node adjacency list as input? If not an algorithm, any existing pieces of code to look at?

Upvotes: 0

Views: 52

Answers (0)

Related Questions