chiark / gitweb /
Templates for scripts. Monitoring script. Do not depend on time of generation at...
authorian <ian>
Sun, 3 Mar 2002 15:30:30 +0000 (15:30 +0000)
committerian <ian>
Sun, 3 Mar 2002 15:30:30 +0000 (15:30 +0000)
.cvsignore
Makefile
README
make-probes.tcl
monitor.template [new file with mode: 0644]
on-dest.template [new file with mode: 0644]

index 2bfee31cf449132cd358676321e4316b2a72d692..1bc23c1133adf5b78103ec940d28f5d8f239eb8d 100644 (file)
@@ -3,6 +3,7 @@ send-*.log
 send-*.pcap
 *.tmp
 on-dest.sh
+monitor.sh
 recv-*.log
 recv-*.pcap
 recv-*.diff
index 15f0ea8908118c4ccd6af81f549bc7a523fda90e..8f4acce3e134ec491483640c6785ea41f9e831c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,9 @@ PARTS=                100
 # You shouldn't need to edit anything beyond this point.
 #############################################################
 
-FEW_TARGETS=   on-dest.sh \
+SCRIPT_TARGETS=        on-dest.sh monitor.sh
+
+FEW_TARGETS=   $(SCRIPT_TARGETS) \
                send-1.pcap send-1.log send-1.why
 
 TARGETS=       $(FEW_TARGETS) \
@@ -64,12 +66,18 @@ AN_TARGETS= $(AN_LOGS) $(AN_DIFFS)
 INFORM=                @echo ' GENERATED THESE FILES:'; \
                echo '          $^'
 
+SOURCE_IP=     $(shell expr $(SOURCE) : '\([0-9.]*\)/')
+DEST_IP=       $(shell expr $(DEST) : '\([0-9.]*\)/')
+
 all:           $(TARGETS)
                        $(INFORM)
 
 few:           $(FEW_TARGETS)
                        $(INFORM)
 
+scripts:       $(SCRIPT_TARGETS)
+                       $(INFORM)
+
 anal analyse:  $(AN_TARGETS)
                        $(INFORM)
 
@@ -87,7 +95,7 @@ send-all.why: $(A_WHYS) Makefile
 send-%.pcap send-%.why:        ./make-probes.tcl Makefile
        ./make-probes.tcl --write $@ --mtu $(MTU) --upto $(PERPART) \
                --source $(SOURCE) \
-               --dest $(DEST) \
+               --dest $(DEST) \
                 --xseed "$* $(UNIQUE)" >send-$*.why
 
 %.log:         %.pcap lnumber-tcpdump.pl Makefile
@@ -98,16 +106,13 @@ send-%.pcap send-%.why:    ./make-probes.tcl Makefile
 recv-%.diff:   send-%.log recv-%.log
                diff -uI'^[0-9]' $^ >$@ || test $$? == 1
 
-on-dest.sh:    Makefile
-       @rm -f $@
-       echo >$@ "#!/bin/sh"
-       @echo >>$@ "# run this script on $(DEST) as root, saying:"
-       @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 -s$$(($(MTU)+500)) -w recv-\$$1.pcap \\"
-       @echo >>$@ " src host $(SOURCE) and dst host $(DEST)"
-       chmod +x $@
+%.sh:          %.template Makefile
+               sed <$< >$@.tmp -e ' \
+                       s/@@M/'$$(($(MTU)+500))'/; \
+                       s/@@S/$(SOURCE_IP)/; \
+                       s/@@D/$(DEST_IP)/'
+               chmod +x $@.tmp
+               @mv -f $@.tmp $@
 
 clean:
                rm -f *.tmp *~ t u v
diff --git a/README b/README
index 2072a74d335072fb9f69e8f5abec1c2c7003c877..dc5a83bf77bb445b3414592cf27c9bed14bdecfe 100644 (file)
--- a/README
+++ b/README
@@ -48,22 +48,26 @@ WHAT TO DO
            If you want to do a quick test first, you can say
            `make few' first, instead.
        * Copy send-1.pcap and send-all.pcap to the sending machine.
-       * Copy on-dest.sh to the to the receiving machine.
+       * Copy on-dest.sh and monitor.sh to the to the receiving machine.
 
 2. Run the first, small test
        * On the receiving machine, say, as root,
-               ./on-dest.sh 1
-           and leave it running.
+               ./on-dest.sh 1 [-i <interface>]
+           and leave it running.  Also, in a nice big window, say
+               ./monitor.sh [-i <interface>]
+           and leave that running too.  The default interface is
+           the one that tcpdump picks by default.
        * On the sending machine, say, as root,
-               tcpreplay -m 1 <send-1.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.
-       * When it has finished, kill on-dest.sh.  Copy the
-           file recv-1.pcap back to your analysis machine, and
-           there say `make analyse' (or `make anal' if you prefer).
+               tcpreplay -m 1 <send-1.pcap [-i <interface>]
+           You should see the results in your monitoring window.
+           This will take (by default) 100 seconds.  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.
+       * When it has finished, kill on-dest.sh and monitor.sh.
+            Copy the file recv-1.pcap back to your analysis machine, and
+           there say `make anal'.
        * This will generate `recv-1.log' and `recv-1.diff'.
            Read the diff and see if it's by and large working.
            See below for information about interpreting the various files.
