+
+def include_timestamps_zero_packets(timefreq):
+ """ Include every second that has zero packets (no packets/transmission)
+ Args:
+ timefreq = dictionary that maps timestamps to number of packets
+ """
+ sortedkeylist = []
+ for key in sorted(timefreq):
+ sortedkeylist.append(key)
+ first = sortedkeylist[0]
+ last = sortedkeylist[len(sortedkeylist)-1]
+ # Calculate the number of seconds between first and last packets
+ first_seconds = hms_to_seconds(first)
+ last_seconds = hms_to_seconds(last)
+ seconds = last_seconds - first_seconds
+ # Start counting and filling in timestamps with zero packets
+ counter = 0
+ while counter < seconds:
+ timestamp = seconds_to_hms(first_seconds + counter)
+ if timestamp not in timefreq:
+ timefreq[timestamp] = 0
+ counter += 1
+ return timefreq
+