This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RedBoot sequenecnumber generation


Hello,

i have a problem with RedBoot connecting to other hosts.

In RedBoot the initial sequencenumber for TCP is always the same. 
If RedBoot try to connect to the same host and port multiple
times, it couldn't connect while the port is in TIME_WAIT state
on the host. I think this is because the thinks it gets old lost
packets and just drops them.

The attached patch solved the problem for me, but I think it is
maybe not what is really right. At least the part in do_retrans().
I have made it because although we get a pseudo random sequence-
number, it could be in the window of the previous connection and
if the SYN package are retransmitted with the same sequencenumber
it will not help.

Is this right what I have made?

Roland
Index: redboot/current/src/net/tcp.c
===================================================================
RCS file: /home/cassebohm/net/USERS/CVSROOT/VSprojects/ecos/packages/redboot/current/src/net/tcp.c,v
retrieving revision 1.1.1.1.2.3
diff -u -5 -p -r1.1.1.1.2.3 tcp.c
--- redboot/current/src/net/tcp.c	12 Feb 2004 11:40:14 -0000	1.1.1.1.2.3
+++ redboot/current/src/net/tcp.c	12 Mar 2004 17:46:57 -0000
@@ -296,11 +296,17 @@ unlink_socket(tcp_socket_t *s)
  * Retransmit last packet.
  */
 static void
 do_retrans(void *p)
 {
+    tcp_socket_t *s = (tcp_socket_t *)p;
+
     BSPLOG(bsp_log("tcp do_retrans.\n"));
+
+    if (s->pkt.tcp_hdr->flags & TCP_FLAG_SYN)
+        s->seq += 0x6AAADE77;
+
     tcp_send((tcp_socket_t *)p, 0, 1);
 }
 
 
 static void
@@ -890,11 +896,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 = (port << 16) + (0x6AAADE77 * get_ms_ticks());
     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;
     }

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]