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 RTOSgeneric mbed Ethernet driverhigh performance NXP LPC1768 specific Ethernet driverMulti-threading support for mbed RTOSBerkeley sockets and integration with the New Socket APIFork of the apps running on top of the New Socket APIScheduling 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.
Diff: modules/pico_tcp.c
- Revision:
- 76:938a140caf12
- Parent:
- 75:a9abf10138d6
- Child:
- 79:6d1cb906043d
--- a/modules/pico_tcp.c Tue Oct 01 07:32:47 2013 +0000 +++ b/modules/pico_tcp.c Tue Oct 01 08:31:20 2013 +0000 @@ -2010,6 +2010,10 @@ } } +inline static int checkLocalClosing(struct pico_socket *s); +inline static int checkRemoteClosing(struct pico_socket *s); + + int pico_tcp_output(struct pico_socket *s, int loop_score) { struct pico_socket_tcp *t = (struct pico_socket_tcp *)s; @@ -2071,21 +2075,10 @@ } if ((t->tcpq_out.frames == 0) && (s->state & PICO_SOCKET_STATE_SHUT_LOCAL)) { /* if no more packets in queue, XXX replacled !f by tcpq check */ - if ((s->state & PICO_SOCKET_STATE_TCP) == PICO_SOCKET_STATE_TCP_ESTABLISHED) { - tcp_dbg("TCP> buffer empty, shutdown established ...\n"); - /* send fin if queue empty and in state shut local (write) */ - tcp_send_fin(t); - /* change tcp state to FIN_WAIT1 */ - s->state &= 0x00FFU; - s->state |= PICO_SOCKET_STATE_TCP_FIN_WAIT1; - } else if ((s->state & PICO_SOCKET_STATE_TCP) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) { - /* send fin if queue empty and in state shut local (write) */ - tcp_send_fin(t); - /* change tcp state to LAST_ACK */ - s->state &= 0x00FFU; - s->state |= PICO_SOCKET_STATE_TCP_LAST_ACK; - tcp_dbg("TCP> STATE: LAST_ACK.\n"); - } + if(!checkLocalClosing(&t->sock)) // check if local closing started and send fin + { + checkRemoteClosing(&t->sock); // check if remote closing started and send fin + } } return loop_score; } @@ -2255,4 +2248,43 @@ tcp_discard_all_segments(&tcp->tcpq_hold); } +static int checkLocalClosing(struct pico_socket *s) +{ + struct pico_socket_tcp * t = (struct pico_socket_tcp *)s; + if ((s->state & PICO_SOCKET_STATE_TCP) == PICO_SOCKET_STATE_TCP_ESTABLISHED) { + tcp_dbg("TCP> buffer empty, shutdown established ...\n"); + /* send fin if queue empty and in state shut local (write) */ + tcp_send_fin(t); + /* change tcp state to FIN_WAIT1 */ + s->state &= 0x00FFU; + s->state |= PICO_SOCKET_STATE_TCP_FIN_WAIT1; + return 1; + } + return 0; +} + +static int checkRemoteClosing(struct pico_socket *s) +{ + struct pico_socket_tcp * t = (struct pico_socket_tcp *)s; + if ((s->state & PICO_SOCKET_STATE_TCP) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) { + /* send fin if queue empty and in state shut local (write) */ + tcp_send_fin(t); + /* change tcp state to LAST_ACK */ + s->state &= 0x00FFU; + s->state |= PICO_SOCKET_STATE_TCP_LAST_ACK; + tcp_dbg("TCP> STATE: LAST_ACK.\n"); + return 1; + } + return 0; +} + +void pico_tcp_notify_closing(struct pico_socket *sck) +{ + struct pico_socket_tcp *t=(struct pico_socket_tcp *)sck; + if(t->tcpq_out.frames == 0) + { + checkLocalClosing(sck); + } +} + #endif //PICO_SUPPORT_TCP