Jay Taylor's notes

back to listing index

Get the current/default value of TCP initcwnd on Linux

[web search]
Original source (superuser.com)
Tags: linux tuning tcp initcwnd cdn superuser.com
Clipped on: 2016-11-10

I can manipulate such value with:

ip route change ... initcwnd 10

and then have a feedback with:

ip route show

But what about the default value before any modification? Is there a way to query that value from the system?

Alternatively, can you provide a valid reference that shows the default hardcoded value for each kernel version?

asked Feb 28 '13 at 14:01
Image (Asset 2/14) alt=
cYrus
12.4k33860
up vote 8 down vote accepted
+50

I don't really know for sure, but this seems like a legit reference

Hunch:

$ grep -A 2 initcwnd `find /usr/src/linux/include -type f -iname '*h'`

out:

/usr/src/linux/include/net/tcp.h:
/* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */
#define TCP_INIT_CWND          10
answered Mar 2 '13 at 19:41
Image (Asset 3/14) alt=
   upvote
  flag
Yes, grepping the code is always a good idea! – cYrus Mar 3 '13 at 11:59

Well, I can't say I'm 100 % sure this should be the answer, buuut, as it often comes, ss is the good choice to get some info revealed, for e. g.:

 ss -nli|fgrep cwnd
     westwood rto:1000 mss:536 cwnd:10
     westwood rto:1000 mss:536 cwnd:10
     westwood rto:1000 mss:536 cwnd:10

-n is typical to get rid of annoying DNS resolving, -l is we stick to listening sockets only and -i (the key) is "Show internal TCP information". As it can be seen, both congestion algorithm and default cwnd are shown.

answered Feb 15 at 20:43
Image (Asset 4/14) alt=
poige
1414

If I understood you correctly, you're looking for the initial value of the snd_cwnd parameter set when a TCP socket is initialized.

It looks like starting with linux kernel 2.6.39, a macro TCP_INIT_CWND has been introduced in linux/include/net/tcp.h which populates the value of snd_cwnd when initializing a TCP socket.

I know where this code is in the kernel for IPv4, and unfortunately it does not seem to use any macro to populate the value for kernels older than 2.6.39

/* net/ipv4/tcp_ipv4.c from 2.6.37 kernel */
static int tcp_v4_init_sock(struct sock *sk)
{
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);

        ....
        ....
        ....

        /* So many TCP implementations out there (incorrectly) count the
         * initial SYN frame in their delayed-ACK and congestion control
         * algorithms that we must have the following bandaid to talk
         * efficiently to them.  -DaveM
         */
        tp->snd_cwnd = 2;

        ....
        ....
        ....
}

A similar init code exists for IPv6 as well inside tcp_v6_init_sock() function in net/ipv6/tcp_ipv6.c

answered Mar 2 '13 at 19:44
Image (Asset 5/14) alt=
Tuxdude
49949
   upvote
  flag
+1, that web site is pretty useful. – cYrus Mar 3 '13 at 12:11

Your Answer

asked

3 years ago

viewed

7452 times

active

8 months ago

Hot Network Questions

Technology Life / Arts Culture / Recreation Science Other
  1. Stack Overflow
  2. Server Fault
  3. Super User
  4. Web Applications
  5. Ask Ubuntu
  6. Webmasters
  7. Game Development
  8. TeX - LaTeX
  1. Software Engineering
  2. Unix & Linux
  3. Ask Different (Apple)
  4. WordPress Development
  5. Geographic Information Systems
  6. Electrical Engineering
  7. Android Enthusiasts
  8. Information Security
  1. Database Administrators
  2. Drupal Answers
  3. SharePoint
  4. User Experience
  5. Mathematica
  6. Salesforce
  7. ExpressionEngine® Answers
  8. Cryptography
  1. Code Review
  2. Magento
  3. Signal Processing
  4. Raspberry Pi
  5. Programming Puzzles & Code Golf
  6. more (7)
  1. Photography
  2. Science Fiction & Fantasy
  3. Graphic Design
  4. Movies & TV
  5. Music: Practice & Theory
  6. Seasoned Advice (cooking)
  7. Home Improvement
  8. Personal Finance & Money
  1. Academia
  2. more (8)
  1. English Language & Usage
  2. Skeptics
  3. Mi Yodeya (Judaism)
  4. Travel
  5. Christianity
  6. English Language Learners
  7. Japanese Language
  8. Arqade (gaming)
  1. Bicycles
  2. Role-playing Games
  3. Anime & Manga
  4. Motor Vehicle Maintenance & Repair
  5. more (17)
  1. MathOverflow
  2. Mathematics
  3. Cross Validated (stats)
  4. Theoretical Computer Science
  5. Physics
  6. Chemistry
  7. Biology
  8. Computer Science
  1. Philosophy
  2. more (3)
  1. Meta Stack Exchange
  2. Stack Apps
  3. Area 51
  4. Stack Overflow Talent
site design / logo © 2016 Stack Exchange Inc; user contributions licensed under cc by-sa 3.0 with attribution required
rev 2016.11.10.4184