home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / protocol / tcpip / 4205 < prev    next >
Encoding:
Text File  |  1992-08-26  |  4.8 KB  |  186 lines

  1. Newsgroups: comp.protocols.tcp-ip
  2. Path: sparky!uunet!drug!y
  3. From: y@drug.COM (Yoshi Mizuno)
  4. Subject: Please Help with TCP/IP TLI problem!!
  5. Message-ID: <1992Aug27.074345.28396@drug.COM>
  6. Organization: Mizuno Pharmacies
  7. Date: Thu, 27 Aug 1992 07:43:45 GMT
  8. Lines: 176
  9.  
  10.  
  11.  
  12. Hi, we encountered a problem trying to impliment our clinent/server application
  13. using TLI. I wonder if anyone can help.  
  14.  
  15. When a fast machine (SUN Sparc 630 MP) sends a bunch of TCP/IP packets to
  16. a slow machine (Sparc IPC) a lot of packets get dropped.  For example, doing
  17. spray from a fast one to the slow one, we get:
  18.  
  19.  
  20. (630MP to IPC)
  21.  
  22. yt@hana$ spray meto
  23. sending 1162 packets of lnth 86 to meto ...
  24.         in 10.4 seconds elapsed time,
  25.         658 packets (56.63%) dropped
  26. Sent:   111 packets/sec, 9.4K bytes/sec
  27. Rcvd:   48 packets/sec, 4.1K bytes/sec
  28.  
  29. With this condition, the following test program fails.  We thought that TCP/IP
  30. makes an error free connection. . .  What are we doing wrong?  Or, is this
  31. the way TCP/IP is?  
  32.  
  33.  
  34. Yoshi Mizuno, Pharm.D.             [][][]       UUCP:      uunet!drug!y
  35. Mizuno Pharmacies                  []  []       INTERNET:  y@drug.COM
  36. 4-1-24 Yushima, Bunkyo-ku        [][][][]       ISDN:      +81-3-5684-7722
  37. Tokyo 113 JAPAN                    []           G3 FAX:    +81-3-5684-7723
  38.  
  39.  
  40.  
  41. ------------------------CUT HERE--------------------------------
  42. /* tst.c */
  43.  
  44. /*    This is test program using TLI to access TCP/IP.
  45.     Server send data to client.
  46.     If this program is used with no arguments, then it is the server.
  47.     If this program gets the name of the machine where the server is
  48.     running as an argument, then it is the client.
  49.     When packets get lost in transmission, the client blocks on t_rcv forever.
  50.     I assume that the lost packets never get sent again.
  51. */
  52.  
  53. #include <stdlib.h>
  54. #include <stdio.h>
  55. #include <fcntl.h>
  56. #include <tiuser.h>
  57. #include <sys/types.h>
  58. #include <sys/socket.h>
  59. #include <netinet/in.h>
  60. #include <netdb.h>
  61.  
  62. extern int t_errno;
  63.  
  64. void ErrFn();
  65. #define Error()        ErrFn(__FILE__,__LINE__)
  66. #define Assert(b)    if(!(b)) Error()
  67. #define TLI_ERR        { t_error("t_error"); Error(); }
  68.  
  69.  
  70. #define nTimes        500
  71. #define bufsize        256
  72. #define iPort        5
  73.  
  74. main(argc,argv)
  75. int argc;
  76. char *argv[];
  77. {
  78.     int i, c, iR, g, fd;
  79.     unsigned char buf[bufsize];
  80.  
  81.     switch(argc) {
  82.     case 1:                    /* no arguments, make server and send */
  83.         fd = OpenServer();
  84.         for( c=0; c<bufsize; c++ )
  85.             buf[c] = c;
  86.         for( i=0; i<nTimes; i++ ) {
  87.             printf("put %d\n",i);
  88.             iR = t_snd(fd,buf,bufsize,0);
  89.             if(iR!=bufsize)  TLI_ERR;
  90.         }
  91.         break;
  92.     case 2:                    /* 1 argument is name of server machine, make client and receive */
  93.         fd = OpenClient(argv[1]);
  94.         for( i=0; i<nTimes; i++ ) {
  95.             printf("get %d\n",i);
  96.             for( c=0; c<bufsize; c++ ) {
  97.                 iR = t_rcv(fd,buf,1,&g);
  98.                 if(iR!=1)  TLI_ERR;
  99.                 if( *buf != c ) {
  100.                     printf("%d %d\n",*buf,c);
  101.                     Error();
  102.                 }
  103.             }
  104.         }
  105.         break;
  106.     default:
  107.         Error();
  108.     }
  109.     sleep(60);
  110.     printf("done\n");
  111.     /* the fancy functions to close TLI don't work on Sun, so forget them */
  112.     if( t_close(fd) < 0 )  TLI_ERR;
  113. }
  114.  
  115. int OpenServer() {
  116.     int fd;
  117.     struct t_bind *pBind;
  118.     struct sockaddr_in oSock;
  119.     struct t_call *pCall;
  120.  
  121.     fd = t_open("/dev/tcp",O_RDWR,NULL);
  122.     if( fd < 0 )  TLI_ERR;
  123.     pBind = (struct t_bind*)t_alloc(fd,T_BIND,T_ALL);
  124.     if(!pBind)  TLI_ERR;
  125.     pBind->qlen = 1;
  126.  
  127.     oSock.sin_family = AF_INET;
  128.     oSock.sin_addr.s_addr = INADDR_ANY;
  129.     oSock.sin_port = iPort;
  130.     pBind->addr.len = sizeof(struct sockaddr_in);
  131.     memcpy(pBind->addr.buf,&oSock,sizeof(struct sockaddr_in));
  132.  
  133.     if( t_bind(fd,pBind,pBind) < 0 )  TLI_ERR;
  134.     if( t_free((char*)pBind,T_BIND) < 0 )  TLI_ERR;
  135.     pCall = (struct t_call*)t_alloc(fd,T_CALL,T_ADDR);
  136.     if(!pCall)  TLI_ERR;
  137.     if( t_listen(fd,pCall) < 0 )  TLI_ERR;
  138.     if( t_accept(fd,fd,pCall) < 0 )  TLI_ERR;
  139.     if( t_free((char*)pCall,T_CALL) < 0 )  TLI_ERR;
  140.     return fd;
  141. }
  142.  
  143. int OpenClient(sHost)
  144. char *sHost;
  145. {
  146.     int fd;
  147.     struct t_call *pCall;
  148.     struct sockaddr_in oSock;
  149.     struct hostent *pHost;
  150.  
  151.     fd = t_open("/dev/tcp",O_RDWR,NULL);
  152.     if( fd < 0 )  TLI_ERR;
  153.     if( t_bind(fd,NULL,NULL) < 0 )  TLI_ERR;
  154.     pCall = (struct t_call*)t_alloc(fd,T_CALL,T_ADDR);
  155.     if(!pCall)  TLI_ERR;
  156.  
  157.     oSock.sin_family = AF_INET;
  158.     pHost = gethostbyname(sHost);
  159.     Assert(pHost);
  160.     memcpy(&oSock.sin_addr,pHost->h_addr,pHost->h_length);
  161.     oSock.sin_port = iPort;
  162.     pCall->addr.len = sizeof(struct sockaddr_in);
  163.     memcpy(pCall->addr.buf,&oSock,sizeof(struct sockaddr_in));
  164.  
  165.     if( t_connect(fd,pCall,NULL) < 0 ) {
  166.         if(t_errno==TLOOK)  printf("t_look=%x\n",t_look(fd));
  167.         TLI_ERR;
  168.     }
  169.     if( t_free((char*)pCall,T_CALL) < 0 )  TLI_ERR;
  170.     return fd;
  171. }
  172.  
  173. void ErrFn(s,i)
  174. char *s;
  175. int i;
  176. {
  177.     printf(" %s %d\n",s,i);
  178.     exit(1);
  179. }
  180.  
  181. -- 
  182. Yoshi Mizuno, Pharm.D.             [][][]       UUCP:       uunet!drug!y
  183. Mizuno Pharmacies                  []  []       INTERNET:  y@drug.COM
  184. 4-1-24 Yushima, Bunkyo-ku        [][][][]       ISDN:      +81-3-5684-7722
  185. Tokyo 113 JAPAN                    []           G3 FAX:    +81-3-5684-7723
  186.