chiark / gitweb /
Including README and examples and stuff.
[vinegar-ip.git] / Makefile
index cf9c919d906e175ccd12c1d677ef6a9fd8e26b70..0ecd8284983655c12c6d2e74279e0fb6f89f9621 100644 (file)
--- a/Makefile
+++ b/Makefile
-# INSTRUCTIONS
+# Makefile for vinegar-ip
 #
-# This is a tool for TCP transparency testing.  It allows you to send
-# a wide variety of `interesting' packets from one nominated machine
-# to another, and then examine what arrived to see if there are any
-# differences.
+# This file is part of vinegar-ip, tools for IP transparency testing.
+# vinegar-ip is Copyright (C) 2002 Ian Jackson
 #
-# Up to 4 hosts are involved: one to do the test dataset generation, a
-# sender, a receiver, and one to do the analysis.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
 #
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-# WHAT YOU WILL NEED
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 #
-#  on the machine you generate the test data
-#      This Makefile and corresponding Tcl script
-#      Tcl (as /usr/bin/tclsh)
-#      OpenSSL (as `openssl' on PATH)
-#      Lots of CPU !  (the generation script is rather slow)
-#
-#  on the sending machine
-#      tcpreplay (http://www.subterrain.net/tools/tcpreplay/,
-#              or from Debian testing 3.5.2002.  I used 1.0.1-1.1)
-#              and root privilege to run it
-#
-#  on the receiving machine
-#      tcpdump for packet capture, and root privilege to run it
-#      The `on-dest.sh' script that this Makefile creates
-#
-#  on the analysis machine
-#      tcpdump for converting trace files only, no root privilege
-#      This Makefile to drive tcpdump for you, if you like
-#      diff to look at the output
-#
-# It will be much better if the machines you are using do not have any
-# other traffic.  If they do the tests may disrupt it, and it'll get
-# in the way of your analysis too.
-#
-#
-# WHAT TO DO
-#
-#  1. Generate the test data.
-#      * Edit this Makefile.
-#          You /must/ change SOURCE and DEST; they must be IPv4 addresses.
-#          You may also change PARTS, PERPART or MTU if you like.
-#      * Say `make -j2 generate'.  This will generate the test data sets.
-#          This will take a while.  Vary the -j for your system.
-#      * Copy send-*.pcap and on-dest.sh to the sending machine.
-#
-#  2. Run one of the tests
-#      * Pick a PART number, say 1, to start with.
-#      * On the receiving machine, say, as root,
-#              ./on-dest.sh PART
-#          and leave it running.
-#      * On the sending machine, say, as root,
-#              tcpreplay -m 1 <send-PART.pcap
-#          The -m 1 option makes tcpreplay send the packets at one a
-#          second (they are generated as if they were captured at one
-#          a second); this avoids flooding the network, which causes
-#          congestion, packet loss and maybe other randomness.
-#          This will take (by default) 100 seconds.
-
-#
-#
-#
-# FILES INVOLVED
-#    Those made by `make generate':
-#      send-*.pcap     `pcap' format raw test data files
-#                       (feed this to tcpreplay -m 1)
-#      send-*.log      tcpdump's interpretation of the test data
-#                       with line numbers added
-#      send-*.why      The generator's explanations (ha ha) of
-#                       what the test data is
-#      on-dest.sh      Script for running tcpdump on the destination
-#
-#    Those supposedly captured at the destination
-#      recv-*.pcap     `pcap' format raw received packets
-#
-#    Those made during the analysis:
-#      recv-*.log      tcpdump's interpretation of the received packets
-#      recv-*.diff     difference between send-*.log and recv-*.log
-#      all.diff        all the .diff's concatenated in one easy file
-#
-#
-#  On the receiving machine,
-#      
-#
-#  on the 
-#  Run this makefile anywhere to generate the test data sets
-#  
+# $Id$
 
+#############################################################
+# You should edit the parameters below for your site
 
 SOURCE=                172.18.45.35
-DEST=          172.18.45.35
+DEST=          172.18.45.6
 
 UNIQUE=
 # set UNIQUE to something random for less observability
 
+# NB, this MTU is not completely strictly adhered to by the
+# test packet generator.  Sorry.
 MTU=           100
 
 # no of packets in each individual part, including part 1
-PERPART=       10
+PERPART=       100
 
-# `rest' is made of PARTS-1 parts of PERPART packets
-PARTS=         10
+# REST is made of PARTS-1 parts of PERPART packets
+PARTS=         100
 
 # You shouldn't need to edit anything beyond this point.
