Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

VB6 - SimpleServer Stress Test

$
0
0
I have been fairly satisfied with the performance of SimpleSock, but even though SimpleServer is being used successfully in a couple of server routines, I have not been able to stress test it. I would like to thank dilettante for providing the test routine for MSWinSck. After modifying the routines to use SimpleSock and SimpleServer, the SimpleServer routine failed the test miserably. It ran fine when tested with the default conditions (5 Clients, 100 Sends, same machine), but when I moved the client to a different machine, it failed at 3 Clients. The mode of failure was an incorrect calculation of the record length, which left the server waiting for the rest of the record. The point at which the failure occurred was not consistent, which made it difficult to troubleshoot. This is the relative debug output from one such failure.
-----------------------------------------------
FD_READ 664 = (socket 3)
InBuff 0
OK Bytes obtained from buffer: 5840 (4 x 1460)
Header:
01 01 00 00 00 00 28 57 (10327)
FD_READ 860 (socket 1)
InBuff 5832
OK Bytes obtained from buffer: 8192
Header:
87 88 89 8A 8B 8C 8D 8E
FD_READ 664 = (socket 3)
InBuff 3689
OK Bytes obtained from buffer: 4495
-----------------------------------------------
Socket 3 received 5,840 bytes. This represents 4 packets of 1,460 bytes each. Socket 1 then received 8,192 bytes. This represents the maximum Winsock buffer size this particular machine can handle. But that buffer already contained 5,832 bytes. This is equal to what socket 3 received less the header bytes.

To understand this situation better, I ran a packet sniffer and captured a different failure.
Code:

socket packet
65460 398 - sending 10327 bytes -  1513-61 = 1452 bytes
65460 399 - 1513-53 = 1460 bytes
65460 401 - 1513-53 = 1460 bytes
65460 402 - 1513-53 = 1460 bytes
65460 404 - 1513-53 = 1460 bytes
65460 405 - 1513-53 = 1460 bytes
65460 407 - 1513-53 = 1460 bytes
65460 408 - 168-53 = 115 bytes    Total = 10327 bytes

65461 416 - sending 10327 bytes -  1513-61 = 1452 bytes
65459 417 - sending 10768 bytes -  1513-61 = 1452 bytes
65459 418 - 1513-53 = 1460 bytes
65459 420 - 1513-53 = 1460 bytes
65459 421 - 1513-53 = 1460 bytes
65459 423 - 1513-53 = 1460 bytes
65459 424 - 1513-53 = 1460 bytes
65459 426 - 1513-53 = 1460 bytes
65459 427 - 609-53 = 556 bytes    Total = 10768 bytes
65461 429 - 1513-53 = 1460 bytes
65461 437 - 1513-53 = 1460 bytes
65461 438 - 1513-53 = 1460 bytes
65461 440 - 1513-53 = 1460 bytes
65461 441 - 1513-53 = 1460 bytes
65461 443 - 1513-53 = 1460 bytes
65461 444 - 168-53 = 115 bytes    Total = 10327 bytes

The first transfer (socket 65460) represents a normal transfer (8 packets totaling 10,327 bytes. On the second transfer, socket 65461 received a single packet, and was then interrupted by a transfer to socket 65459. This is what caused the failure, and is a real world scenario. This is because the sending programs are 3 separate applications operating independently.

SimpleServer originally extracted all the bytes received by a socket, and accumulated and analyzed them in the "DataArrival" routine. Any left over bytes were retained, to be included in the next record. This worked well in SimpleSock because it only supported a single socket. Even though there are independent routines for each socket (defined by Index), the variables defined within each routine appear to be common. The solution was to define those variables (RecLen/Type) as an array, and let the local buffer in the class instance (m_bRecvBuffer) accumulate bytes until the entire record is received. This uses a feature that has always existed in SimpleServer that allows you to extract a restricted number of bytes (maxLen). This is used to extract the header, which I used to define the length of the following record. If you decide that the length will include the header, a routine called PeekData was added that allows you to copy the number of bytes needed, but leave them in place.

J.A. Coutts
Attached Files

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>