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:
109:f630e6230063
Parent:
107:841ae542f96c
Child:
110:0ece1bbbd36e
--- a/modules/pico_tcp.c	Fri Oct 25 12:47:19 2013 +0000
+++ b/modules/pico_tcp.c	Wed Oct 30 07:49:24 2013 +0000
@@ -1899,7 +1899,7 @@
         tcp_wakeup_pending(s, PICO_SOCK_EV_ERR);
         pico_socket_del(&t->sock);  /* delete socket */
         tcp_dbg("TCP RST> SOCKET BACK TO LISTEN\n");
-  //    pico_socket_del(s);
+   //   pico_socket_del(s);
       } else {
         tcp_force_closed(s);
         tcp_wakeup_pending(s, PICO_SOCK_EV_FIN);
@@ -1922,6 +1922,24 @@
   tcp_send_ack(t);
   return 0;
 }
+static int tcp_closeconn(struct pico_socket *s, struct pico_frame *fr)
+{
+  struct pico_socket_tcp *t = (struct pico_socket_tcp *) s;
+  struct pico_tcp_hdr *hdr  = (struct pico_tcp_hdr *) (fr->transport_hdr);
+
+  if (seq_compare(SEQN(fr), t->rcv_nxt) == 0) {
+      /* received FIN, increase ACK nr */
+  	  t->rcv_nxt = long_be(hdr->seq) + 1;
+	  s->state &= 0x00FFU;
+	  s->state |= PICO_SOCKET_STATE_TCP_CLOSE_WAIT;
+	  /* set SHUT_LOCAL */
+      s->state |= PICO_SOCKET_STATE_SHUT_LOCAL;
+      pico_socket_close(s);
+      s->parent->number_of_pending_conn--;
+      return 1;
+  }
+  return 0;
+}
 struct tcp_action_entry {
   uint16_t tcpstate;
   int (*syn)(struct pico_socket *s, struct pico_frame *f);
@@ -1939,7 +1957,7 @@
   { PICO_SOCKET_STATE_TCP_CLOSED,       NULL,            NULL,              NULL,              NULL,            NULL,            NULL,            NULL     },
   { PICO_SOCKET_STATE_TCP_LISTEN,       &tcp_syn,        &tcp_nosync_rst,   &tcp_nosync_rst,   &tcp_nosync_rst, &tcp_nosync_rst, &tcp_nosync_rst, NULL     },
   { PICO_SOCKET_STATE_TCP_SYN_SENT,     &tcp_nosync_rst, &tcp_synack,       &tcp_nosync_rst,   &tcp_nosync_rst, &tcp_nosync_rst, &tcp_nosync_rst, &tcp_rst },
-  { PICO_SOCKET_STATE_TCP_SYN_RECV,     NULL,            &tcp_nosync_rst,   &tcp_first_ack,    &tcp_data_in,    &tcp_nosync_rst, &tcp_nosync_rst, &tcp_rst },
+  { PICO_SOCKET_STATE_TCP_SYN_RECV,     NULL,            &tcp_nosync_rst,   &tcp_first_ack,    &tcp_data_in,    &tcp_nosync_rst, &tcp_closeconn,  &tcp_rst },
   { PICO_SOCKET_STATE_TCP_ESTABLISHED,  &tcp_halfopencon,&tcp_ack,          &tcp_ack,          &tcp_data_in,    &tcp_closewait,  &tcp_closewait,  &tcp_rst },
   { PICO_SOCKET_STATE_TCP_CLOSE_WAIT,   NULL,            &tcp_ack,          &tcp_ack,          &tcp_send_rst,   &tcp_closewait,  &tcp_closewait,  &tcp_rst },
   { PICO_SOCKET_STATE_TCP_LAST_ACK,     NULL,            &tcp_ack,          &tcp_lastackwait,  &tcp_send_rst,   &tcp_send_rst,   &tcp_send_rst,   &tcp_rst },
@@ -2302,7 +2320,8 @@
 	struct pico_socket_tcp *t=(struct pico_socket_tcp *)sck;
 	if(t->tcpq_out.frames == 0)
 	{
-		checkLocalClosing(sck);
+		if(!checkLocalClosing(sck))
+			checkRemoteClosing(sck);
 	}
 }