Last active
December 23, 2015 13:59
-
-
Save jpetazzo/6645281 to your computer and use it in GitHub Desktop.
Test container-to-container speed
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/sh | |
set -ex | |
which iperf >/dev/null || apt-get install iperf | |
mkdir -p /var/run/netns | |
unshare --net -- sh -c "sleep 3; exec iperf -s" & | |
PID1=$! | |
ln -sf /proc/$PID1/ns/net /var/run/netns/ns1 | |
unshare --net -- sh -c "sleep 3; exec iperf -c 10.1.1.1 -i 1" & | |
PID2=$! | |
ln -sf /proc/$PID2/ns/net /var/run/netns/ns2 | |
if ip link ls br0 | |
then true | |
else | |
ip link add br0 type bridge | |
ip link set br0 up | |
fi | |
for N in 1 2 | |
do | |
ip link add v$N type veth peer name e$N | |
ip link set v$N up master br0 | |
ip link set e$N netns ns$N | |
ip netns exec ns$N ip link set e$N up | |
ip netns exec ns$N ip link set lo up | |
ip netns exec ns$N ip addr add 10.1.1.$N/24 dev e$N | |
done | |
wait $PID2 | |
kill $PID1 |
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/sh | |
set -ex | |
which iperf >/dev/null || apt-get install iperf | |
iperf -s & | |
PID1=$! | |
iperf -c 127.0.0.1 -i 1 | |
kill $PID1 |
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/sh | |
set -ex | |
which iperf >/dev/null || apt-get install iperf | |
mkdir -p /var/run/netns | |
unshare --net -- sh -c "sleep 3; exec iperf -s" & | |
PID1=$! | |
ln -sf /proc/$PID1/ns/net /var/run/netns/ns1 | |
unshare --net -- sh -c "sleep 3; exec iperf -c 10.1.1.1 -i 1" & | |
PID2=$! | |
ln -sf /proc/$PID2/ns/net /var/run/netns/ns2 | |
ip link add e1 type veth peer name e2 | |
for N in 1 2 | |
do | |
ip link set e$N netns ns$N | |
ip netns exec ns$N ip link set lo up | |
ip netns exec ns$N ip link set e$N up | |
ip netns exec ns$N ip addr add 10.1.1.$N/24 dev e$N | |
done | |
wait $PID2 | |
kill $PID1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment