xcore / sc_xtcp

micro TCP/IP stack for use with sc_ethernet
http://github.xcore.com/sc_xtcp/
Other
24 stars 19 forks source link

Double packets and sending packtes showing up as incomming - under havy load #15

Closed aritec closed 12 years ago

aritec commented 12 years ago

Hi, I figured out a strange behaviour when I send many TCP/IP packets from a host to my XMOS sc_xtcp sink. I got an stcp_event() for incoming data, but the data (usually an ACK) are the ones I just sent back to the host. With wireshark, I saw that the sc_xtcp is [ACK] a packet and then [PSH. ACK] the new request, but the ACK was for the same seq.

When I change the order in the function xtcpd_appcall() (uip_xtcp.c) to check first for new data and then ack a packet it works way better. I still got some problems if the TCP/IP packets are very large, but for small one it works great.

Regards Armin

Index: C:/Users/ain/projects/identec/LotTrack/source/module_xtcp/src/uip/xcore/uip_xtcp.c
===================================================================
--- C:/Users/ain/projects/identec/LotTrack/source/module_xtcp/src/uip/xcore/uip_xtcp.c  (revision 683)
+++ C:/Users/ain/projects/identec/LotTrack/source/module_xtcp/src/uip/xcore/uip_xtcp.c  (revision 684)
@@ -429,6 +429,22 @@
     }
   }

+  if (uip_newdata() && uip_len > 0) {
+  if (s->linknum != -1) {
+    if (!uip_udpconnection() && s->s.ack_recv_mode) {
+      uip_stop();
+    }
+    xtcpd_service_clients_until_ready(s->linknum, xtcp_links, xtcp_num);
+
+    xtcpd_recv(xtcp_links, s->linknum, xtcp_num,
+               s,
+               uip_appdata,
+               uip_datalen());
+  }
+
+}
+
+
   if (uip_acked()) {
     int len;
     if (s->linknum != -1) {
@@ -442,22 +458,6 @@
         uip_send(uip_appdata, len);
     }
   }  
-
-
-    if (uip_newdata() && uip_len > 0) {
-    if (s->linknum != -1) {
-      if (!uip_udpconnection() && s->s.ack_recv_mode) {
-        uip_stop();
-      }      
-      xtcpd_service_clients_until_ready(s->linknum, xtcp_links, xtcp_num);
-      
-      xtcpd_recv(xtcp_links, s->linknum, xtcp_num,
-                 s, 
-                 uip_appdata, 
-                 uip_datalen());   
-    }
-
-  }

   else if (uip_aborted()) {
     xtcpd_event(XTCP_ABORTED, s);
ajwlucas commented 12 years ago

Hi @aritec, can you fork sc_xtcp and do a pull request with your proposed changes? That way I can see the changes to the code and test it if necessary.

aritec commented 12 years ago

thanks