This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: RedBoot sequencenumber generation
Hello Mark,
thanks for helping.
In most cases it works, but if the initial sequencenumber, which
is now a pseudo random number, is anyhow in the window of the
TIME_WAIT connections of the host I get the old problem.
The SYN packet don't get a responce and will be retransmitted
on and on with the same sequencenumber.
This the end of the previous connection and the beginning of
the next which does not work:
17:03:48.646494 IP 192.168.1.37.2400 > 192.168.1.254.7801: P
1378753320:1378754780(1460) ack 14845252 win 64240
17:03:48.646496 IP 192.168.1.37.2400 > 192.168.1.254.7801: .
1378754780:1378754790(10) ack 14845252 win 64240
17:03:48.655519 IP 192.168.1.254.7801 > 192.168.1.37.2400: . ack 1378754780
win 1470
17:03:48.655650 IP 192.168.1.37.2400 > 192.168.1.254.7801: FP
1378754790:1378755667(877) ack 14845252 win 64240
17:03:48.655675 IP 192.168.1.254.7801 > 192.168.1.37.2400: . ack 1378754790
win 1470
17:03:48.656600 IP 192.168.1.254.7801 > 192.168.1.37.2400: . ack 1378755667
win 1470
17:03:49.064497 IP 192.168.1.37.2400 > 192.168.1.254.7801: F
1378755667:1378755667(0) ack 14845252 win 64240
17:03:49.065174 IP 192.168.1.254.7801 > 192.168.1.37.2400: . ack 1378755668
win 1470
17:03:49.065548 IP 192.168.1.254.7801 > 192.168.1.37.2400: F
14845252:14845252(0) ack 1378755668 win 1470
17:03:49.065609 IP 192.168.1.37.2400 > 192.168.1.254.7801: . ack 14845253 win
64240
17:04:15.129332 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470 <mss 1470>
17:04:16.163694 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:17.198333 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:18.233059 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:19.273759 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:20.338882 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:21.402446 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:22.466567 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:23.530214 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:24.594361 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:25.657939 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:26.722036 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:27.786039 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
17:04:28.850146 IP 192.168.1.254.7800 > 192.168.1.37.2400: S
5377751:5377751(0) win 1470
On Dienstag, 16. März 2004 15:15, Mark Salter wrote:
> Index: redboot/current/src/net/tcp.c
> ===================================================================
> RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/tcp.c,v
> retrieving revision 1.11
> diff -u -p -5 -r1.11 tcp.c
> --- redboot/current/src/net/tcp.c 21 Dec 2003 13:17:52
> -0000 1.11 +++ redboot/current/src/net/tcp.c 16 Mar 2004
> 14:05:26 -0000 @@ -58,10 +58,12 @@
> #include <cyg/hal/hal_if.h>
>
> #define MAX_TCP_SEGMENT (ETH_MAX_PKTLEN - (sizeof(eth_header_t) +
> sizeof(ip_header_t))) #define MAX_TCP_DATA (MAX_TCP_SEGMENT -
> sizeof(tcp_header_t))
>
> +/* setting this to 1 is technically wrong, but BSD does it too... */
> +static int initial_seqnum = 1;
>
> /* sequence number comparison macros */
> #define SEQ_LT(a,b) ((int)((a)-(b)) < 0)
> #define SEQ_LE(a,b) ((int)((a)-(b)) <= 0)
> #define SEQ_GT(a,b) ((int)((a)-(b)) > 0)
> @@ -479,10 +481,11 @@ __tcp_handler(pktbuf_t *pkt, ip_route_t
> return;
> }
> s->state = _ESTABLISHED;
> s->ack = ntohl(tcp->seqnum) + 1;
> s->seq = ntohl(tcp->acknum);
> + initial_seqnum += 64000;
> __timer_cancel(&s->timer);
> send_ack(s);
> break;
>
> case _LISTEN:
> @@ -523,10 +526,11 @@ __tcp_handler(pktbuf_t *pkt, ip_route_t
> } else if ((tcp->flags & TCP_FLAG_ACK) &&
> ntohl(tcp->acknum) == (s->seq + 1)) {
> /* we've established the connection */
> s->state = _ESTABLISHED;
> s->seq++;
> + initial_seqnum += 64000;
>
> BSPLOG(bsp_log("ACK received - connection
> established\n")); }
> break;
>
> @@ -643,10 +647,13 @@ void
> __tcp_poll(void)
> {
> __enet_poll();
> MS_TICKS_DELAY();
> __timer_poll();
> +
> + /* rfc793 says this should be incremented approx. once per 4ms */
> + initial_seqnum += 1000 / 4;
> }
>
>
> int
> __tcp_listen(tcp_socket_t *s, word port)
> @@ -890,11 +897,11 @@ __tcp_open(tcp_socket_t *s, struct socka
> s->his_port = host->sin_port;
> s->pkt.buf = (word *)s->pktbuf;
> s->pkt.bufsize = ETH_MAX_PKTLEN;
> s->pkt.ip_hdr = (ip_header_t *)s->pkt.buf;
> s->pkt.tcp_hdr = (tcp_header_t *)(s->pkt.ip_hdr + 1);
> - s->seq = (port << 16) | 0xDE77;
> + s->seq = initial_seqnum;
> s->ack = 0;
> if (__arp_lookup((ip_addr_t *)&host->sin_addr, &s->his_addr) < 0) {
> diag_printf("%s: Can't find address of server\n", __FUNCTION__);
> return -1;
> }
--
___________________________________________________
VS Vision Systems GmbH, Industrial Image Processing
Dipl.-Ing. Roland Caßebohm
Aspelohe 27A, D-22848 Norderstedt, Germany
Mail: roland.cassebohm@visionsystems.de
http://www.visionsystems.de
___________________________________________________
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss