I have to determine the duration of a flow of packets sent from the same IP source address (DDoS). My criteria is that the flow should be no less than 60 seconds. I am a bit confused about the different time formats available in tshark for display. What is the best time format to choose for this purpose, and how would the flow duration be determined. This is a sample of what I have so far, with the time in seconds. I can sort the time field and then subtract the last time minus the first time to obtain the flow duration. Is this a correct approach? Is there a command in tshark to do both tasks? Thank you for your help.
asked 26 Nov '16, 08:27 MaryR edited 26 Nov '16, 08:43 sindy |
One Answer:
Sorting should normally not be necessary as the timestamps are monotonously growing, unless you use some reordering of the capture file. I must say that as I observe your case from your other Questions, I'd pipe the textual output of tshark to a perl (or any other scripting language which can use associative arrays) script to deal with the task, and I would keep records of first timestamp, last timestamp and packet count for each source IP address, as you seem not to be interested in the actual contents. As for the time format chosen (unix time in microseconds resolution), I'd probably use answered 26 Nov '16, 09:10 sindy |
Thank you for your answer Sindy. For some reason when I sorted the ip source address field, the time field turn out to be sorted also but only for some IP addresses. For example, for this IP address, time is not growing. I added the time field that you suggested to see the display. So basically, I could use either time format to calculate my time flow, right?
As for the script, would a bash script work? Sadly, I do not know Perl, neither bash script for that matter, but it seems to me that it would be easier to learn how to write a bash script.
So what I am trying to accomplish cannot be done by just CL advanced commands? Thanks so much for responding.
`
You can use statistic functions of tshark (from the
-z
universe) but that won't provide all you want for more than a single IP address, so you'd have to use multiple passes - first to identify the list of IP addresses which are worth deeper investigation, and then to make an individual statistics for each of them.By piping a tshark output to a tailor-made script, you can get your result in a single pass. Bash scripts do support arrays but the index must be an integer number; what makes the mission possible is that not all array elements must be initialized. So for IPv4 addresses, you can convert the IP address to a 32-bit integer (which it actually is) and then use it as an index to the three arrays (count, first_ts, last_ts). For IPv6 addresses, I'm not sure whether your bash will understand 128-bit integers, while in perl you would simply use string forms of the IP addresses as index values.
I would have to see the complete CLI command which has caused that. If you take a real capture file and let tshark print some fields of the frames, they will be printed in the order in which they have been captured.