From owner-freebsd-ipfw@FreeBSD.ORG Sun Jul 27 03:39:49 2003 Return-Path: Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C207D37B401 for ; Sun, 27 Jul 2003 03:39:49 -0700 (PDT) Received: from mail020.syd.optusnet.com.au (mail020.syd.optusnet.com.au [210.49.20.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 13D1743F3F for ; Sun, 27 Jul 2003 03:39:48 -0700 (PDT) (envelope-from markhannon@optusnet.com.au) Received: from doorway.homeip.net (c211-28-121-120.sunsh3.vic.optusnet.com.au [211.28.121.120])h6RAdjG02082 for ; Sun, 27 Jul 2003 20:39:46 +1000 Received: from optusnet.com.au (tbird.home.lan [192.168.1.5]) by doorway.homeip.net (8.12.9/8.12.9) with ESMTP id h6RAdj86019081 for ; Sun, 27 Jul 2003 20:39:45 +1000 (EST) (envelope-from markhannon@optusnet.com.au) Message-ID: <3F23ABF3.1020905@optusnet.com.au> Date: Sun, 27 Jul 2003 20:39:47 +1000 From: Mark Hannon User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20030719 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: freebsd-ipfw@freebsd.org References: <3F212BF7.4060602@optusnet.com.au> <20030725103814.A54554@xorpc.icir.org> In-Reply-To: <20030725103814.A54554@xorpc.icir.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: using dummynet to simulate modem, dsl, etc X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2003 10:39:50 -0000 For those that are interested ... the following script and test results were obtained. My reasonings for the delay etc are partially included in the perl script. /mark #!/usr/bin/perl # # $Id: lnf-test.pl,v 1.1 2003/07/27 10:30:57 mark Exp $ # # ===================================================================== # Details of all of the networks to be simulated are stored in a hash: # # name => "descriptive text" # ip => "dotted ip number - will be aliased to lo0", # mtu => "mtu in octets", # us_bw => "upstream bandwidth in kbit/s", # us_queue => 0, # us_init_delay => "upstream processing delay only", # us_total_delay => "upstream total delay - calculated", # ds_bw => "downstream bandwidth in kbit/s", # ds_queue => o, # ds_init_delay => "downstream processing delay only", # ds_total_delay => "downstream total delay - calculated", $testnet = [ { name => "56k modem", ip => "127.0.0.101", mtu => 576, us_bw => 33, us_queue => 0, us_init_delay => 40, # V.90 processing, error correction etc. us_total_delay => 0, ds_bw => 56, ds_queue => 0, ds_init_delay => 40, # V.90 processing, error correction etc. ds_total_delay => 0 }, { name => "128k ISDN-BA", ip => "127.0.0.102", mtu => 576, us_bw => 128, us_queue => 0, us_init_delay => 20, # guesstimate us_total_delay => 0, ds_bw => 128, ds_queue => 0, ds_init_delay => 20, # guesstimate ds_total_delay => 0 }, { name => "512k/64k ADSL", ip => "127.0.0.103", mtu => 1500, us_bw => 64, us_queue => 0, us_init_delay => 15, # guesstimate us_total_delay => 0, ds_bw => 512, ds_queue => 0, ds_init_delay => 15, # guesstimate ds_total_delay => 0 }, { name => "1500k/256k ADSL", ip => "127.0.0.104", mtu => 1500, us_bw => 256, us_queue => 0, us_init_delay => 15, # guesstimate us_total_delay => 0, ds_bw => 1500, ds_queue => 0, ds_init_delay => 15, # guesstimate ds_total_delay => 0 }, { name => "8000k/1000k ADSL", ip => "127.0.0.105", mtu => 1500, us_bw => 1000, us_queue => 0, us_init_delay => 15, # guesstimate us_total_delay => 0, ds_bw => 8000, ds_queue => 0, ds_init_delay => 15, # guesstimate ds_total_delay => 0 }, ]; # ===================================================================== # Loop through $testnet and setup simulated networks $set_nr = 10; # the initial ipfw set number to use $pipe_nr = 10; # the initial ipfw pipe number to use $rule_nr = 10; # the initial ipfw rule number to use foreach $this (@$testnet){ # add serilization of 40 octet ACK to upsteam delay $us_serial_delay = (40 * 8 ) / $$this{us_bw}; $$this{us_total_delay} = int($$this{us_init_delay} + $us_serial_delay); # add serilization of MTU octet data to downstream delay $ds_serial_delay = ($$this{mtu} * 8 ) / $$this{ds_bw}; $$this{ds_total_delay} = int($$this{ds_init_delay} + $ds_serial_delay); printf "%s: %s kbit/s @ %s ms down and %s kbit/s @ %s ms up\n", $$this{name}, $$this{ds_bw}, $$this{ds_total_delay}, $$this{us_bw}, $$this{us_total_delay}; # add alias to lo0 for the address $ifconfig_command = "ifconfig lo0 alias $$this{ip}"; print $ifconfig_command, "\n"; `$ifconfig_command`; # setup an input pipe to simulate the upstream $ipfw_command = "ipfw -q add $rule_nr pipe $pipe_nr ip from any to $$this{ip} in"; $pipe_command = "ipfw -q pipe $pipe_nr config bw $$this{us_bw}kbit/s " . "queue $$this{us_queue} delay $$this{us_total_delay}ms"; print $ipfw_command, "\n"; `$ipfw_command`; print $pipe_command, "\n"; `$pipe_command`; $rule_nr++; $pipe_nr++; # setup an input pipe to simulate the downstream $ipfw_command = "ipfw -q add $rule_nr pipe $pipe_nr ip from $$this{ip} to any in"; $pipe_command = "ipfw -q pipe $pipe_nr config bw $$this{ds_bw}kbit/s " . "queue $$this{ds_queue} delay $$this{ds_total_delay}ms"; print $ipfw_command, "\n"; `$ipfw_command`; print $pipe_command, "\n"; `$pipe_command`; $rule_nr++; $pipe_nr++; } # SIGHUP inetd in order to listen on all new interfaces `killall -HUP inetd`; # ===================================================================== # Loop through $testnet and test performance foreach $this (@$testnet){ # print headers etc printf "===================================================================\n"; printf "%s: %s kbit/s @ %s ms down and %s kbit/s @ %s ms up\n", $$this{name}, $$this{ds_bw}, $$this{ds_total_delay}, $$this{us_bw}, $$this{us_total_delay}; printf "===================================================================\n"; $start_time = time; $ftp_command = "fetch ftp://$$this{ip}/pub/test_small"; printf "$ftp_command\n"; `$ftp_command`; $finish_time = time; $clock_time = $finish_time - $start_time; printf "Clock time for transfer = $clock_time seconds\n"; printf "\n"; } tbird:~/projects/lnf-test# ./lnf-test.pl 56k modem: 56 kbit/s @ 122 ms down and 33 kbit/s @ 49 ms up ifconfig lo0 alias 127.0.0.101 ipfw -q add 10 pipe 10 ip from any to 127.0.0.101 in ipfw -q pipe 10 config bw 33kbit/s queue 0 delay 49ms ipfw -q add 11 pipe 11 ip from 127.0.0.101 to any in ipfw -q pipe 11 config bw 56kbit/s queue 0 delay 122ms 128k ISDN-BA: 128 kbit/s @ 56 ms down and 128 kbit/s @ 22 ms up ifconfig lo0 alias 127.0.0.102 ipfw -q add 12 pipe 12 ip from any to 127.0.0.102 in ipfw -q pipe 12 config bw 128kbit/s queue 0 delay 22ms ipfw -q add 13 pipe 13 ip from 127.0.0.102 to any in ipfw -q pipe 13 config bw 128kbit/s queue 0 delay 56ms 512k/64k ADSL: 512 kbit/s @ 38 ms down and 64 kbit/s @ 20 ms up ifconfig lo0 alias 127.0.0.103 ipfw -q add 14 pipe 14 ip from any to 127.0.0.103 in ipfw -q pipe 14 config bw 64kbit/s queue 0 delay 20ms ipfw -q add 15 pipe 15 ip from 127.0.0.103 to any in ipfw -q pipe 15 config bw 512kbit/s queue 0 delay 38ms 1500k/256k ADSL: 1500 kbit/s @ 23 ms down and 256 kbit/s @ 16 ms up ifconfig lo0 alias 127.0.0.104 ipfw -q add 16 pipe 16 ip from any to 127.0.0.104 in ipfw -q pipe 16 config bw 256kbit/s queue 0 delay 16ms ipfw -q add 17 pipe 17 ip from 127.0.0.104 to any in ipfw -q pipe 17 config bw 1500kbit/s queue 0 delay 23ms 8000k/1000k ADSL: 8000 kbit/s @ 16 ms down and 1000 kbit/s @ 15 ms up ifconfig lo0 alias 127.0.0.105 ipfw -q add 18 pipe 18 ip from any to 127.0.0.105 in ipfw -q pipe 18 config bw 1000kbit/s queue 0 delay 15ms ipfw -q add 19 pipe 19 ip from 127.0.0.105 to any in ipfw -q pipe 19 config bw 8000kbit/s queue 0 delay 16ms =================================================================== 56k modem: 56 kbit/s @ 122 ms down and 33 kbit/s @ 49 ms up =================================================================== fetch ftp://127.0.0.101/pub/test_small Receiving test_small (40960 bytes): 100% 40960 bytes transferred in 6.1 seconds (6.58 kBps) Clock time for transfer = 8 seconds =================================================================== 128k ISDN-BA: 128 kbit/s @ 56 ms down and 128 kbit/s @ 22 ms up =================================================================== fetch ftp://127.0.0.102/pub/test_small Receiving test_small (40960 bytes): 100% 40960 bytes transferred in 2.7 seconds (15.06 kBps) Clock time for transfer = 4 seconds =================================================================== 512k/64k ADSL: 512 kbit/s @ 38 ms down and 64 kbit/s @ 20 ms up =================================================================== fetch ftp://127.0.0.103/pub/test_small Receiving test_small (40960 bytes): 100% 40960 bytes transferred in 0.7 seconds (57.42 kBps) Clock time for transfer = 1 seconds =================================================================== 1500k/256k ADSL: 1500 kbit/s @ 23 ms down and 256 kbit/s @ 16 ms up =================================================================== fetch ftp://127.0.0.104/pub/test_small Receiving test_small (40960 bytes): 100% 40960 bytes transferred in 0.3 seconds (126.33 kBps) Clock time for transfer = 1 seconds =================================================================== 8000k/1000k ADSL: 8000 kbit/s @ 16 ms down and 1000 kbit/s @ 15 ms up =================================================================== fetch ftp://127.0.0.105/pub/test_small Receiving test_small (40960 bytes): 100% 40960 bytes transferred in 0.2 seconds (202.97 kBps) Clock time for transfer = 1 seconds