1VMOD_TCP(3)                                                        VMOD_TCP(3)
2
3
4

NAME

6       vmod_tcp - TCP vmod
7

SYNOPSIS

9          import tcp [from "path"] ;
10
11          INT congestion_algorithm(STRING algorithm)
12
13          VOID dump_info()
14
15          REAL get_estimated_rtt()
16
17          VOID set_socket_pace(INT)
18

DESCRIPTION

20       The TCP vmod opens for access and modification of client TCP connection
21       attributes from VCL.
22
23       Primary use is for rate limiting (pacing) using the fq  network  sched‐
24       uler on recent Linux systems.
25
26       Example:
27
28          vcl 4.0;
29
30          import tcp;
31
32          backend default { .host = "192.0.2.11"; .port = "8080"; }
33
34          sub vcl_recv {
35              # Shape (pace) the data rate to avoid filling router buffers for a
36              # single client.
37              if (req.url ~ ".mp4$") {
38                      tcp.set_socket_pace(1000);   # KB/s.
39              }
40
41              # We want to change the congestion control algorithm.
42              if (tcp.get_estimated_rtt() > 300) {
43                  set req.http.x-tcp = tcp.congestion_algorithm("hybla");
44              }
45          }
46
47   INT congestion_algorithm(STRING algorithm)
48       Set  the  client socket congestion control algorithm to S. Returns 0 on
49       success, and -1 on error.
50
51       Example:
52
53          sub vcl_recv {
54              set req.http.x-tcp = tcp.congestion_algorithm("cubic");
55          }
56
57   VOID dump_info()
58       Write the contents of the TCP_INFO data structure into varnishlog.
59
60       Example:
61
62          tcp.dump_info();
63
64       Example varnishlog output:
65
66          -   VCL_Log        tcpi: snd_mss=1448 rcv_mss=536 lost=0 retrans=0
67          -   VCL_Log        tcpi2: pmtu=1500 rtt=152000 rttvar=76000 snd_cwnd=10 advmss=1448 reordering=3
68          -   VCL_Log        getsockopt() returned: cubic
69
70   REAL get_estimated_rtt()
71       Get the estimated round-trip-time for the  client  socket.  Unit:  mil‐
72       liseconds.
73
74       Example:
75
76          if (tcp.get_estimated_rtt() > 300) {
77              std.log("client is far away.");
78          }
79
80   VOID set_socket_pace(INT)
81       Set  socket  pacing on client-side TCP connection to PACE KB/s. Network
82       interface used must be using a supported scheduler. (fq)
83
84       Example:
85
86          tcp.set_socket_pace(1000);
87
88
89
90
91                                                                   VMOD_TCP(3)
Impressum