#!/usr/bin/bpftrace # # Hook TCP listener connection completion and print the client's reported initial window size. # # You can see that rcv_wnd for the server socket is greatly decreased # if a Linux client sets a small SO_RCVBUF: # ```py # sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, int(sys.argv[1]) if len(sys.argv) > 1 else 512) # ``` #include BEGIN { printf("%-16s %-24s %-8s %-8s\n", "", "Elapsed(us)", "snd_cwnd", "rcv_wnd", "snd_wnd"); } kprobe:tcp_finish_connect { $tcps = (struct tcp_sock*)arg0; printf("rcv\t\t0x%llx\t%lld\t%d\t\t**%d**\t\t%d\n", arg0, elapsed/1000, $tcps->snd_cwnd, $tcps->rcv_wnd, $tcps->snd_wnd); }