User guide

Ethernet Developers Guide
74
840 USE 115 00 Version 1.0
The receive state machine
(
which is described below
)
processes the response to a
re
q
uest. When the receive state machine has completed receivin
g
the response, it
chan
g
es the transmit state machine from the TX_DONE state to the WAIT_TO_TX
state.
Recall that the TransmitUserRe
q
uest saves the time. CSample_View
OnPollInterval uses this saved time to determine if a new re
q
uest needs to be
transmitted. OnPollInterval is called b
y
MFC architectural framework to process
the WM_POLL_INTERVAL sent when CMainFram class processes the window
timer messa
g
e, WM_TIMER. OnPollInterval examines the transmit state. If the
transmit state is WAIT_TO_TX, and the elapsed time from the previous transmit
re
q
uest exceeds the poll interval, then OnPollInterval calls TransmitUserRe
q
uest to
start another transaction.
B.11 Receive State Machine
The receive state machine receives a response to a transaction b
y
first readin
g
the
header, determinin
g
the size of the rest of the messa
g
e, and then readin
g
the bod
y
of the messa
g
e. The different states of the receive state machine are as follows.
RX_HEADER. In the RX_HEADER state, the receive machine is receivin
g
the
messa
g
e header.
RX_BODY. In the RX_HEADER state, the receive machine is receivin
g
the
response messa
g
e associated to the re
q
uested transaction.
DUMP_BODY. In the DUMP_BODY state, the receive messa
g
e is receivin
g
a
messa
g
e, but there is no associated transaction with respect to this messa
g
e.
The window socket DLL
g
enerates the FD_READ event whenever there is data to
be read. If onl
y
part of the data is read, it
g
enerates another event. CSample_View
OnTcpIpRead function processes the FD_READ event, and drives the receive
state machine.
When a FD_READ event is
g
enerated it is possible that the complete messa
g
e is
not present. The remote node ma
y
have attempted to send a 100 b
y
te response,
but the transport s
y
stem ma
y
have onl
y
had buffer space to transmit three b
y
tes.
The receiver will
g
et a FD_READ for the three b
y
tes. OnTcpIpRead calls
CSample_View rx_ms
g
to read the receive data into the buffer. There are three
parameters to rx_ms
g
. The first parameter is a pointer to a receive buffer. The
second input parameter is the receive size. The third parameter is both an input
and output parameter. On both input and output the third parameter is the number
of b
y
tes read. These parameters allow the processin
g
of a partiall
y
received
messa
g
e.