Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosts can't ping each other in a simple topology. #128

Open
TsinghuaDong opened this issue Oct 22, 2023 · 2 comments
Open

Hosts can't ping each other in a simple topology. #128

TsinghuaDong opened this issue Oct 22, 2023 · 2 comments

Comments

@TsinghuaDong
Copy link

TsinghuaDong commented Oct 22, 2023

Hello I am new to ipmininet. I tried a very simple topology, but the hosts can't successfully ping each other. I really need help, thank you!

#!/usr/bin/python3

import sys
import os
import getopt
import subprocess


from ipmininet.iptopo import IPTopo
from ipmininet.ipnet import IPNet
from ipmininet.cli import IPCLI
from ipmininet.topologydb import TopologyDB


class MyTopology(IPTopo):
    def __init__(self, *args, **kwargs):
        self.switch_count = 0
        super().__init__(*args, **kwargs)

    def build(self, *args, **kwargs):
        r1 = self.addRouter("r1")
        r2 = self.addRouter("r2")

        h1 = self.addHost("h1")
        h2 = self.addHost("h2")

        self.addLink(r1, r2)
        self.addLink(h1, r1)
        self.addLink(r2, h2)

        super().build(*args, **kwargs)

    def ping_all(self, net):
        h1 = net.get('h1')
        h2 = net.get('h2')
        h1.defaultIntf().updateIP6()
        h2.defaultIntf().updateIP6()
        print(h1.cmd("ping -c 3 "+ h2.defaultIntf().ip6))
        print(h2.cmd("ping -c 3 "+ h1.defaultIntf().ip6))



def main():
    exp = MyTopology()
    net = IPNet(topo=exp, use_v4=False, use_v6=True)

    db = TopologyDB(net=net)
    db_path = "topologydb.json"
    db.save(db_path)

    try:
        net.start()
        exp.ping_all(net)

    finally:
        net.stop()



if __name__ == '__main__':
    try:
        main()
    except:
        print("!"*80)
        print("Exception! Cleaning!")
        print("!"*80)
        import traceback
        traceback.print_exc()
        subprocess.call('sudo python3 -m ipmininet.clean', shell=True)
@TsinghuaDong
Copy link
Author

The results are:

PING fc00:0:2::2(fc00:0:2::2) 56 data bytes
From fc00:0:1::1 icmp_seq=1 Destination unreachable: No route
From fc00:0:1::1 icmp_seq=2 Destination unreachable: No route
From fc00:0:1::1 icmp_seq=3 Destination unreachable: No route

--- fc00:0:2::2 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2077ms

PING fc00:0:1::2(fc00:0:1::2) 56 data bytes
From fc00:0:2::1 icmp_seq=1 Destination unreachable: No route
From fc00:0:2::1 icmp_seq=2 Destination unreachable: No route
From fc00:0:2::1 icmp_seq=3 Destination unreachable: No route

--- fc00:0:1::2 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2027ms

(r1 exited - ignoring cmd('ip link del r1-eth1',))
(r1 exited - ignoring cmd('ip link del r1-eth0',))
(r2 exited - ignoring cmd('ip link del r2-eth0',))
(r2 exited - ignoring cmd('ip link del r2-eth1',))

@jadinm
Copy link
Collaborator

jadinm commented Oct 30, 2023

Thank you for reporting your issue :-)

I see that you are pinging directly the hosts but actually a OSPF and OSPF6 deamons are launched on the routers
These daemons could take several seconds before installing the routes.
net.start() finishes as soon as every daemon is started but not necessarily after ospf convergence.

Maybe it's best to test it yourself by opening the IPCLI(net) and run (https://ipmininet.readthedocs.io/en/latest/getting_started.html#network-run and https://ipmininet.readthedocs.io/en/latest/cli.html#command-line-interface).
There you can check on each router if the daemons ospf and ospf6 are indeed launched and after some time, that routing tables of r1 and r2 are correct or not :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants