ipfw -f -q flush ipfw -f -q pipe flush ipfw add pipe 1 ip from any to any in recv em0 ipfw add pipe 2 ip from any to any out xmit em0 ipfw pipe 1 config bw $1Mbit/s delay $2ms queue $3 ipfw pipe 2 config bw $1Mbit/s delay $2ms queue $3 # 1. compiling Kernel Options # options IPFIREWALL # options IPFIREWALL_DEFAULT_TO_ACCEPT # options DUMMYNET # options HZ=1000 # options NMBCLUSTERS=131072 # options DEVICE_POLLING # Disable SMP as suggested by DEVICE_POLLING # 2. Add the following lines into /etc/sysctl.conf # kern.polling.enable=1 # kern.polling.user_frac=5 # kern.polling.burst_max=400 # kern.polling.each_burst=15 # net.inet.ip.intr_queue_maxlen=3000 # 3. Modify source code of ipfw and dummynet to support larger queue size # 4. Increase NIC buffer by setting EM_MAX_RXD to 4096 in /usr/src/sys/dev/em/if_em.h