From 1ab82727ce79c6fabb182d71dad16a0c620893b1 Mon Sep 17 00:00:00 2001 From: Brian O'Connor Date: Tue, 1 Mar 2016 13:32:24 -0800 Subject: [PATCH] Adding example to gratuitiously ARP from all hosts --- examples/arping.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 examples/arping.py diff --git a/examples/arping.py b/examples/arping.py new file mode 100755 index 00000000..4c322102 --- /dev/null +++ b/examples/arping.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +""" +Create a simple, star topology and gratuitiously ARP from each host, +which may aid in a network controller's host discovery. However, these +ARPs will not populate the ARP tables of the other hosts. + +This can also be done from the Mininet CLI: +mininet> py [ h.cmd('arping -U -c 1 ' + h.IP()) for h in net.hosts ] +""" + +from mininet.log import setLogLevel +from mininet.util import quietRun +from mininet.log import error +from mininet.cli import CLI +from mininet.net import Mininet +from mininet.topo import SingleSwitchTopo + +if __name__ == '__main__': + + if not quietRun( 'which arping' ): + error( "Cannot find command 'arping'\nThe package", + "'iputils-arping' is required in Ubuntu or Debian\n" ) + exit() + + setLogLevel( 'info' ) + + net = Mininet( topo=SingleSwitchTopo( k=10 ), waitConnected=True ) + net.start() + + for host in net.hosts: + print host + print host.cmd( 'arping -U -c 1 ' + host.IP() ) + + CLI( net ) + net.stop()