lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] sending a RST when the connection is in a non-synchronized


From: Olaf Peters
Subject: [lwip-users] sending a RST when the connection is in a non-synchronized state(SYN-SENT, SYN-RECEIVED)
Date: Mon, 30 May 2005 17:27:04 +0200

Hi,

During TCP tests between lwIP 1.1.0 and Windows-XP I discovered that lwIP
doesn't send a RST segment when the connection is in a non-synchronized
state (SYN-SENT, SYN-RECEIVED) and an incoming segment acknowledges
something not yet sent. See item 2 in the section "Reset Generation",
RFC793, page 36.

I discovered this when I had a half open connection, i.e. I restarted my
system when my app had an open connection with XP (so XP still thinks it is
connected). In this half open connection state, my application on top of
lwIP tried to connect to XP, and XP did send an ACK to me (see also
figure-10 in RFC793). Anybody else did run into the same problem?

Olaf.


Below are patches for the changes I applied to lwIP 1.1.0 to solve my
problems, please have a look and comment:


*** lwip-1.1.0-org/src/core/tcp_in.c    Wed Nov 24 17:05:42 2004
--- lwip-1.1.0/src/core/tcp_in.c        Tue May 24 17:40:20 2005
*************** tcp_process(struct tcp_pcb *pcb)
*** 561,566 ****
--- 562,579 ----
        TCP_EVENT_CONNECTED(pcb, ERR_OK, err);
        tcp_ack(pcb);
      }
+     else {
+       /* When we received an ACK, we might deal with an half-open
+          connection (the other side might be in a synchronized/connected
+          state). Send a RST to bring the other side in a non-synchronized 
+          state. */
+       if (flags & TCP_ACK) {
+          tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
+                  tcphdr->dest, tcphdr->src);
+       }
+     }
      break;
    case SYN_RCVD:
      if (flags & TCP_ACK &&
*************** tcp_process(struct tcp_pcb *pcb)
*** 586,591 ****
--- 599,613 ----
          tcp_receive(pcb);
          pcb->cwnd = pcb->mss;
        }
+       else {
+         /* We received an ACK but with an incorrect ack number. Send a RST
+            to inform the other side about this situation. */
+         tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
+                 tcphdr->dest, tcphdr->src);
+       }
      }
      break;
    case CLOSE_WAIT:






reply via email to

[Prev in Thread] Current Thread [Next in Thread]