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.
Revision 97:e73b01cb3147, committed 2013-10-16
- Comitter:
- tass
- Date:
- Wed Oct 16 12:40:29 2013 +0000
- Parent:
- 96:6d41e372ee2c
- Child:
- 98:b0575c2cc01c
- Commit message:
- Issue #40 + removed ep_accepting since there is no need for it.
Changed in this revision
Socket/bsd/stack_endpoint.cpp | Show annotated file Show diff for this revision Revisions of this file |
modules/pico_tcp.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/Socket/bsd/stack_endpoint.cpp Wed Oct 16 11:51:10 2013 +0000 +++ b/Socket/bsd/stack_endpoint.cpp Wed Oct 16 12:40:29 2013 +0000 @@ -28,7 +28,6 @@ Mutex *PicoTcpLock; Queue<void,32> *PicoTcpEvents; -static struct stack_endpoint *ep_accepting; static Thread * serverThread = NULL; /* Testing ng blocking mechanism */ @@ -64,17 +63,12 @@ { struct stack_endpoint *ep = (struct stack_endpoint *)s->priv; if (!ep) { - if (ep_accepting != NULL) { - ptsock_dbg("Delivering %02x to accepting socket...\n", ev); - ep = ep_accepting; - } else { - ptsock_dbg("WAKEUP: socket not found! ev=%04x\n", ev); - return; - } + ptsock_dbg("WAKEUP: socket not found! ev=%04x\n", ev); + return; } //if (((ep->revents & PICO_SOCK_EV_RD) == 0) && (ev & PICO_SOCK_EV_RD)) // printf("Activating RD\n"); - if(!ep || !ep->s || !ep->queue) + if(!ep->s || !ep->queue) { ptsock_dbg("Endpoint null warning : ep=%p, ep->s=%p, ep->queue=%p\n",ep,ep->s,ep->queue); return; @@ -153,10 +147,7 @@ int ret; PicoTcpLock->lock(); ret = pico_socket_listen(ep->s, queue); - ep_accepting = (struct stack_endpoint *) pico_zalloc(sizeof(struct stack_endpoint)); - ep_accepting->queue = new Queue<void,1>(); - if (!ep_accepting) - ret = -1; + if(ret == 0) ep->state = SOCK_LISTEN; PicoTcpLock->unlock(); @@ -188,14 +179,12 @@ struct stack_endpoint *picotcp_accept(struct stack_endpoint *ep, struct sockaddr *_cli_addr, socklen_t *len) { int retval; - struct stack_endpoint *aep = ep_accepting; + struct sockaddr_in *cli_addr = (struct sockaddr_in *)_cli_addr; - ep_accepting = (struct stack_endpoint *) pico_zalloc(sizeof(struct stack_endpoint)); - if (ep_accepting) - ep_accepting->queue = new Queue<void,1>(); - - - if (!aep) + struct stack_endpoint *aep = (struct stack_endpoint *) pico_zalloc(sizeof(struct stack_endpoint)); + if (aep) + aep->queue = new Queue<void,1>(); + else return aep; PicoTcpLock->lock();
--- 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; } - } } } + } /***************************************************************************/ }