<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>Hi All (and Harald
in particular),</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>I have found the
following oddity in the TCP state machine:-</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>If I do an active
open from Nut/OS and the destination machine's server software is not running
the destination machine will correctly return a RST to
Nut/OS.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>At this point the
TCP state machine is in TCPS_SYN_SENT state and the incomming RST correctly
sets:-</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2>sock->so_last_error = ECONNREFUSED;<BR>sock->so_state =
TCPS_CLOSE_WAIT;</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>It does not however
remove the original active open SYN packet from the send
queue.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>Soon enough the
retransmit timer expires and Nut/OS re-sends the original SYN packet, which
again attracts a RST.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>This repeats until
the socket times out and closes and generates a LOT of useless
traffic.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>This should not
happen, RFC 793 goes into quite some detail about how RSTs should be handled but
in summary:-</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>All socket send and
receive queues should be flushed.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>The TCB should be
deleted.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>The Application
should be notified.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>The socket should go
directly to the CLOSED state.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003></SPAN><SPAN class=293101707-26082003><FONT
face=Arial size=2>Looking through tcpsm it seems Nut/OS does not handle RST's
correctly regardless of the current state.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>I've added the
following function to tcpsm.c</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>/*!<BR> *
\brief RST processing.<BR> *<BR> * \param sock Socket descriptor. This
pointer must have been
<BR> *
retrieved by calling NutTcpCreateSocket().<BR> *<BR> */<BR>static void
NutTcpProcessRst(TCPSOCKET * sock)<BR>{<BR> NETBUF *nb;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2> // Immediatly
set state to closed<BR> sock->so_state =
TCPS_CLOSED;</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2> // Delete
anything in the buffer<BR> if (sock->so_rx_buf)
{<BR>
NutHeapFree(sock->so_rx_buf);<BR>
sock->so_rx_cnt = 0;<BR>
sock->so_rx_buf = 0;<BR> }<BR> while ((nb
= sock->so_tx_nbq) != 0) {<BR>
sock->so_tx_nbq =
nb->nb_next;<BR>
NutNetBufFree(nb);<BR> }<BR> while ((nb =
sock->so_rx_nbq) != 0) {<BR>
sock->so_rx_nbq =
nb->nb_next;<BR>
NutNetBufFree(nb);<BR> }</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2> // Notify
changes<BR>
NutEventBroadcast(&sock->so_rx_tq);<BR>
NutEventBroadcast(&sock->so_tx_tq);<BR>
NutEventBroadcast(&sock->so_pc_tq);<BR>
NutEventBroadcast(&sock->so_ac_tq);<BR>}</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial size=2>And call it as
appropriate when a RST is received, which seems to work for
me.</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=293101707-26082003></SPAN><SPAN class=293101707-26082003><FONT
face=Arial size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=293101707-26082003></SPAN> </DIV>
<DIV align=left><FONT face=Arial
size=2>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR>Mike
Cornelius
Internet: <A
href="mailto:mikec@call-direct.com.au">mikec@call-direct.com.au</A><BR>Call
Direct Cellular Solutions Phone:
+61 2 9209-4259<BR>Suite
145
FAX: +61 2 9209-4196<BR>National Innovation
Centre URL: <A
href="http://www.call-direct.com.au/">http://www.call-direct.com.au</A><BR>Australian
Technology Park<BR>Eveleigh NSW
1430<BR>Australia
<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</FONT></DIV>
<DIV> </DIV></BODY></HTML>