!******************************************************************************!
! RMIF RDP send buffer does not overflow test case
!
! The RMIF RDP send buffer can overflow and get corrupted when large packets
! near the maximum RMIF packet size (32K) are sent. This normally happens when
! the packets are resent, when a prior packet may have over overflowed the
! send buffer. Some folks have notice that increasing the window size can help
! show the problem quicker, but we are able to reproduce it here with large
! packets sent via an RMIF SET MESSAGE
!
! Problem is:  send buffer size < (packetSize * numPackets).
!
! This test uses 3 different size large messages that will show the problem
! nomally after 50 messages, but the test adds a couple more to make
! sure that problem surfaces.
!
! <sPort>   - The KNOWN port of the server.  Client uses any available port.
! <msgCnt>  - The number of messages the client (sender) will send out.
!             Note, if you increase this, you may also have to increase the
!             test timeout value.
! <timeout> - The timeout (max time) that this test should run before aborting
!
! @bug     1112
! @author  Neon Ngo
! @since   NeXtMidas 2.5.1
!******************************************************************************!
startmacro L:sPort[-1] L:msgCnt[120] D:timeout[30]
  switch DEBUG         debug        GET DEF=false    SDEF=true
  switch DEBUGSERVER   debugs       GET DEF=^debug   SDEF=true
  switch DEBUGCLIENT   debugc       GET DEF=^debug   SDEF=true
  switch VERBOSE       verbose      GET DEF=false    SDEF=true
  switch VERBOSESERVER verboses     GET DEF=^verbose SDEF=true
  switch VERBOSECLIENT verbosec     GET DEF=^verbose SDEF=true
  switch STATEM        statemachine GET DEF=false    SDEF=true

  timer set

  ! call RMIF test framework standard setup (see included standard_rmif_procs.mminc)
  call standardSetup timeout sPort
  pipe on
    %test_rmif_rdp_send_buffer_overflow_server/id=SERVER/STATEM=^statemachine/DEBUG=^debugs/VERBOSE=^verboses/BG this ^sPort ^msgCnt
    %test_rmif_rdp_send_buffer_overflow_client/id=CLIENT/STATEM=^statemachine/DEBUG=^debugc/VERBOSE=^verbosec/BG this ^sPort ^msgCnt
  pipe off

  timer elapse
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if debug then
    say "^reg.main.name: Got message name=^msg.name fid=^msg.fid info=^msg.info data=^msg.data"
  endif

  if false then ! Your message name goes here
    !
    ! Your message(s) processing goes here
    !
  else
    call processStandardMessages
  endif
return

! These are a set of standard procedures
include standard_rmif_procs.mminc
