chiark / gitweb /
Found on davenant
[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=         130.233.5.88/00:0D:60:89:9F:AC
26 DEST=           193.201.200.170/00:0B:45:B3:78:40
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 SCRIPT_TARGETS= on-dest.sh monitor.sh
45
46 FEW_TARGETS=    $(SCRIPT_TARGETS) \
47                 send-1.pcap send-1.log send-1.why
48
49 TARGETS=        $(FEW_TARGETS) \
50                 send-all.pcap send-all.log send-all.why
51
52 A_PARTNOS=      $(shell \
53         set -e; i=1; while [ $$i -le $(PARTS) ]; do \
54                 echo $$i; i=$$(( $$i + 1)); done \
55         )
56
57 A_BASES=        $(addprefix send-,$(A_PARTNOS))
58 A_PCAPS=        $(addsuffix .pcap,$(A_BASES))
59 A_WHYS=         $(addsuffix .why,$(A_BASES))
60
61 AN_BASES=       $(basename $(wildcard recv-*.pcap))
62 AN_LOGS=        $(addsuffix .log,$(AN_BASES))
63 AN_DIFFS=       $(addsuffix .diff,$(AN_BASES))
64 AN_MDIFFS=      $(addsuffix .mdiff,$(AN_BASES))
65 AN_SUMMARIES=   $(addsuffix .summary,$(AN_BASES))
66 AN_TARGETS=     $(AN_LOGS) $(AN_DIFFS) $(AN_MDIFFS) $(AN_SUMMARIES)
67
68 INFORM=         @echo ' GENERATED THESE FILES:'; \
69                 echo '          $^'
70
71 SOURCE_IP=      $(shell expr $(SOURCE) : '\([0-9.]*\)/')
72 DEST_IP=        $(shell expr $(DEST) : '\([0-9.]*\)/')
73
74 all:            $(TARGETS)
75                         $(INFORM)
76
77 few:            $(FEW_TARGETS)
78                         $(INFORM)
79
80 scripts:        $(SCRIPT_TARGETS)
81                         $(INFORM)
82
83 anal analyse:   $(AN_TARGETS)
84                         $(INFORM)
85
86 send-all.pcap:  $(A_PCAPS)
87                 rm -f $@
88                 dd if=$< ibs=24 count=1 of=$@
89                 set -e; for f in $(A_PCAPS); do \
90                         dd ibs=24 skip=1 if=$$f >>$@; done
91
92 send-all.why:   $(A_WHYS) Makefile
93                 cat $(A_WHYS) >$@.1.tmp
94                 nl -bp'^ ? ? ?[0-9]' <$@.1.tmp >$@.2.tmp
95                 @mv -f $@.2.tmp $@
96
97 send-%.pcap send-%.why: ./make-probes.tcl
98         ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
99                 --source $(SOURCE) \
100                 --dest $(DEST) \
101                  --xseed "$* $(UNIQUE)" >send-$*.why
102
103 %.log:  %.pcap Makefile \
104         lnumber-tcpdump.pl blank-ttl-ipcsum.pl tcpdump-nomultiline.pl
105                 tcpdump -tnxvvs$$(($(MTU)+500)) -r $< >$@.2.tmp
106                 ./tcpdump-nomultiline.pl <$@.2.tmp >$@.3.tmp
107                 ./blank-ttl-ipcsum.pl <$@.3.tmp >$@.4.tmp
108                 ./lnumber-tcpdump.pl <$@.4.tmp >$@.5.tmp
109                 @mv -f $@.5.tmp $@
110
111 recv-%.diff:    send-%.log recv-%.log
112                 diff -uI'^[0-9]' $^ >$@ || test $$? == 1
113
114 recv-%.mdiff:   send-%.log recv-%.log
115                 diff -U 1 -I'^[0-9]\|^    [     ][      ]' $^ >$@ \
116                         || test $$? == 1
117
118 recv-%.summary: recv-%.mdiff mdiff-summarise.pl
119                 ./mdiff-summarise.pl <$< >$@.1.tmp
120                 sort -t : +1 <$@.1.tmp >$@.2.tmp
121                 @mv -f $@.2.tmp $@
122
123 %.sh:           %.template Makefile
124                 sed <$< >$@.tmp -e ' \
125                         s/@@M/'$$(($(MTU)+500))'/; \
126                         s/@@S/$(SOURCE_IP)/; \
127                         s/@@D/$(DEST_IP)/'
128                 chmod +x $@.tmp
129                 @mv -f $@.tmp $@
130
131 clean:
132                 rm -f *.tmp *~ t u v
133
134 realclean:      clean
135                 rm -f $(TARGETS) *.pcap *.why *.log recv-*.diff
136
137 # $Id$