@@ -82,9 +86,12 @@ FILES INVOLVED
        send-X.why      The generator's explanations (ha ha) of
                         what the test data is
        on-dest.sh      Script for running tcpdump on the destination
+                        to capture the packets as they come in
+       monitor.sh      Script for running tcpdump on either end
+                        for monitoring how it's going
    You really want to be paying attention to the ones where
-   X is `1' and `all'.  The others, 2 onwards, are all in
-   `all' and it'll be easier to take them all at once.
+   X is `1' and `all'.  `all' contains all the numbered parts,
+   and it'll be easier to do them all at once.
 
    Those supposedly captured at the destination
        recv-X.pcap     `pcap' format raw received packets
@@ -118,7 +125,7 @@ lines marked with `-'.  The changed numbers at the left are just the
 packet numbers.  You can use the numbers marked with `-' to find the
 corresponding packet in the other files.  Ignore the numbers marked
 with `+', they aren't useful.  In this case, it's packet 5 that's
-missing.  So, we can look in send-1.why or send-rest.why, as
+missing.  So, we can look in send-1.why or send-all.why, as
 appropriate, and see this:
 
    1 5  tos=0xe7 id=30130 df (!any) proto=icmp[1] \
index 527687340a10fd2db8f97f2cc274726653d53d03..b8b520f6475ba48b1616983aa35929944bfecc66 100755 (executable)
@@ -248,7 +248,8 @@ proc get/rand {s v minlen maxlen blockbytes} {
 }
 
 proc get/ip-timestamp {s v} {
-    set rv [expr {[clock seconds] | 0x80000000}]
+    set rv 0xbc000000
+    incr rv [choice-int 100 10000]
     getlog "$v=[format %x $rv]"
     return $rv
 }
@@ -1179,7 +1180,7 @@ namespace import PCap::*
 
 proc emit {seed} {
     global getlog_log errorInfo mtu fake_time_t
-    global minframelen linktypename
+    global minframelen linktypename errors_continue
 
     get-for ip
     get-config source 127.0.0.1 v4addr
@@ -1192,6 +1193,9 @@ proc emit {seed} {
     } emsg]} {
        puts stderr "\nERROR\n$seed\n\n$emsg\n\n$errorInfo\n\n"
        puts stdout "[format %6s $seed] error"
+       if {!$errors_continue} {
+           error "internal error generating packet - consult author"
+       }
     } else {
        set ts_sec [incr fake_time_t]
        set ts_usec 0
@@ -1257,6 +1261,7 @@ proc nextarg_il {} {
 }
 
 set debug_level 0
+set errors_continue 0
 set mtu 100
 set upto {}
 set xseed {}
@@ -1270,6 +1275,7 @@ while {[regexp {^\-\-} [lindex $argv 0]]} {
        --write { pcap_open [nextarg] }
        --mtu { set mtu [nextarg_num] }
        --xseed { set xseed [nextarg] }
+       --errors-continue { set errors_continue 1 }
        --linktype { set linktypename [nextarg] }
        --source { manyset [nextarg_il] config/ip-source config/link-source }
        --dest { manyset [nextarg_il] config/ip-dest config/link-dest }
@@ -1306,7 +1312,10 @@ pcap_write {
     s32 linktype
 }
 
-set fake_time_t [clock seconds]
+set fake_time_t 1000000000
+
+start_gen TEST
+random-bytes 100
 
 if {[llength $argv]} {
     foreach count $argv { emit "$xseed$count" }
diff --git a/monitor.template b/monitor.template
new file mode 100644 (file)
index 0000000..c2c9516
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Monitoring script.  Run on destination or source.
+# Run this script on @@S or @@D as root, saying:
+#   ./monitor.sh [<other tcpdump options>]
+
+exec tcpdump -lnvvps@@M "$@" \
+ src host @@S and dst host @@D
diff --git a/on-dest.template b/on-dest.template
new file mode 100644 (file)
index 0000000..07b6c06
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Received packets collection script.
+# Run this script on @@S as root, saying:
+#   ./on-dest.sh PART [<other tcpdump options>]
+# where PART ranges from 1 to 100
+
+if [ $# -lt 1 ]; then echo >&2 'PART?'; exit 1; fi
+part=$1; shift
+
+exec tcpdump -ps@@M -w recv-$part.pcap "$@" \
+ src host @@S and dst host @@D