• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/awk -f
2
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script computes the intervals between the time instants of
8# contiguous SYN_REPORT packets, and count the number of packets
9# with time intervals greater than 1/60 seconds.
10# Note: this script is larged borrowed from adlr@'s timing test in shell.
11
12# Usage: DISPLAY=:0 mtplot tools/awk_process_syn
13#  Note: You need to press 'q' instead of ctrl-c to exit mtplot
14#        in order to print the count of large intervals.
15
16
17BEGIN {
18  previous = 0;
19  count_packets = 0;
20  count_large = 0;
21}
22
23/SYN_REPORT/ {
24  if (previous == 0) {
25    previous = $3;
26  } else {
27    current = $3;
28    interval = current - previous;
29    previous = current;
30    count_packets++;
31    if (interval > 1.0 / 60) {
32      mark = "*****";
33      count_large++;
34    } else {
35      mark = "     ";
36    }
37    template = "  %s interval: %.6f   (%s)\n";
38    printf(template, mark, interval, $0);
39  }
40}
41
42END {
43  msg = "\nthe count of large intervals: %d out of %d packets\n\n"
44  printf(msg, count_large, count_packets);
45}
46
47