chiark / gitweb /
Including README and examples and stuff.
[vinegar-ip.git] / Makefile
1 # Makefile for vinegar-ip
2 #
3 # This file is part of vinegar-ip, tools for IP transparency testing.
4 # vinegar-ip is Copyright (C) 2002 Ian Jackson
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
19 #
20 # $Id$
21
22 #############################################################
23 # You should edit the parameters below for your site
24
25 SOURCE=         172.18.45.35
26 DEST=           172.18.45.6
27
28 UNIQUE=
29 # set UNIQUE to something random for less observability
30
31 # NB, this MTU is not completely strictly adhered to by the
32 # test packet generator.  Sorry.
33 MTU=            100
34
35 # no of packets in each individual part, including part 1
36 PERPART=        100
37
38 # REST is made of PARTS-1 parts of PERPART packets
39 PARTS=          100
40
41 # You shouldn't need to edit anything beyond this point.
42 #############################################################
43
44 FEW_TARGETS=    on-dest.sh \
45                 send-1.pcap send-1.log send-1.why
46
47 TARGETS=        $(FEW_TARGETS) \
48                 send-all.pcap send-all.log send-all.why
49
50 A_PARTNOS=      $(shell \
51         set -e; i=1; while [ $$i -le $(PARTS) ]; do \
52                 echo $$i; i=$$(( $$i + 1)); done \
53         )
54
55 A_BASES=        $(addprefix send-,$(A_PARTNOS))
56 A_PCAPS=        $(addsuffix .pcap,$(A_BASES))
57 A_WHYS=         $(addsuffix .why,$(A_BASES))
58
59 AN_BASES=       $(basename $(wildcard recv-*.pcap))
60 AN_LOGS=        $(addsuffix .log,$(AN_BASES))
61 AN_DIFFS=       $(addsuffix .diff,$(AN_BASES))
62 AN_TARGETS=     $(AN_LOGS) $(AN_DIFFS)
63
64 INFORM=         @echo ' GENERATED THESE FILES:'; \
65                 echo '          $^'
66
67 all:            $(TARGETS)
68                         $(INFORM)
69
70 few:            $(FEW_TARGETS)
71                         $(INFORM)
72
73 anal analyse:   $(AN_TARGETS)
74                         $(INFORM)
75
76 send-all.pcap:  $(A_PCAPS) Makefile
77                 rm -f $@
78                 dd if=$< ibs=24 count=1 of=$@
79                 set -e; for f in $(A_PCAPS); do \
80                         dd ibs=24 skip=1 if=$$f >>$@; done
81
82 send-all.why:   $(A_WHYS) Makefile
83                 cat $(A_WHYS) >$@.1.tmp
84                 nl -bp'^ ? ? ?[0-9]' <$@.1.tmp >$@.2.tmp
85                 @mv -f $@.2.tmp $@
86
87 send-%.pcap send-%.why: ./make-probes.tcl Makefile
88         ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
89                 --source $(SOURCE) --dest $(DEST) --xseed "$* $(UNIQUE)" \
90                 >send-$*.why
91
92 %.log:          %.pcap lnumber-tcpdump.pl Makefile
93                 tcpdump -tnxvvs$$(($(MTU)+500)) -r $< >$@.1.tmp
94                 ./lnumber-tcpdump.pl <$@.1.tmp >$@.2.tmp
95                 @mv -f $@.2.tmp $@
96
97 recv-%.diff:    send-%.log recv-%.log
98                 diff -uI'^[0-9]' $^ >$@ || test $$? == 1
99
100 on-dest.sh:     Makefile
101         @rm -f $@
102         echo >$@ "#!/bin/sh"
103         @echo >>$@ "# run this script on $(DEST) as root, saying:"
104         @echo >>$@ "#   ./on-dest.sh PART"
105         @echo >>$@ "# where PART ranges from 1 to $(PARTS)"
106         @echo >>$@ "if ! [ \$$# = 1 ]; then echo >&2 'PART?'; exit 1; fi"
107         @echo >>$@ "exec tcpdump -s$$(($(MTU)+500)) -w recv-\$$1.pcap \\"
108         @echo >>$@ " src host $(SOURCE) and dst host $(DEST)"
109         chmod +x $@
110
111 clean:
112                 rm -f *.tmp *~ t u v
113
114 realclean:      clean
115                 rm -f $(TARGETS) *.pcap *.why *.log
116
117 # $Id$