l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2004 Feb 29 23:44

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] Very slow TCP transfer over loopback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] Very slow TCP transfer over loopback



Hello All,

Got a mystery here... transferring data over the loopback interface
on a old RHAS 2.1 kernel (2.4.9-e.25enterprise) even a modern 2.6.1
kernel, is _very_ slow.  When the SO_RCVBUF is set low.

  As you can see from the tcpdump below after the session gets going,
only one data packet is exchanged every .2 seconds, the sending side
of the pipe seems to be waiting for something...

- Anyone have a place to look in the RFCs or such that would explain 
  why it's waiting, for what?

    Thanks,
      Mike

ps: the RCVBUF can be changed upto 5460 bytes and same problem...

pps: if you move the RCVBUF setting to change the "accept_sock"
     instead of the "file", then the problem goes away regardless
     of what size.

tcpdump when RCVBUF is 1024
===
1078104350.943758 127.0.0.1.37612 > 127.0.0.1.2222: S 1206126103:1206126103(0) win 32767 <mss 16396,sackOK,timestamp 1050688520 0,nop,wscale 0> (DF)
1078104350.943788 127.0.0.1.2222 > 127.0.0.1.37612: S 1215430393:1215430393(0) ack 1206126104 win 32767 <mss 16396,sackOK,timestamp 1050688520 1050688520,nop,wscale 0> (DF)
1078104350.943801 127.0.0.1.37612 > 127.0.0.1.2222: . ack 1 win 32767 <nop,nop,timestamp 1050688520 1050688520> (DF)
1078104350.944058 127.0.0.1.37612 > 127.0.0.1.2222: P 1:8193(8192) ack 1 win 32767 <nop,nop,timestamp 1050688520 1050688520> (DF)
1078104350.944069 127.0.0.1.2222 > 127.0.0.1.37612: . ack 8193 win 24575 <nop,nop,timestamp 1050688520 1050688520> (DF)
1078104350.944143 127.0.0.1.37612 > 127.0.0.1.2222: P 8193:16385(8192) ack 1 win 32767 <nop,nop,timestamp 1050688520 1050688520> (DF)
1078104350.944253 127.0.0.1.37612 > 127.0.0.1.2222: . 16385:32768(16383) ack 1 win 32767 <nop,nop,timestamp 1050688521 1050688520> (DF)
1078104350.944292 127.0.0.1.2222 > 127.0.0.1.37612: . ack 32768 win 1536 <nop,nop,timestamp 1050688521 1050688520> (DF)
1078104350.944308 127.0.0.1.37612 > 127.0.0.1.2222: P 32768:32769(1) ack 1 win 32767 <nop,nop,timestamp 1050688521 1050688521> (DF)
1078104350.944321 127.0.0.1.2222 > 127.0.0.1.37612: . ack 32769 win 1536 <nop,nop,timestamp 1050688521 1050688521> (DF)
1078104351.145164 127.0.0.1.37612 > 127.0.0.1.2222: P 32769:34305(1536) ack 1 win 32767 <nop,nop,timestamp 1050688722 1050688521> (DF)
1078104351.145219 127.0.0.1.2222 > 127.0.0.1.37612: . ack 34305 win 1536 <nop,nop,timestamp 1050688722 1050688722> (DF)
1078104351.346130 127.0.0.1.37612 > 127.0.0.1.2222: P 34305:35841(1536) ack 1 win 32767 <nop,nop,timestamp 1050688923 1050688722> (DF)
1078104351.346185 127.0.0.1.2222 > 127.0.0.1.37612: . ack 35841 win 1536 <nop,nop,timestamp 1050688923 1050688923> (DF)
1078104351.547093 127.0.0.1.37612 > 127.0.0.1.2222: P 35841:37377(1536) ack 1 win 32767 <nop,nop,timestamp 1050689124 1050688923> (DF)
1078104351.547147 127.0.0.1.2222 > 127.0.0.1.37612: . ack 37377 win 1536 <nop,nop,timestamp 1050689124 1050689124> (DF)
1078104351.748059 127.0.0.1.37612 > 127.0.0.1.2222: P 37377:38913(1536) ack 1 win 32767 <nop,nop,timestamp 1050689325 1050689124> (DF)
1078104351.748111 127.0.0.1.2222 > 127.0.0.1.37612: . ack 38913 win 1536 <nop,nop,timestamp 1050689325 1050689325> (DF)
1078104351.949030 127.0.0.1.37612 > 127.0.0.1.2222: P 38913:40449(1536) ack 1 win 32767 <nop,nop,timestamp 1050689526 1050689325> (DF)
1078104351.949091 127.0.0.1.2222 > 127.0.0.1.37612: . ack 40449 win 1536 <nop,nop,timestamp 1050689526 1050689526> (DF)
1078104352.150001 127.0.0.1.37612 > 127.0.0.1.2222: P 40449:41985(1536) ack 1 win 32767 <nop,nop,timestamp 1050689727 1050689526> (DF)
1078104352.150060 127.0.0.1.2222 > 127.0.0.1.37612: . ack 41985 win 1536 <nop,nop,timestamp 1050689727 1050689727> (DF)
===

server.c
===
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

#define BEFORE_ACCEPT 0

int main(int argc, char *argv[])
{
  int accept_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  int option = 1;
  int file;
  socklen_t accept_addr_len;
  struct sockaddr_in accept_addr;
  char buffer[1<<16];

  memset(&accept_addr, 0, sizeof(accept_addr));
  accept_addr.sin_family = AF_INET;
  accept_addr.sin_port = htons(2222);
  inet_aton("0.0.0.0", &accept_addr.sin_addr);

  setsockopt(accept_sock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
  bind(accept_sock, (struct sockaddr *) &accept_addr, sizeof(accept_addr));

  listen(accept_sock, 128);

#ifdef BEFORE_ACCEPT
  if (!(argc == 2 && sscanf(argv[1], "%d", &option)))
    option = 1024;

  setsockopt(accept_sock, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
#endif

  accept_addr_len = sizeof(accept_addr);
  file = accept(accept_sock, (struct sockaddr *) &accept_addr, &accept_addr_len);

#ifndef BEFORE_ACCEPT
  if (!(argc == 2 && sscanf(argv[1], "%d", &option)))
    option = 1024;

  setsockopt(accept_sock, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
#endif
  while (read(file, &buffer, sizeof(buffer)));

  return 0;
}
===

How to run server:
===
msimons@fizban:~/www/tests/slow_loopback$ gcc -Wall -W s.c
msimons@fizban:~/www/tests/slow_loopback$ ./a.out

# to run with a given buffer size
msimons@fizban:~/www/tests/slow_loopback$ ./a.out 5460
===

How to run client:
===
msimons@fizban:~/www/tests/slow_loopback$ dd if=/dev/zero bs=1024 count=1024 | nc localhost 2222
===
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.