parse_tcpdump_log.pl: Use relative timestamps
authorMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 9 Mar 2011 01:47:38 +0000 (22:47 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 9 Mar 2011 01:47:38 +0000 (22:47 -0300)
Instead of use absolute timestamps, use timestamps relative to the
first package.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
contrib/parse_tcpdump_log.pl [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 8cc791c..56882c1
@@ -28,12 +28,17 @@ sub print_frame($$)
        my %req = %{ @_[0] };
        my %resp = %{ @_[1] };
 
+       if (!$initial_time) {
+               $initial_time = $req{"Time"};
+               $last_time = $initial_time;
+       }
+
        # Print timestamps:
        #       relative time from resp 1
        #       relative time from last resp
        #       time to complete
        printf "%09d ms %06d ms (%06d us",
-               1000 * $req{"Time"} + 0.5,
+               1000 * ($req{"Time"} - $initial_time) + 0.5,
                1000 * ($req{"Time"} - $last_time) + 0.5,
                ($resp{"Time"} - $req{"Time"}) * 1000000 + 0.5;
        $last_time = $req{"Time"};
@@ -82,8 +87,6 @@ sub print_frame($$)
 sub process_frame($) {
        my %frame = %{ @_[0] };
 
-       $initial_time = $frame{"Arrival"} if (!$initial_time);
-
        if ($debug > 1) {
                my ($key, $value);
                print "\t\tRAW: $key => $value\n" while (($key, $value) = each(%frame));