I have written a bash code to run iperf3 and capture packets. Then i have extracted frame time from the .pcap file using tshark. The time is in the following format Jan 27, 2020 13:22:12.683438000 CET.
Now i want to calculate the time difference between the sent and received packets, but I dont know how do i subtract time which is in this format. Which variable type should i use so that I can perform the subtraction.
I have also used datetime library but did not get results.
check if below lines can help you
from datetime import datetime
from pytz import timezone
CET = timezone('CET')
send_time = datetime.strptime('11:18:57.925 Wed Jan 5 2019', '%H:%M:%S.%f %a %b %d %Y')
print(send_time.astimezone(CET))
difference_from_now = send_time.astimezone(CET) - datetime.now().astimezone(CET)
print(difference_from_now)
received_time = datetime.strptime('08:18:57.925 Mon Jan 20 2020', '%H:%M:%S.%f %a %b %d %Y')
print(received_time.astimezone(CET))
difference_send_received = send_time.astimezone(CET) - received_time.astimezone(CET)
print(difference_send_received)