Free (GPLv2) TCP/IP stack developed by TASS Belgium

Dependents:   lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more

PicoTCP. Copyright (c) 2013 TASS Belgium NV.

Released under the GNU General Public License, version 2.

Different licensing models may exist, at the sole discretion of the Copyright holders.

Official homepage: http://www.picotcp.com

Bug tracker: https://github.com/tass-belgium/picotcp/issues

Development steps:

  • initial integration with mbed RTOS
  • generic mbed Ethernet driver
  • high performance NXP LPC1768 specific Ethernet driver
  • Multi-threading support for mbed RTOS
  • Berkeley sockets and integration with the New Socket API
  • Fork of the apps running on top of the New Socket API
  • Scheduling optimizations
  • Debugging/benchmarking/testing

Demo application (measuring TCP sender performance):

Import programlpc1768-picotcp-demo

A PicoTCP demo app testing the ethernet throughput on the lpc1768 mbed board.

Revision:
97:e73b01cb3147
Parent:
95:f4ca916a26fe
Child:
103:eff282352d4c
Child:
106:d34698d89baf
--- a/modules/pico_tcp.c	Wed Oct 16 11:51:10 2013 +0000
+++ b/modules/pico_tcp.c	Wed Oct 16 12:40:29 2013 +0000
@@ -27,6 +27,7 @@
 #define PICO_TCP_SYN_TO	 1000u
 #define PICO_TCP_ZOMBIE_TO 30000
 
+#define PICO_TCP_MAX_RETRANS		 10
 #define PICO_TCP_MAX_CONNECT_RETRIES 7
 
 #define PICO_TCP_LOOKAHEAD      0x00
@@ -97,7 +98,7 @@
   uint32_t size;
   uint32_t frames;
 };
-
+static void tcp_discard_all_segments(struct pico_tcp_queue *tq);
 static struct pico_frame *peek_segment(struct pico_tcp_queue *tq, uint32_t seq)
 {
   struct pico_tcp_hdr H;
@@ -1276,7 +1277,7 @@
   struct pico_frame *f = NULL;
   uint32_t limit = val - t->rto;
   if( t->sock.net && ((t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_ESTABLISHED
-  		|| (t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) )
+  		|| (t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) && t->backoff < PICO_TCP_MAX_RETRANS)
   {
 		tcp_dbg("TIMEOUT! backoff = %d\n", t->backoff);
 		/* was timer cancelled? */
@@ -1316,9 +1317,16 @@
 		t->backoff = 0;
 		add_retransmission_timer(t, 0);
 		if (t->tcpq_out.size < t->tcpq_out.max_size)
-			 t->sock.ev_pending |= PICO_SOCK_EV_WR;
+		  t->sock.ev_pending |= PICO_SOCK_EV_WR;
 		return;
 	}
+    else if(t->backoff >= PICO_TCP_MAX_RETRANS && (t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_ESTABLISHED )
+	{
+		// the retransmission timer, failed to get an ack for a frame, giving up on the connection
+		tcp_discard_all_segments(&t->tcpq_out);
+		if(t->sock.wakeup)
+		  t->sock.wakeup(PICO_SOCK_EV_FIN,&t->sock);
+	}
 }
 
 static void add_retransmission_timer(struct pico_socket_tcp *t, uint32_t next_ts)
@@ -2225,9 +2233,9 @@
           tcp_dbg_nagle("TCP_PUSH - NAGLE - enqueue hold failed 2\n");
           return 0;
         }
-      }
     }
   }
+      }
   /***************************************************************************/
 }