5 # Generate a ton of connections and check if we can see syn/ack packets via tcpdump.
6 # Author: sapanb@cs.princeton.edu
13 my $guineapig='www.cs.princeton.edu';
14 my $targetfile='/~sapanb/small';
15 my $magic='3j4kl;1234kj341234jl1k234ljk123h4';
17 my $numsynacks:shared=0;
19 my $numpackets=$numthreads*$numiter;
22 my $sock = new IO::Socket::INET (
23 PeerAddr => $guineapig,
27 return 0 unless $sock;
28 print $sock "GET $targetfile HTTP/1.0\r\n";
29 print $sock "Host: www.cs.princeton.edu\r\n";
41 $numsynacks=$numsynacks+1;
47 foreach (1..$numiter) {
54 foreach (1..$numthreads) {
55 my $thr = threads->create(\&mfetch);
65 my $filter="'tcp[tcpflags]&tcp-syn !=0 and tcp[tcpflags]&tcp-ack !=0 and src $guineapig'";
66 my $cmdline="/usr/sbin/tcpdump -c $numpackets $filter";
73 print "[FAILED] tcpdump apparently did not intercept all SYN/ACK packets\n";
77 print "Starting tcpdump...\n";
78 my $tcpdthr=threads->create(\&open_tcpdump);
80 print "Generating connections...\n";
82 $SIG{ALRM}=\&alhandler;
86 print "[SUCCESS] Test completed OK. $numsynacks SYN/ACK packets intercepted.\n";