From owner-freebsd-net Wed Nov 28 22:40:33 2001 Delivered-To: freebsd-net@freebsd.org Received: from prism.flugsvamp.com (cb58709-a.mdsn1.wi.home.com [24.17.241.9]) by hub.freebsd.org (Postfix) with ESMTP id 8632737B422 for ; Wed, 28 Nov 2001 22:40:30 -0800 (PST) Received: (from jlemon@localhost) by prism.flugsvamp.com (8.11.0/8.11.0) id fAT6bd213755; Thu, 29 Nov 2001 00:37:39 -0600 (CST) (envelope-from jlemon) Date: Thu, 29 Nov 2001 00:37:39 -0600 (CST) From: Jonathan Lemon Message-Id: <200111290637.fAT6bd213755@prism.flugsvamp.com> To: cfliu@csie.nctu.edu.tw, net@freebsd.org Subject: Re: Does 4.4 FreeBSD kernel supports TCP simultaneous open? X-Newsgroups: local.mail.freebsd-net In-Reply-To: Organization: Cc: Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In article you write: >-=-=-=-=-=- > >Hi, I am tracing the FreeBSD 4.4 kernel and I found that its TCP seems >NOT be able to do simultaneous open according to the source code. In >tcp_input.c, even though code near line #1750, > >case TCPS_SYN_RECEIVED: > ..... > if (tp->t_flags & TF_NEEDFIN) { > tp->t_state = TCPS_FIN_WAIT_1; > tp->t_flags &= ~TF_NEEDFIN; > } else { > tp->t_state = TCPS_ESTABLISHED; > callout_reset(tp->tt_keep, tcp_keepidle, > tcp_timer_keep, tp); > } > >do change state from SYN_RCVD state to ESTABLISHED, however, near line >1700 , the code fragment > >if (thflags & TH_SYN) { > tp = tcp_drop(tp, ECONNRESET); > rstreason = BANDLIM_UNLIMITED; > goto dropwithreset; > } > > > drops a packet with SYN bit set in SYN_RCVD state. I think this would >break TCP's simultaneous open. > >Since upon receiving a SYN segment in SYN_SENT state, TCP switches to >SYN_RCVD state and sends a (ACK,SYN) segment to the peer, if the peer >drops segments with SYN bit set during SYN_RCVD state, the simultaneous >open mechanism of TCP would break. > >Am I correct? No. In this case, there are 3 distinct state transitions: A. send SYN. CLOSED -> SYN_SENT B. recv SYN. SYN_SENT -> SYN_RECEIVED C. recv ACK. SYN_RECIEVED -> ESTABLISHED So dropping a connection when receiving a SYN packet in the SYN_RECEIVED state is the correct thing to do; this is would be a duplicate SYN. For a simultaneous open, the peer's SYN is received when the local state is SYN_SENT. The error in your logic above is that in step B, only an ACK is sent to the peer, the SYN is not retransmitted as well. -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message