2001-11-27 06:28:59

by Jordan Russell

[permalink] [raw]
Subject: 2.4 TCP performance difference - feature or flaw?

Hi,

I've encountered an odd difference in TCP performance between the 2.4.15 and
2.2.20 kernels. Perhaps someone can explain this phenomenon...
(I'm not a kernel hacker.)

Background:
I administer my Linux box over a LAN via SSH2 from a Windows 2000 machine.
OpenSSH 3.0.1 is used on the Linux side and PuTTY on the Windows side.

The issue:
I have my keyboard repeat rate set high (31 chars/sec). When I'm SSH'ed into
Linux and I hold down a letter key (for example), it does not repeat
"smoothly" with a 2.4 kernel installed. The characters seem to show up about
2 at a time. It's as if I'm going over a high-latency connection; I'm not.

If I revert to 2.2.20, this effect does not occur. It also does not occur
when I SSH into OpenBSD 2.9.

So apparently the effect is caused by some change in the 2.4 kernel. But I'm
very curious to know what it is, and if there is maybe some way to go back
to the "old" behavior. (It drives me nuts!)

tcpdump seems to shed some light. Here are some tcpdump log excerpts of keys
being repeated and echoed back...

Linux 2.4.15
- Notice that there is a 40 millisecond delay every 5 packets. This won't do
because the keys repeat faster than that!

20:33:47.174648 w2k.1616 > lnx.ssh: P 264:308(44) ack 133 win 16860 (DF)
20:33:47.174675 lnx.ssh > w2k.1616: . ack 308 win 16080 (DF) [tos 0x10]
20:33:47.174902 lnx.ssh > w2k.1616: P 133:177(44) ack 308 win 16080 (DF)
[tos 0x10]
20:33:47.175564 w2k.1616 > lnx.ssh: P 308:352(44) ack 177 win 16816 (DF)
20:33:47.210744 lnx.ssh > w2k.1616: . ack 352 win 16080 (DF) [tos 0x10]
20:33:47.210945 w2k.1616 > lnx.ssh: P 352:396(44) ack 177 win 16816 (DF)
20:33:47.210969 lnx.ssh > w2k.1616: . ack 396 win 16080 (DF) [tos 0x10]
20:33:47.211181 lnx.ssh > w2k.1616: P 177:221(44) ack 396 win 16080 (DF)
[tos 0x10]
20:33:47.211632 w2k.1616 > lnx.ssh: P 396:440(44) ack 221 win 16772 (DF)
20:33:47.250743 lnx.ssh > w2k.1616: . ack 440 win 16080 (DF) [tos 0x10]
20:33:47.250940 w2k.1616 > lnx.ssh: P 440:484(44) ack 221 win 16772 (DF)
20:33:47.250963 lnx.ssh > w2k.1616: . ack 484 win 16080 (DF) [tos 0x10]
20:33:47.251181 lnx.ssh > w2k.1616: P 221:265(44) ack 484 win 16080 (DF)
[tos 0x10]
20:33:47.251629 w2k.1616 > lnx.ssh: P 484:528(44) ack 265 win 16728 (DF)
20:33:47.290744 lnx.ssh > w2k.1616: . ack 528 win 16080 (DF) [tos 0x10]

Linux 2.2.20
- The 40 millisecond delay isn't there. The packets seem to be sent/received
at the right time.

20:39:45.278313 w2k.1628 > lnx.ssh: P 264:308(44) ack 133 win 17388 (DF)
20:39:45.278712 lnx.ssh > w2k.1628: P 133:177(44) ack 308 win 32120 (DF)
[tos 0x10]
20:39:45.279166 w2k.1628 > lnx.ssh: P 308:352(44) ack 177 win 17344 (DF)
20:39:45.298612 lnx.ssh > w2k.1628: . ack 352 win 32120 (DF) [tos 0x10]
20:39:45.309020 w2k.1628 > lnx.ssh: P 352:396(44) ack 177 win 17344 (DF)
20:39:45.309407 lnx.ssh > w2k.1628: P 177:221(44) ack 396 win 32120 (DF)
[tos 0x10]
20:39:45.309816 w2k.1628 > lnx.ssh: P 396:440(44) ack 221 win 17300 (DF)
20:39:45.328613 lnx.ssh > w2k.1628: . ack 440 win 32120 (DF) [tos 0x10]
20:39:45.339798 w2k.1628 > lnx.ssh: P 440:484(44) ack 221 win 17300 (DF)
20:39:45.340039 lnx.ssh > w2k.1628: P 221:265(44) ack 484 win 32120 (DF)
[tos 0x10]
20:39:45.340587 w2k.1628 > lnx.ssh: P 484:528(44) ack 265 win 17256 (DF)
20:39:45.358612 lnx.ssh > w2k.1628: . ack 528 win 32120 (DF) [tos 0x10]


Thanks,
Jordan Russell


2001-11-27 15:33:06

by Eric Weigle

[permalink] [raw]
Subject: Re: 2.4 TCP performance difference - feature or flaw?

Morning-

First, don't use 2.4.15, there's a known bug that causes "minor" FS corruption
on umount. Upgrade to 2.4.16 and force a fsck.

> The issue:
> I have my keyboard repeat rate set high (31 chars/sec). When I'm SSH'ed into
> Linux and I hold down a letter key (for example), it does not repeat
> "smoothly" with a 2.4 kernel installed. The characters seem to show up about
> 2 at a time. It's as if I'm going over a high-latency connection; I'm not.
This might be an issue with the Nagle algorithm; this basically sets a
time to wait for more input before sending a packet. That way fewer total
packets are sent over interactive connections (sending one byte payloads
with many-byte headers wastes BW) and generally it is a Good Idea. If this is
indeed the problem it might be because 2.2.20 doesn't implement the algorithm
quite the same way as 2.4.15 but that's beyond my knowledge.

If it really bugs you get the SSH client/server source and grep for where
the socket options are set `grep -r "setsockopt" *` and see if the TCP_NODELAY
flag is set in some call. If not just add code like:
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(int))<0)
fprintf(stderr, "Failed to turn of Nagle algorithm");
and see if that does anything.

If the code is already there, then there might actually be a minor bug in
the kernel.


-Eric

--
--------------------------------------------
Eric H. Weigle CCS-1, RADIANT team
[email protected] Los Alamos National Lab
(505) 665-4937 http://home.lanl.gov/ehw/
--------------------------------------------