def mobilityTest():
 info('* Simple mobility test\n')
 net = Mininet(topo=LinearTopo(3), switch=MobilitySwitch)
 info('* Starting network:\n')
 net.start()
 printConnections(net.switches)
 info('* Testing network\n')
 net.pingAll()
 info('* Identifying switch interface for h1\n')
 (h1, old) = net.get('h1', 's1')
 for s in (2, 3, 1):
  new = net[('s%d' % s)]
  port = randint(10, 20)
  info('* Moving', h1, 'from', old, 'to', new, 'port', port, '\n')
  (hintf, sintf) = moveHost(h1, old, new, newPort=port)
  info('*', hintf, 'is now connected to', sintf, '\n')
  info('* Clearing out old flows\n')
  for sw in net.switches:
   sw.dpctl('del-flows')
  info('* New network:\n')
  printConnections(net.switches)
  info('* Testing connectivity:\n')
  net.pingAll()
  old = new
 net.stop()

def mobilityTest ( ) : info ( '* Simple mobility test\n' ) net = Mininet ( topo = LinearTopo ( 3 ) , switch = MobilitySwitch ) info ( '* Starting network:\n' ) net . start ( ) printConnections ( net . switches ) info ( '* Testing network\n' ) net . pingAll ( ) info ( '* Identifying switch interface for h1\n' ) ( h1 , old ) = net . get ( 'h1' , 's1' ) for s in ( 2 , 3 , 1 ) : new = net [ ( 's%d' % s ) ] port = randint ( 10 , 20 ) info ( '* Moving' , h1 , 'from' , old , 'to' , new , 'port' , port , '\n' ) ( hintf , sintf ) = moveHost ( h1 , old , new , newPort = port ) info ( '*' , hintf , 'is now connected to' , sintf , '\n' ) info ( '* Clearing out old flows\n' ) for sw in net . switches : sw . dpctl ( 'del-flows' ) info ( '* New network:\n' ) printConnections ( net . switches ) info ( '* Testing connectivity:\n' ) net . pingAll ( ) old = new net . stop ( )
a simple test of mobility .