Fixed divide by 0 error in ping command when no packets are sent

fixes #143
This commit is contained in:
Brian O'Connor
2013-07-11 11:17:46 -07:00
parent adf391fdec
commit c188bee3e3
+6 -2
View File
@@ -468,9 +468,13 @@ class Mininet( object ):
lost += sent - received
output( ( '%s ' % dest.name ) if received else 'X ' )
output( '\n' )
if packets > 0:
ploss = 100 * lost / packets
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
( ploss, lost, packets ) )
output( "*** Results: %i%% dropped (%d/%d lost)\n" %
( ploss, lost, packets ) )
else:
ploss = 0
output( "*** Warning: No packets sent\n" )
return ploss
@staticmethod