Skip to content

Instantly share code, notes, and snippets.

@wkz
Created March 29, 2023 08:09
Show Gist options
  • Save wkz/5cad71d7a823cd9c495ac8eaf89be478 to your computer and use it in GitHub Desktop.
Save wkz/5cad71d7a823cd9c495ac8eaf89be478 to your computer and use it in GitHub Desktop.
usage()
{
cat <<EOF
usage: $0 [-h] [-a <period>]
Measure bridge ingress times. Without -a, print each packet's ingress
time. With -a, aggregate data in <period> sized buckets (in
nanoseconds).
EOF
}
case $(uname -m) in
*64)
ptrsz=8
;;
*)
ptrsz=4
;;
esac
while getopts "a:h" opt; do
case ${opt} in
a)
agg=$OPTARG
;;
h)
usage
exit
;;
esac
done
shift $((OPTIND - 1))
ply "
k:br_handle_frame
{
in[mem(arg0, $ptrsz)] = time;
}
k:br_pass_frame_up / in[arg0] /
{
`[ \"$agg\" ] || echo \"print(time - in[arg0]);\"`
`[ \"$agg\" ] && echo \"@[(time - in[arg0]) / $agg] = count();\"`
delete in[arg0];
}
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment