Skip to content

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

@TsinghuaDong

Description

@TsinghuaDong

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions