xref: /original-bsd/usr.sbin/traceroute/mean.awk (revision c3e32dec)
1#!/bin/awk -f
2#
3# Copyright (c) 1990, 1993
4#	The Regents of the University of California.  All rights reserved.
5#
6# This code is derived from software contributed to Berkeley by
7# Van Jacobson.
8#
9# %sccs.include.redist.sh%
10#
11#	@(#)mean.awk	8.1 (Berkeley) 06/06/93
12#
13/^ *[0-9]/	{
14	# print out the average time to each hop along a route.
15	tottime = 0; n = 0;
16	for (f = 5; f <= NF; ++f) {
17		if ($f == "ms") {
18			tottime += $(f - 1)
19			++n
20		}
21	}
22	if (n > 0)
23		print $1, tottime/n, median
24}
25