home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / programm / 4541 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  4.1 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!Sirius.dfn.de!chx400!news.unige.ch!ugun2b!hei.unige.ch!droux
  2. Newsgroups: comp.unix.programmer
  3. Subject: TCP reliability
  4. Message-ID: <1992Sep4.163505.1@hei.unige.ch>
  5. From: droux@hei.unige.ch
  6. Date: 4 Sep 92 16:35:05 +0200
  7. Organization: University of Geneva, Switzerland
  8. Nntp-Posting-Host: ugheia
  9. Nntp-Posting-User: droux
  10. Lines: 94
  11.  
  12.  
  13. TCP/IP BERKELEY SOCKETS: Transmission problems with doublicated packets
  14. -----------------------------------------------------------------------
  15.  
  16. We are currently implementing a distributed system providing the use of
  17. different computers (different UNIX workstations) connected by Internet.
  18. Our System is based on a server - client model using berkeley sockets.
  19.  
  20. These two entities are communicating through AF_INET family
  21. sockets of SOCK_STREAM type. Our Problem is, that a receiver implemented on
  22. a NeXT receives much more packets than the sender implemented on 
  23. a Sun workstation sends (1.3 : 1).
  24.  
  25. As TCP is known as sequenced, reliable and two-way connection based, this
  26. fact is surprising to us. Is it possible to avoid this ? 
  27.  
  28. We implemented the mechanism as follows:
  29.  
  30. OPERATING SYSTEMS:
  31.  
  32. NeXT Cube (System Release 2.1) and SUN Sparcstation 1+ (Sun OS 4.1)
  33.  
  34. CONNECTION:
  35.  
  36. a)Server side:
  37.   
  38.   if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)  /* create sockets */
  39.     err_sys("client: error during socket creation");
  40.   our_bzero((char *) &sock_addr,sizeof(sock_addr));
  41.   sock_addr.sin_family = AF_INET;           /* initializes socket addresses */ 
  42.   sock_addr.sin_port = 0;
  43.   sock_addr.sin_addr.s_addr = INADDR_ANY;
  44.   servlen = sizeof(struct sockaddr_in);
  45.   if (bind(socket_fd, (struct sockaddr *)&sock_addr, servlen))
  46.     err_sys("inet_bind_fix: error binding socket");
  47.   if (getsockname(socket_fd, (struct sockaddr *)&sock_addr, &servlen))
  48.     err_sys("inet_bind_fix: error getting socket name");
  49.     
  50. The port number is transferred using inetd to the client.
  51.  
  52. b)Client side:
  53.  
  54.   if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)  /* create sockets */
  55.     err_sys("client: error during socket creation");
  56.   if ((foreign_addr = gethostbyname(machine)) == 0)       /* get the server */
  57.     err_sys("unknown host");
  58.   our_bzero((char *) &sock_addr, servlen);
  59.   copy_struct(foreign_addr->h_addr,&sock_addr.sin_addr,
  60.     foreign_addr->h_length);
  61.   sock_addr.sin_family = AF_INET;
  62.   sock_addr.sin_port = htons(port);
  63.   do
  64.   {                                          /* connect to the power server */
  65.     connect_status = connect(socket_fd,
  66.       (struct sockaddr *)&sock_addr, servlen);  
  67.     connect_retries--;
  68.   } while((connect_status < 0) && (connect_retries));
  69.     
  70. SOCKET OPTIONS:
  71.  
  72. #define SOCKET_BUFFER_LEN 10000                 /* buffer size of a channel */
  73.  
  74.   int buf_len = SOCKET_BUFFER_LEN;         /* set new socket buffers length */
  75.   
  76.   if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 
  77.                  (char *)&buf_len, sizeof(buf_len)) == -1)
  78.     err_sys("set_sock_buf: cannot set new socket buffer length");
  79.   if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, 
  80.                  (char *)&buf_len, sizeof(buf_len)) == -1)
  81.     err_sys("set_sock_buf: cannot set new socket buffer length");
  82.  
  83. The data exchange is made by normal read() and write() calls followed by an 
  84. acknowledgement. We transmitt packets of 5000 bytes of unstructered data.
  85. If a sender send 300 packets (as a concrete example) the receiver receives
  86. over 400 packets and about 120 of them are invalid. We consider this as a
  87. serious problem since our system is based on realibility of TCP sockets.
  88. Is there a special option on sockets or another method to avoid these
  89. problems?
  90.  
  91. Special Comments:
  92. 1. If the server and the client are running on the same computer, the problem
  93.    does not occur.
  94. 2. If the NeXT (receiver client) is swapping the number of faulty packets is
  95.    increasing.
  96. 3. The number of faulty packets is somehow depending on their size.
  97.  
  98. We would be very happy about some information as our application is part
  99. of our graduation thesis.
  100.  
  101. Nicolas Droux & Daniel Liebhart
  102. Biel School of Engineering, Switzerland
  103. Computer Science Dpt.
  104. E-mail: droux@hei.unige.ch
  105.    
  106.