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:
- 37:bdf736327c71
- Parent:
- 36:afa3ab5e06b3
- Child:
- 40:c8ab0d2bba0b
--- a/modules/pico_tcp.c Wed Jun 26 06:27:32 2013 +0000 +++ b/modules/pico_tcp.c Wed Jul 03 08:56:01 2013 +0000 @@ -22,7 +22,8 @@ #define PICO_TCP_RTO_MIN 10 #define PICO_TCP_RTO_MAX 120000 -#define PICO_TCP_IW 2 +#define PICO_TCP_IW 2 +#define PICO_TCP_SYN_TO 1000 #define PICO_TCP_MAX_CONNECT_RETRIES 7 @@ -242,7 +243,7 @@ while (head && (seq_compare(SEQN(head) + head->payload_len, seq) <= 0)) { struct pico_frame *cur = head; head = next_segment(q, cur); - //printf("Releasing %x\n", cur); + tcp_dbg("Releasing %p\n", q); pico_discard_segment(q, cur); ret++; } @@ -258,7 +259,7 @@ pico_tree_foreach_safe(idx,&q->pool,temp){ f = idx->keyValue; if (seq_compare(SEQN(f) + f->payload_len, seq) <= 0) { - //printf("Releasing %p\n", f); + tcp_dbg("Releasing %p\n", f); pico_discard_segment(q, f); ret++; } else @@ -781,7 +782,7 @@ /* TCP: ENQUEUE to PROTO ( SYN ) */ tcp_dbg("Sending SYN... (ports: %d - %d) size: %d\n", short_be(ts->sock.local_port), short_be(ts->sock.remote_port), syn->buffer_len); pico_enqueue(&tcp_out, syn); - pico_timer_add(PICO_TCP_RTO_MIN << ts->backoff, initconn_retry, ts); + pico_timer_add(PICO_TCP_SYN_TO << ts->backoff, initconn_retry, ts); return 0; } @@ -1240,7 +1241,7 @@ if( t->sock.net && ((t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_ESTABLISHED || (t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) ) { - //printf("\n\nTIMEOUT! backoff = %d\n", t->backoff); + tcp_dbg("\n\nTIMEOUT! backoff = %d\n", t->backoff); /* was timer cancelled? */ if (t->timer_running == 0) { add_retransmission_timer(t, 0); @@ -1309,7 +1310,6 @@ } if (next_ts > 0) { if ((next_ts + t->rto) > pico_tick) { - //printf("Adding timer1\n,%d,%d,%d",next_ts,t->rto,pico_tick); pico_timer_add(next_ts + t->rto - pico_tick, tcp_retrans_timeout, t); } else { pico_timer_add(1, tcp_retrans_timeout, t); @@ -1337,7 +1337,6 @@ if (pico_enqueue(&tcp_out, cpy) > 0) { t->in_flight++; t->snd_last_out = SEQN(cpy); - //printf("tcp_retrans\n"); add_retransmission_timer(t, pico_tick + t->rto); } else { pico_frame_discard(cpy); @@ -1414,7 +1413,6 @@ t->recv_wnd = short_be(hdr->rwnd); acked = tcp_ack_advance_una(t, f); - //printf("acked:%d,%d,%d\n",acked,SEQN(f),ACKN(f)); una = first_segment(&t->tcpq_out); if ((t->x_mode == PICO_TCP_BLACKOUT) || @@ -1930,20 +1928,14 @@ /* Those are not supported at this time. */ flags &= ~(PICO_TCP_CWR | PICO_TCP_URG | PICO_TCP_ECN); - if (flags == PICO_TCP_SYN) { if (action->syn) - { - //printf("SYN\n"); action->syn(s,f); - } } else if (flags == (PICO_TCP_SYN | PICO_TCP_ACK)) { - //printf("SYN-ACK\n"); if (action->synack) action->synack(s,f); } else { if ((flags == PICO_TCP_ACK) || (flags == (PICO_TCP_ACK | PICO_TCP_PSH))) { - //printf("%s\n", flags == PICO_TCP_ACK ? "ACK" : (flags == (PICO_TCP_ACK | PICO_TCP_PSH) ? "PSH,ACK" : "x") ); if (action->ack) { action->ack(s,f); } @@ -2005,7 +1997,6 @@ while((f) && (t->cwnd >= t->in_flight)) { hdr = (struct pico_tcp_hdr *)f->transport_hdr; f->timestamp = pico_tick; - //printf("Output frame : %x\n",f); tcp_add_options(t, f, hdr->flags, tcp_options_size(t, hdr->flags)); if (seq_compare(SEQN(f) + f->payload_len, SEQN(una) + (t->recv_wnd << t->recv_wnd_scale)) > 0) { t->cwnd = t->in_flight; @@ -2045,7 +2036,6 @@ if (sent > 0) { if (t->rto < PICO_TCP_RTO_MIN) t->rto = PICO_TCP_RTO_MIN; - //printf("pico_tcp_output\n"); add_retransmission_timer(t, pico_tick + t->rto); } else { // no packets in queue ??