Skip to content

Instantly share code, notes, and snippets.

@ivan4th
Created March 15, 2021 16:03
Show Gist options
  • Save ivan4th/af7ca91857ea05aa35c7ab4773b089f8 to your computer and use it in GitHub Desktop.
Save ivan4th/af7ca91857ea05aa35c7ab4773b089f8 to your computer and use it in GitHub Desktop.
VPP UDP Test
FROM upg:debug
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y libssl-dev git curl wget iproute2 dumb-init gdb \
nginx gnupg apt-transport-https netcat tcpdump ethtool socat
COPY start.sh /
COPY test.sh /
ENTRYPOINT ["dumb-init", "--"]
CMD ["/start.sh"]
#!/bin/bash
set -u -e -x
mtu="${MTU:-1500}"
ctlsock="/run/vpp/cli-vpp1.sock"
function ctl {
vppctl -s "${ctlsock}" "$@"
}
function config_vpp {
while [[ ! -e ${ctlsock} ]]; do
sleep 1
done
ctl create host-interface name vpp0
ctl set interface state host-vpp0 up
ctl set interface ip address host-vpp0 10.0.0.2/24
ctl set interface mtu "${mtu}" host-vpp0
ctl test echo server uri udp://10.0.0.2/10000 fifo-size 65536
ctl session enable
}
ip netns add client
ip link add vpp0 type veth peer name client
ip link set dev client netns client
ip netns exec client ip link set dev lo up
ip netns exec client ip link set dev client up mtu "${mtu}"
ip netns exec client ip addr add 10.0.0.1/24 dev client
ip link set dev vpp0 up mtu "${mtu}"
ethtool -K vpp0 gro off gso off
config_vpp &
# echo 'run' > /tmp/cmds
# echo 'bt' >> /tmp/cmds
# gdb -x /tmp/cmds --args \
/usr/bin/vpp \
unix { nodaemon cli-listen "${ctlsock}" } \
api-segment { prefix vpp1 } \
cpu { workers 0 } \
udp { mtu 12000 }
#!/bin/bash
set -u -e
function genstr {
echo -n {A..Z}{a..z}{A..Z} | head -c$1
}
function test {
str="$(genstr $1)"
out="$(echo -n "${str}" | ip netns exec client socat -b1000000 - udp:10.0.0.2:10000)"
if [[ "${str}" == "${out}" ]]; then
echo "PASS: $1"
else
echo "FAIL: $1"
fi
}
test 100
test 1400
test 1908
test 1909
test 3000
test 8000
test 11000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment