home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / pcc / v08n03 / netwrk.exe / LANBENCH.ZIP / NORM.BAS < prev    next >
BASIC Source File  |  1987-05-05  |  3KB  |  64 lines

  1. 10 REM NORM.BAS generates normally distributed LAN noise.
  2. 20 REM  ---------------------------------------------------------------
  3. 30 GOSUB 500'                 initialization subroutine
  4. 40 REM  ---------------------------------------------------------------
  5. 50 REM main program
  6. 60 REM    DEL        time until next net event
  7. 70 REM    NXT        time of next event
  8. 80 REM    TN         transaction number
  9. 90 REM  ---------------------------------------------------------------
  10. 100 GOSUB 310'                 get random variable in Z
  11. 110 DEL = M + SD*Z
  12. 120 NXT = TIMER+DEL
  13. 130 TN = TN+1
  14. 140 PRINT "Transaction"; TN; "in"; DEL; " seconds."
  15. 150 IF TIMER < NXT THEN 150
  16. 160 GOSUB 200'                 fire off some network activity
  17. 170 GOTO 100
  18. 180 REM  -------------------------------------------------------------
  19. 190 REM Subroutine with side effect of network activity.
  20. 200 OPEN "r", 1, FLNM$, N
  21. 210 FIELD #1, N AS Q$
  22. 220 LSET Q$ = QQ$
  23. 230 PUT #1, 1
  24. 240 GET #1, 1
  25. 250 CLOSE #1
  26. 260 RETURN
  27. 270 REM  -------------------------------------------------------------
  28. 280 REM This subroutine returns a standard normal random variable
  29. 290 REM in Z, but it has lots of side effects (TOGGLE, Z2, S, R1, R2).
  30. 300 REM See Byte Magazine, ???, for a discussion of the algorithm.
  31. 310 IF TOGGLE = 1 THEN Z=Z2: TOGGLE=0 : RETURN
  32. 320 TOGGLE=1: S=1
  33. 330 WHILE (S>=1)
  34. 340   R1=2*RND-1
  35. 350   R2=2*RND-1
  36. 360   S=R1^2 + R2^2
  37. 370 WEND
  38. 380 S=SQR(-2*LOG(S)/S)
  39. 390 Z=S*R1: Z2=S*R2
  40. 400 RETURN
  41. 410 REM  -------------------------------------------------------------
  42. 420 REM Initialization of:
  43. 430 REM    M        mean time between network events
  44. 440 REM    SD       standard deviation of time between events
  45. 450 REM    N        length of pad record
  46. 460 REM    D$       server "drive" for scratch file
  47. 470 REM    FLNM$    name of scratch file on the server  
  48. 480 REM    QQ$      pad string to be written over the network
  49. 490 REM  -------------------------------------------------------------
  50. 500 KEY (1) ON
  51. 510 ON KEY (1) GOSUB 630'   stop execution
  52. 520 REM initialize the distribution
  53. 530 RANDOMIZE TIMER
  54. 540 INPUT "enter mean time between network activity: ", M
  55. 550 INPUT "enter the standard deviation: ",SD
  56. 560 REM initialize the file to be read
  57. 570 INPUT "enter record length: ", N
  58. 580 INPUT "enter drive identifier, without the colon: ", D$
  59. 590 FLNM$ = D$ + ":junk"
  60. 600 QQ$=STRING$ (N, "q")
  61. 610 PRINT: PRINT "Hit F1 to stop."
  62. 620 RETURN
  63. 630 END'                     operator hits F1 to stop execution
  64.