Fixed divide by 0 error in ping command when no packets are sent
fixes #143
This commit is contained in:
@@ -468,9 +468,13 @@ class Mininet( object ):
|
|||||||
lost += sent - received
|
lost += sent - received
|
||||||
output( ( '%s ' % dest.name ) if received else 'X ' )
|
output( ( '%s ' % dest.name ) if received else 'X ' )
|
||||||
output( '\n' )
|
output( '\n' )
|
||||||
|
if packets > 0:
|
||||||
ploss = 100 * lost / packets
|
ploss = 100 * lost / packets
|
||||||
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
|
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
|
||||||
( ploss, lost, packets ) )
|
( ploss, lost, packets ) )
|
||||||
|
else:
|
||||||
|
ploss = 0
|
||||||
|
output( "*** Warning: No packets sent\n" )
|
||||||
return ploss
|
return ploss
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user