anchao commented on pull request #1589:
URL: https://github.com/apache/incubator-nuttx/pull/1589#issuecomment-674139608


   No, they are completely different problems, PHY notification does not change 
the behavior of the TCP/IP stack. The stack does not have any interface to 
determine whether the network is disconnected unexpectedly,
   
   If the wireless network is disconnected after the application completes a 
socket send(2), then the TCP stack will keep retrying fetch for the ACK, the 
connection state is remain in TCP_ESTABLISHED
   
   
   ```
   void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
                  int hsec)
   {
   ...
    if (conn->tcpstateflags == TCP_TIME_WAIT ||
        conn->tcpstateflags == TCP_FIN_WAIT_2)  // skip, state remain 
TCP_ESTABLISHED
      {
   ...
     else if (conn->tcpstateflags != TCP_CLOSED)
       {
   ...
         if (conn->tx_unacked > 0)   // still waiting for the ack but the 
network is unreachable
           {
   ...
                 if (conn->tcpstateflags == TCP_SYN_RCVD &&   // skip, state 
remain TCP_ESTABLISHED
                     conn->nrtx >= TCP_MAXSYNRTX)
                   {
   ...
                 else if (
   #ifdef CONFIG_NET_TCP_WRITE_BUFFERS
                     conn->expired > 0 ||
   #else
                     conn->nrtx >= TCP_MAXRTX ||
   #endif
                     (conn->tcpstateflags == TCP_SYN_SENT &&  // skip, state 
remain TCP_ESTABLISHED
                      conn->nrtx >= TCP_MAXSYNRTX)
                    )
                   {
   ....
   
   ```
   
   In the process of waiting for ACK, network disconnection will lead to 
tcp_timer keeps trying to get the ACK, If the application close(2) the TCP 
connection, the close(2) call will blocked because the TCP stack does not know 
that the network is unreachable 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to