Browse Source

Fixes invalid CountingMetric, if no Packets were captured

* min>max print out was replaced by "No Packets were sent."
Andreas T. Meyer-Berg 5 years ago
parent
commit
185eb6f654
1 changed files with 4 additions and 2 deletions
  1. 4 2
      examples/CountingMetric.java

+ 4 - 2
examples/CountingMetric.java

@@ -117,8 +117,10 @@ public class CountingMetric implements PacketSniffer {
 				System.out.println(unknownPackets+ "("+Math.round(unknownPackets*100.0/packets.size())+"%) of them were unknwon packets");
 			}
 		}
-		
-		System.out.println("First packet was captured at "+minTime+" ms, and the last at "+maxTime+" ms.");
+		if(min<=max)
+			System.out.println("First packet was captured at "+minTime+" ms, and the last at "+maxTime+" ms.");
+		else
+			System.out.println("No packets were captured.");
 		//Print the number of packets per connection
 		for (Entry<SmartDevice, HashMap<SmartDevice, Integer>>  e: connections.entrySet()) {
 			String src = e.getKey() == null || e.getKey().getName()==null ? "null":e.getKey().getName();