]> git.meshlink.io Git - utcp/blob - makegraph
Add a script to generate graphs of the data recorded by the benchmark script.
[utcp] / makegraph
1 #!/bin/sh
2 set -e
3
4 LOG_PREFIX=/dev/shm/benchmark-log
5
6 PLOT_SCRIPT=$LOG_PREFIX-plot.script
7 PLOT_PDF=$LOG_PREFIX-plot.pdf
8
9 cat >$PLOT_SCRIPT <<EOF
10         set terminal pdf size 29.7cm,21cm
11         set output "$PLOT_PDF"
12         set style data steps
13         set xdata time
14         set timefmt "%s"
15         set grid
16         set lmargin 12
17         set rmargin 3
18 EOF
19
20 for peer in client server; do
21         LOG=$LOG_PREFIX-$peer.txt
22         fgrep 'recv:' $LOG > $LOG.recv
23         grep '\(send\|rtrx\):' $LOG > $LOG.send
24         fgrep 'snd.cwnd' $LOG > $LOG.cwnd
25         fgrep 'cwndleft' $LOG > $LOG.left
26         fgrep 'rtt' $LOG > $LOG.rtt || (
27                 head -1 $LOG.send | (read ts conn rest; echo $ts $conn rtt 0 srtt 0 rttvar 0 rto 0 >$LOG.rtt)
28         )
29         (fgrep 'fast recovery started' $LOG || true) | while read ts rest; do
30                 echo "set xtics add (\"\" $ts)" >>$PLOT_SCRIPT
31         done
32         (fgrep 'retransmitting after timeout' $LOG || true) | while read ts rest; do
33                 echo "set xtics add (\"\" $ts)" >>$PLOT_SCRIPT
34         done
35
36         cat >>$PLOT_SCRIPT <<EOF
37                 set multiplot layout 4, 1 title "UTCP $peer"
38
39                 set tmargin 2
40                 set bmargin 0
41                 set xtics format ""
42                 set ylabel "sequence number (bytes)"
43                 plot \
44                         "$LOG.send" using 1:11 title "send seq", \
45                         "$LOG.recv" using 1:13 title "recv ack"
46                 set xrange [GPVAL_X_MIN:GPVAL_X_MAX]
47
48                 set tmargin 0
49                 set ylabel "size (bytes)"
50                 plot \
51                         "$LOG.cwnd" using 1:4 title "cwnd", \
52                         "$LOG.cwnd" using 1:6 title "ssthresh"
53
54                 set ylabel "time (milliseconds)"
55                 plot \
56                         "$LOG.rtt" using 1:(\$4/1000) title "rtt", \
57                         "$LOG.rtt" using 1:(\$10/1000) title "rto"
58
59                 set bmargin 4
60                 set xtics format "%g"
61                 set xlabel "time"
62                 set ylabel "size (bytes)"
63                 plot \
64                         "$LOG.left" using 1:(\$4 > 0 ? \$4 : 0) title "cwnd left", \
65                         "$LOG.left" using 1:6 title "sndbuf left"
66
67                 unset xtics
68 EOF
69 done
70
71 cat >>$PLOT_SCRIPT <<EOF
72         unset multiplot
73         set output
74 EOF
75
76 gnuplot $PLOT_SCRIPT