Ethernet and Coffee

How to get the Linux DB2 ODBC driver to use a high performance TCP Window Scale factor

All commands below were run with DB2 ODBC Driver on RHEL7 with kernel 3.10.0-957.1.3.el7.x86_64.

First we make a call to the db2cli utility to see the default behavior. I’m passing bogus credentials to db2cli becaue I don’t care if the actual database connection is successful, I just want to see the TCP SYN so I can verify the wscale value.

While I executed the above db2cli command I had tcpdump running in another shell. I’m using a tcpdump capture filter to just get SYNs and FINs from a specific subnet where my DB2 server lives.

Notice in the following TCPDUMP output the first packet has wscale value of 1. It’s bolded but you may have to scroll over to the right to see it. Note that the client ip = and the server ip =

That wscale=1 value effectively limits our TCP receive window to 128kbytes which is pretty small in today’s world of high bandwidth WAN links.

Now we’ll set an ENV var called DB2SORCVBUF to 512000, run the db2cli command again, and watch the TCPDUMP output.

This time, TCPDUMP shows a window scale value of 4 which is correct for a 512kbyte calculated window size.

Now, as long as our DB2 queries return large enough amounts of data we’ll be able to actually use the bandwidth available to us over long fat network pipes.

I found the DB2SORCVBUF environment variable on page 252 of this IBM DB2 client v9 PDF.

There is also some worthwhile information about DB2 and TCP Window Scaling on page 146 of this IBM DB2 Connect v10.5 PDF.