Skip to main content
Version: latest

trace_tcpretrans

The trace_tcpretrans gadget tracks TCP retransmissions.

Getting started

Running the gadget:

$ kubectl gadget run ghcr.io/inspektor-gadget/gadget/trace_tcpretrans:latest [flags]

Guide

In terminal 1, start the trace_tcpretrans gadget:

$ kubectl gadget run trace_tcpretrans:latest
K8S.NODE K8S.NAMESPACE K8S.PODNAME K8S.CONTAINERNAME SRC DST COMM PID TID STATE REASON TCPFLAGS TYPE

In terminal 2, start a pod and configure the network emulator to drop 25% of the packets. This will cause TCP retransmissions:

$ kubectl create service nodeport nginx --tcp=80:80
$ kubectl create deployment nginx --image=nginx
$ kubectl run --rm -ti --privileged --image ubuntu shell -- bash
root@shell:/# apt-get update
root@shell:/# apt install -y iproute2 curl
root@shell:/# tc qdisc add dev eth0 root netem drop 25%
root@shell:/# curl nginx

The results in terminal 1 will show that some TCP transmissions cause by the dropped packets:

K8S.NODE          K8S.NAMESPACE            K8S.PODNAME              K8S.CONTAINERNAME        SRC                              DST                              COMM                    PID           TID STATE         REASON        TCPFLAGS     TYPE
minikube-docker default shell shell p/default/shell:45638 s/default/nginx:80 curl 874866 874866 2 0 SYN RETRANS

The network emulator uses a random generator to drop 25% of the packets. The results may vary.

Congratulations! You reached the end of this guide! You can now delete the pod you created:

$ kubectl delete service nginx
$ kubectl delete deployment nginx
$ kubectl delete pod shell