+#############################################################
 
 FEW_TARGETS=   on-dest.sh \
                send-1.pcap send-1.log send-1.why
 
-TARGETS=       $(GEN_SMALL) \
-               send-rest.pcap send-rest.log send-rest.why
+TARGETS=       $(FEW_TARGETS) \
+               send-all.pcap send-all.log send-all.why
 
-R_PARTNOS=     $(shell \
-       set -e; i=2; while [ $$i -le $(PARTS) ]; do \
+A_PARTNOS=     $(shell \
+       set -e; i=1; while [ $$i -le $(PARTS) ]; do \
                echo $$i; i=$$(( $$i + 1)); done \
        )
 
-R_BASES=       $(addprefix send-,1 $(R_PARTNOS))
-R_PCAPS=       $(addsuffix .pcap,$(R_BASES))
-R_WHYS=                $(addsuffix .why,$(R_BASES))
+A_BASES=       $(addprefix send-,$(A_PARTNOS))
+A_PCAPS=       $(addsuffix .pcap,$(A_BASES))
+A_WHYS=                $(addsuffix .why,$(A_BASES))
+
+AN_BASES=      $(basename $(wildcard recv-*.pcap))
+AN_LOGS=       $(addsuffix .log,$(AN_BASES))
+AN_DIFFS=      $(addsuffix .diff,$(AN_BASES))
+AN_TARGETS=    $(AN_LOGS) $(AN_DIFFS)
+
+INFORM=                @echo ' GENERATED THESE FILES:'; \
+               echo '          $^'
 
 all:           $(TARGETS)
+                       $(INFORM)
+
 few:           $(FEW_TARGETS)
+                       $(INFORM)
+
+anal analyse:  $(AN_TARGETS)
+                       $(INFORM)
 
-send-rest.pcap:        $(R_PCAPS)
+send-all.pcap: $(A_PCAPS) Makefile
                rm -f $@
                dd if=$< ibs=24 count=1 of=$@
-               set -e; for f in $^; do \
+               set -e; for f in $(A_PCAPS); do \
                        dd ibs=24 skip=1 if=$$f >>$@; done
 
-send-rest.why: $(R_WHYS)
-               cat $(R_WHYS) >$@.1.tmp
+send-all.why:  $(A_WHYS) Makefile
+               cat $(A_WHYS) >$@.1.tmp
                nl -bp'^ ? ? ?[0-9]' <$@.1.tmp >$@.2.tmp
                @mv -f $@.2.tmp $@
 
-send-%.pcap:   ./make-probes.tcl
+send-%.pcap send-%.why:        ./make-probes.tcl Makefile
        ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
                --source $(SOURCE) --dest $(DEST) --xseed "$* $(UNIQUE)" \
                >send-$*.why
 
-%.log:         %.pcap
-               tcpdump -tnxvvs$$(($(MTU)+50)) -r $< >$@.1.tmp
-               nl -bp'^[0-9]' <$@.1.tmp >$@.2.tmp
+%.log:         %.pcap lnumber-tcpdump.pl Makefile
+               tcpdump -tnxvvs$$(($(MTU)+500)) -r $< >$@.1.tmp
+               ./lnumber-tcpdump.pl <$@.1.tmp >$@.2.tmp
                @mv -f $@.2.tmp $@
 
+recv-%.diff:   send-%.log recv-%.log
+               diff -uI'^[0-9]' $^ >$@ || test $$? == 1
+
 on-dest.sh:    Makefile
        @rm -f $@
        echo >$@ "#!/bin/sh"
@@ -151,7 +104,7 @@ on-dest.sh: Makefile
        @echo >>$@ "#   ./on-dest.sh PART"
        @echo >>$@ "# where PART ranges from 1 to $(PARTS)"
        @echo >>$@ "if ! [ \$$# = 1 ]; then echo >&2 'PART?'; exit 1; fi"
-       @echo >>$@ "exec tcpdump -ps$$(($(MTU)+50)) -w recv-\$$1.pcap \\"
+       @echo >>$@ "exec tcpdump -s$$(($(MTU)+500)) -w recv-\$$1.pcap \\"
        @echo >>$@ " src host $(SOURCE) and dst host $(DEST)"
        chmod +x $@
 
@@ -160,3 +113,5 @@ clean:
 
 realclean:     clean
                rm -f $(TARGETS) *.pcap *.why *.log
+
+# $Id$