Time to live is defined as "Time to live (TTL) refers to the amount of time or “hops” that a packet is set to exist inside a network before being discarded by a router. TTL is also used in other contexts including CDN caching and DNS caching."
I'm attempting to model the ideal TTL that will enable most packets to exist before being discarded by the router.
Taking a sample of the amount of time each packet exists in seconds results in the following dataset : {1,2,3,4,2,5,6,7,8,9}
The bin sizes I set are : {3,5,10}
I expect to extract the following output
3 -> {1,2,3}
5 -> {1,2,3,4,5}
From the above I deduce
Setting a TTL of 3 seconds will result in packets {4,5,6,7,8,9} being discarded.
Setting a TTL of 5 seconds will result in packets {5,6,7,8,9} being discarded.
Is my logic correct ?
Converting this logic to Jupyter notebook code results in :
%reset -f
import datetime
import json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
packet_exist_times = [1,2,3,4,2,5,6,7,8,9]
packet_times_bins = [3,5,10]
print(packet_exist_times)
hist, bins = np.histogram(packet_exist_times, bins = packet_times_bins)
print(hist)
print(bins)
which produces output :
[1, 2, 3, 4, 2, 5, 6, 7, 8, 9]
[2 5]
[ 3 5 10]
Displaying the histogram :
plt.hist(packet_exist_times, bins='auto')
renders :
From the numpy histogram (https://numpy.org/doc/stable/reference/generated/numpy.histogram.html) how to extract the information to enable modelling of ideal TTL time to allow most packets to not be discarded ?


