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.

Files at this revision

API Documentation at this revision

Comitter:
tass picotcp@tass.be
Date:
Fri Feb 07 11:24:45 2014 +0100
Parent:
137:a1c8bfa9d691
Child:
140:bb24e339e40b
Commit message:
Update from masterbranch

Changed in this revision

stack/pico_arp.c Show annotated file Show diff for this revision Revisions of this file
stack/pico_device.c Show annotated file Show diff for this revision Revisions of this file
stack/pico_socket.c Show annotated file Show diff for this revision Revisions of this file
stack/pico_stack.c Show annotated file Show diff for this revision Revisions of this file
--- 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 */
         }
     }
 
--- a/stack/pico_device.c	Fri Feb 07 11:21:12 2014 +0100
+++ b/stack/pico_device.c	Fri Feb 07 11:24:45 2014 +0100
@@ -139,7 +139,7 @@
     if (dev->eth) {
         ret = pico_ethernet_send(f);
         if (0 <= ret) {
-            return 1;
+            return -1;
         } else {
             if (!pico_source_is_local(f)) {
                 dbg("Destination unreachable -------> SEND ICMP\n");
@@ -152,7 +152,10 @@
             return 1;
         }
     } else {
-        dev->send(dev, f->start, (int)f->len);
+        /* non-ethernet */
+        if (dev->send(dev, f->start, (int)f->len) <= 0)
+            return -1;
+
         pico_frame_discard(f);
         return 1;
     }
@@ -170,7 +173,10 @@
         if (!f)
             break;
 
-        loop_score -= devloop_sendto_dev(dev, f);
+        if (devloop_sendto_dev(dev, f) < 0)
+            break;
+
+        loop_score--;
     }
     return loop_score;
 }
--- a/stack/pico_socket.c	Fri Feb 07 11:21:12 2014 +0100
+++ b/stack/pico_socket.c	Fri Feb 07 11:24:45 2014 +0100
@@ -897,8 +897,10 @@
         s = pico_tcp_open();
         s->proto = &pico_proto_tcp;
         /*check if Nagle enabled */
+        /* 
         if (!IS_NAGLE_ENABLED(s))
             dbg("ERROR Nagle should be enabled here\n\n");
+        */
     }
 
 #endif
--- a/stack/pico_stack.c	Fri Feb 07 11:21:12 2014 +0100
+++ b/stack/pico_stack.c	Fri Feb 07 11:24:45 2014 +0100
@@ -542,7 +542,6 @@
 
 struct pico_timer
 {
-    pico_time expire;
     void *arg;
     void (*timer)(pico_time timestamp, void *arg);
 };
@@ -597,12 +596,6 @@
     }
 }
 
-pico_time pico_timer_get_expire(struct pico_timer *t)
-{
-    return t->expire;
-}
-
-
 #define PROTO_DEF_NR      11
 #define PROTO_DEF_AVG_NR  4
 #define PROTO_DEF_SCORE   32
@@ -815,24 +808,21 @@
     t->arg = arg;
     t->timer = timer;
     tref.tmr = t;
-    heap_insert(Timers, &tref);
     #ifdef JENKINS_DEBUG
     //jenkins_dbg("pico_timer_add: now have %d \t caller: %p\n", Timers->n, __builtin_return_address(0));
     tref.caller = __builtin_return_address(0);
     #endif
+    heap_insert(Timers, &tref);
     if (Timers->n > PICO_MAX_TIMERS) {
         /* dbg("Warning: I have %d timers\n", Timers->n); */
         #ifdef JENKINS_DEBUG
         {
-            struct pico_timer *tmr;
             struct pico_timer_ref *trf = heap_first(Timers);
             int timer_it = 1; 
             for (timer_it = 1; timer_it <= Timers->n; timer_it++) 
             {
                 trf = &Timers->top[timer_it];
-                tmr = trf->tmr;
-                //if (tmr && tmr->caller)
-                jenkins_dbg("timer %d [%p] - caller: %p - exp:%lu\n",Timers->n - timer_it , tmr, trf->caller,(uint32_t)(trf->expire - PICO_TIME_MS()));    
+                jenkins_dbg("timer %d [%p] - cb:%p\n",Timers->n - timer_it, trf->tmr, trf->caller,(trf->tmr->timer));    
             }
         }
         #endif