chiark / gitweb /
cf9c919d906e175ccd12c1d677ef6a9fd8e26b70
[vinegar-ip.git] / Makefile
1 # INSTRUCTIONS
2 #
3 # This is a tool for TCP transparency testing.  It allows you to send
4 # a wide variety of `interesting' packets from one nominated machine
5 # to another, and then examine what arrived to see if there are any
6 # differences.
7 #
8 # Up to 4 hosts are involved: one to do the test dataset generation, a
9 # sender, a receiver, and one to do the analysis.
10 #
11 #
12 # WHAT YOU WILL NEED
13 #
14 #  on the machine you generate the test data
15 #       This Makefile and corresponding Tcl script
16 #       Tcl (as /usr/bin/tclsh)
17 #       OpenSSL (as `openssl' on PATH)
18 #       Lots of CPU !  (the generation script is rather slow)
19 #
20 #  on the sending machine
21 #       tcpreplay (http://www.subterrain.net/tools/tcpreplay/,
22 #               or from Debian testing 3.5.2002.  I used 1.0.1-1.1)
23 #               and root privilege to run it
24 #
25 #  on the receiving machine
26 #       tcpdump for packet capture, and root privilege to run it
27 #       The `on-dest.sh' script that this Makefile creates
28 #
29 #  on the analysis machine
30 #       tcpdump for converting trace files only, no root privilege
31 #       This Makefile to drive tcpdump for you, if you like
32 #       diff to look at the output
33 #
34 # It will be much better if the machines you are using do not have any
35 # other traffic.  If they do the tests may disrupt it, and it'll get
36 # in the way of your analysis too.
37 #
38 #
39 # WHAT TO DO
40 #
41 #  1. Generate the test data.
42 #       * Edit this Makefile.
43 #           You /must/ change SOURCE and DEST; they must be IPv4 addresses.
44 #           You may also change PARTS, PERPART or MTU if you like.
45 #       * Say `make -j2 generate'.  This will generate the test data sets.
46 #           This will take a while.  Vary the -j for your system.
47 #       * Copy send-*.pcap and on-dest.sh to the sending machine.
48 #
49 #  2. Run one of the tests
50 #       * Pick a PART number, say 1, to start with.
51 #       * On the receiving machine, say, as root,
52 #               ./on-dest.sh PART
53 #           and leave it running.
54 #       * On the sending machine, say, as root,
55 #               tcpreplay -m 1 <send-PART.pcap
56 #           The -m 1 option makes tcpreplay send the packets at one a
57 #           second (they are generated as if they were captured at one
58 #           a second); this avoids flooding the network, which causes
59 #           congestion, packet loss and maybe other randomness.
60 #           This will take (by default) 100 seconds.
61
62 #
63 #
64 #
65 # FILES INVOLVED
66 #    Those made by `make generate':
67 #       send-*.pcap     `pcap' format raw test data files
68 #                        (feed this to tcpreplay -m 1)
69 #       send-*.log      tcpdump's interpretation of the test data
70 #                        with line numbers added
71 #       send-*.why      The generator's explanations (ha ha) of
72 #                        what the test data is
73 #       on-dest.sh      Script for running tcpdump on the destination
74 #
75 #    Those supposedly captured at the destination
76 #       recv-*.pcap     `pcap' format raw received packets
77 #
78 #    Those made during the analysis:
79 #       recv-*.log      tcpdump's interpretation of the received packets
80 #       recv-*.diff     difference between send-*.log and recv-*.log
81 #       all.diff        all the .diff's concatenated in one easy file
82 #
83 #
84 #  On the receiving machine,
85 #       
86 #
87 #  on the 
88 #  Run this makefile anywhere to generate the test data sets
89 #  
90
91
92 SOURCE=         172.18.45.35
93 DEST=           172.18.45.35
94
95 UNIQUE=
96 # set UNIQUE to something random for less observability
97
98 MTU=            100
99
100 # no of packets in each individual part, including part 1
101 PERPART=        10
102
103 # `rest' is made of PARTS-1 parts of PERPART packets
104 PARTS=          10
105
106 # You shouldn't need to edit anything beyond this point.
107
108 FEW_TARGETS=    on-dest.sh \
109                 send-1.pcap send-1.log send-1.why
110
111 TARGETS=        $(GEN_SMALL) \
112                 send-rest.pcap send-rest.log send-rest.why
113
114 R_PARTNOS=      $(shell \
115         set -e; i=2; while [ $$i -le $(PARTS) ]; do \
116                 echo $$i; i=$$(( $$i + 1)); done \
117         )
118
119 R_BASES=        $(addprefix send-,1 $(R_PARTNOS))
120 R_PCAPS=        $(addsuffix .pcap,$(R_BASES))
121 R_WHYS=         $(addsuffix .why,$(R_BASES))
122
123 all:            $(TARGETS)
124 few:            $(FEW_TARGETS)
125
126 send-rest.pcap: $(R_PCAPS)
127                 rm -f $@
128                 dd if=$< ibs=24 count=1 of=$@
129                 set -e; for f in $^; do \
130                         dd ibs=24 skip=1 if=$$f >>$@; done
131
132 send-rest.why:  $(R_WHYS)
133                 cat $(R_WHYS) >$@.1.tmp
134                 nl -bp'^ ? ? ?[0-9]' <$@.1.tmp >$@.2.tmp
135                 @mv -f $@.2.tmp $@
136
137 send-%.pcap:    ./make-probes.tcl
138         ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
139                 --source $(SOURCE) --dest $(DEST) --xseed "$* $(UNIQUE)" \
140                 >send-$*.why
141
142 %.log:          %.pcap
143                 tcpdump -tnxvvs$$(($(MTU)+50)) -r $< >$@.1.tmp
144                 nl -bp'^[0-9]' <$@.1.tmp >$@.2.tmp
145                 @mv -f $@.2.tmp $@
146
147 on-dest.sh:     Makefile
148         @rm -f $@
149         echo >$@ "#!/bin/sh"
150         @echo >>$@ "# run this script on $(DEST) as root, saying:"
151         @echo >>$@ "#   ./on-dest.sh PART"
152         @echo >>$@ "# where PART ranges from 1 to $(PARTS)"
153         @echo >>$@ "if ! [ \$$# = 1 ]; then echo >&2 'PART?'; exit 1; fi"
154         @echo >>$@ "exec tcpdump -ps$$(($(MTU)+50)) -w recv-\$$1.pcap \\"
155         @echo >>$@ " src host $(SOURCE) and dst host $(DEST)"
156         chmod +x $@
157
158 clean:
159                 rm -f *.tmp *~ t u v
160
161 realclean:      clean
162                 rm -f $(TARGETS) *.pcap *.why *.log