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:
138:0a7a449980e6
Parent:
137:a1c8bfa9d691
--- a/stack/pico_arp.c	Fri Feb 07 11:21:12 2014 +0100
+++ b/stack/pico_arp.c	Fri Feb 07 11:24:45 2014 +0100
@@ -172,7 +172,7 @@
 
     if (!a4) {
         if (++f->failure_count < 4) {
-            dbg ("================= ARP REQUIRED: %d =============\n\n", f->failure_count);
+            arp_dbg ("================= ARP REQUIRED: %d =============\n\n", f->failure_count);
             /* check if dst is local (gateway = 0), or if to use gateway */
             if (gateway.addr != 0)
                 pico_arp_request(f->dev, &gateway, PICO_ARP_QUERY); /* arp to gateway */
@@ -210,11 +210,15 @@
 static void arp_expire(pico_time now, void *_stale)
 {
     struct pico_arp *stale = (struct pico_arp *) _stale;
-    IGNORE_PARAMETER(now);
-    stale->arp_status = PICO_ARP_STATUS_STALE;
-    arp_dbg("ARP: Setting arp_status to STALE\n");
-    pico_arp_request(stale->dev, &stale->ipv4, PICO_ARP_QUERY);
-
+    if (now >= (stale->timestamp + PICO_ARP_TIMEOUT)) {
+        stale->arp_status = PICO_ARP_STATUS_STALE;
+        arp_dbg("ARP: Setting arp_status to STALE\n");
+        pico_arp_request(stale->dev, &stale->ipv4, PICO_ARP_QUERY);
+    } else {
+        /* Timer must be rescheduled, ARP entry has been renewed lately.
+         * No action required to refresh the entry, will check on the next timeout */
+        pico_timer_add(PICO_ARP_TIMEOUT + stale->timestamp - now, arp_expire, stale);
+    }
 }
 
 static void pico_arp_add_entry(struct pico_arp *entry)
@@ -301,15 +305,13 @@
             new = found;
 
             pico_tree_delete(&arp_tree, new);
-        }
-        else {
+        } else {
             /* Update mac address */
             memcpy(found->eth.addr, hdr->s_mac, PICO_SIZE_ETH);
 
-            /* Refresh timeout & update timestamp*/
-            pico_timer_cancel(found->timer);
-            found->timer = pico_timer_add(PICO_ARP_TIMEOUT, arp_expire, found);
+            /* Refresh timestamp, this will force a reschedule on the next timeout*/ 
             found->timestamp = PICO_TIME();
+            new = NULL; /* Avoid re-inserting the entry in the table */
         }
     }