Created
April 3, 2013 14:02
-
-
Save wenjianhn/5301474 to your computer and use it in GitHub Desktop.
"conntrack -I" benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $UID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
service conntrackd stop | |
# stop conntrackd.The daemon maybe writes the information about destroyed connections to a logfile. | |
# /var/log/conntrackd-stats.log | |
apt-get install -y conntrack | |
# max=`sudo sysctl -n net.netfilter.nf_conntrack_max` | |
# current=`sudo conntrack -C` | |
# reserved=256 | |
echo -e "\nstart benchmarking" | |
start=$(($(date +%s%N)/1000000)) | |
available=65535 | |
while [ $available -gt 0 ] | |
do | |
src=1.2.3.4 | |
# if we use sudo here, a lot of log will be created in /var/log/auth.log | |
conntrack -I --protonum tcp --timeout 120 --src 1.2.3.4 --sport 65535 --dst 8.8.8.8 --dport $available --state ESTABLISHED 2> /dev/null | |
let available-=1 | |
done | |
echo $(($(date +%s%N)/1000000-start)) ms used | |
sudo conntrack -D -s $src 1> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment