#==================================================================== # USER DEFINES # global defaults my $def_proto = "icmp"; # default protocol to use my $pattern = 153; # default data pattern to send. my $num_bytes = 40; # default number number of bytes to send in data section. my $children = 20; # default number of child processes to spawn my $requests = 50; # default number of requests that each child sends # protocol specific defaults my $prot_ip = { tos => '0', ttl => '30', saddr => '172.16.0.1', }; my $prot_tcp = {source => "33333", dest => "80", urg => "0", ack => "0", psh => "0", rst => "0", syn => "1", fin => "0", }; my $prot_udp = {source => "53", dest => "33333", }; my $prot_icmp = {type => "8", code => "0", }; #======================================= #====================================================================== # MAIN #------------------- # get data info from user print "number of bytes in data field? [$num_bytes] : "; $input = ; chomp ($input); if (($input) && ($input<1501) && ($input>0)) {$num_bytes = $input;} #--------- #------------------- # make data portion of packet my $data = $pattern x $num_bytes; $data = pack("C", $data); #--------- #------------------- # get protocol info from user # get ip info set_ip(); # get upper layer protocol type and info print "tcp, udp, or icmp? [$def_proto] : "; $input = ; chomp ($input); if ($input ne "") { if ($input eq "tcp") { $def_proto = "tcp"; set_tcp(); # set prefs for tcp datagram $prot_tcp->{data} = $data; $packet{tcp} = $prot_tcp; } elsif ($input eq "udp") { $def_proto = "udp"; set_udp(); # set prefs for udp datagram $prot_udp->{data} = $data; $packet{udp} = $prot_udp; } else { $def_proto = "icmp"; set_icmp(); # set prefs for icmp datagram $prot_icmp->{data} = $data; $packet{icmp} = $prot_icmp; } } $packet{ip} = $prot_ip; #--------- #------------------- # fork off children and x-mit data my $pm = new Parallel::ForkManager($children); ReadMode 4; # Turn off controls keys print "press any key to quit...\n"; while (not defined (my $key = ReadKey(-1))) { # Forks and returns the pid for the child: my $pid = $pm->start and next; my $pkt_h = new Net::RawIP; $pkt_h->set(\%packet); $pkt_h->send(.25,$requests); $pm->finish; # Terminates the child process } ReadMode 0; # Reset tty mode before exiting print "\n\nwaiting on child processes to stop..."; $pm->wait_all_children; print "...all done...quitting.\n"; #--------- #=======================================