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.

Committer:
tass
Date:
Thu Jan 28 15:12:00 2016 +0100
Revision:
155:a70f34550c34
Parent:
152:a3d286bf94e5
Adding TCP flag for FIN.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 68:0847e35d08a6 1 /*********************************************************************
tass 152:a3d286bf94e5 2 PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
TASS Belgium NV 131:4758606c9316 3 See LICENSE and COPYING for usage.
tass 68:0847e35d08a6 4
TASS Belgium NV 131:4758606c9316 5 .
tass 68:0847e35d08a6 6
TASS Belgium NV 131:4758606c9316 7 *********************************************************************/
tass picotcp@tass.be 149:5f4cb161cec3 8 #ifndef INCLUDE_PICO_TCP
tass picotcp@tass.be 149:5f4cb161cec3 9 #define INCLUDE_PICO_TCP
tass 68:0847e35d08a6 10 #include "pico_addressing.h"
tass 68:0847e35d08a6 11 #include "pico_protocol.h"
tass 68:0847e35d08a6 12 #include "pico_socket.h"
tass 68:0847e35d08a6 13
tass 68:0847e35d08a6 14 extern struct pico_protocol pico_proto_tcp;
tass 68:0847e35d08a6 15
tass picotcp@tass.be 149:5f4cb161cec3 16 PACKED_STRUCT_DEF pico_tcp_hdr {
TASS Belgium NV 131:4758606c9316 17 struct pico_trans trans;
TASS Belgium NV 131:4758606c9316 18 uint32_t seq;
TASS Belgium NV 131:4758606c9316 19 uint32_t ack;
TASS Belgium NV 131:4758606c9316 20 uint8_t len;
TASS Belgium NV 131:4758606c9316 21 uint8_t flags;
TASS Belgium NV 131:4758606c9316 22 uint16_t rwnd;
TASS Belgium NV 131:4758606c9316 23 uint16_t crc;
TASS Belgium NV 131:4758606c9316 24 uint16_t urgent;
tass 68:0847e35d08a6 25 };
tass 68:0847e35d08a6 26
tass picotcp@tass.be 149:5f4cb161cec3 27 PACKED_STRUCT_DEF tcp_pseudo_hdr_ipv4
tass 68:0847e35d08a6 28 {
TASS Belgium NV 131:4758606c9316 29 struct pico_ip4 src;
TASS Belgium NV 131:4758606c9316 30 struct pico_ip4 dst;
TASS Belgium NV 131:4758606c9316 31 uint16_t tcp_len;
TASS Belgium NV 131:4758606c9316 32 uint8_t res;
TASS Belgium NV 131:4758606c9316 33 uint8_t proto;
tass 68:0847e35d08a6 34 };
tass 68:0847e35d08a6 35
tass 68:0847e35d08a6 36 #define PICO_TCPHDR_SIZE 20
tass 68:0847e35d08a6 37 #define PICO_SIZE_TCPOPT_SYN 20
tass 74:c146c4e346c4 38 #define PICO_SIZE_TCPHDR (uint32_t)(sizeof(struct pico_tcp_hdr))
tass 68:0847e35d08a6 39
tass 68:0847e35d08a6 40 /* TCP options */
tass 68:0847e35d08a6 41 #define PICO_TCP_OPTION_END 0x00
tass 70:cd218dd180e5 42 #define PICO_TCPOPTLEN_END 1u
tass 68:0847e35d08a6 43 #define PICO_TCP_OPTION_NOOP 0x01
tass 68:0847e35d08a6 44 #define PICO_TCPOPTLEN_NOOP 1
tass 68:0847e35d08a6 45 #define PICO_TCP_OPTION_MSS 0x02
tass 68:0847e35d08a6 46 #define PICO_TCPOPTLEN_MSS 4
tass 68:0847e35d08a6 47 #define PICO_TCP_OPTION_WS 0x03
tass 70:cd218dd180e5 48 #define PICO_TCPOPTLEN_WS 3u
tass 68:0847e35d08a6 49 #define PICO_TCP_OPTION_SACK_OK 0x04
tass 68:0847e35d08a6 50 #define PICO_TCPOPTLEN_SACK_OK 2
tass 68:0847e35d08a6 51 #define PICO_TCP_OPTION_SACK 0x05
tass 68:0847e35d08a6 52 #define PICO_TCPOPTLEN_SACK 2 /* Plus the block */
tass 68:0847e35d08a6 53 #define PICO_TCP_OPTION_TIMESTAMP 0x08
tass 70:cd218dd180e5 54 #define PICO_TCPOPTLEN_TIMESTAMP 10u
tass 68:0847e35d08a6 55
tass 68:0847e35d08a6 56 /* TCP flags */
tass picotcp@tass.be 149:5f4cb161cec3 57 #define PICO_TCP_FIN 0x01u
tass picotcp@tass.be 149:5f4cb161cec3 58 #define PICO_TCP_SYN 0x02u
tass picotcp@tass.be 149:5f4cb161cec3 59 #define PICO_TCP_RST 0x04u
tass picotcp@tass.be 149:5f4cb161cec3 60 #define PICO_TCP_PSH 0x08u
tass picotcp@tass.be 149:5f4cb161cec3 61 #define PICO_TCP_ACK 0x10u
tass 70:cd218dd180e5 62 #define PICO_TCP_URG 0x20u
tass 70:cd218dd180e5 63 #define PICO_TCP_ECN 0x40u
tass 70:cd218dd180e5 64 #define PICO_TCP_CWR 0x80u
tass 68:0847e35d08a6 65
TASS Belgium NV 131:4758606c9316 66 #define PICO_TCP_SYNACK (PICO_TCP_SYN | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 67 #define PICO_TCP_PSHACK (PICO_TCP_PSH | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 68 #define PICO_TCP_FINACK (PICO_TCP_FIN | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 69 #define PICO_TCP_FINPSHACK (PICO_TCP_FIN | PICO_TCP_PSH | PICO_TCP_ACK)
tass picotcp@tass.be 133:5b075f5e141a 70 #define PICO_TCP_RSTACK (PICO_TCP_RST | PICO_TCP_ACK)
tass 68:0847e35d08a6 71
tass 68:0847e35d08a6 72
tass picotcp@tass.be 149:5f4cb161cec3 73 PACKED_STRUCT_DEF pico_tcp_option
tass 68:0847e35d08a6 74 {
TASS Belgium NV 131:4758606c9316 75 uint8_t kind;
TASS Belgium NV 131:4758606c9316 76 uint8_t len;
tass 68:0847e35d08a6 77 };
tass 68:0847e35d08a6 78
tass picotcp@tass.be 149:5f4cb161cec3 79 struct pico_socket *pico_tcp_open(uint16_t family);
tass 70:cd218dd180e5 80 uint32_t pico_tcp_read(struct pico_socket *s, void *buf, uint32_t len);
tass 68:0847e35d08a6 81 int pico_tcp_initconn(struct pico_socket *s);
tass 68:0847e35d08a6 82 int pico_tcp_input(struct pico_socket *s, struct pico_frame *f);
tass picotcp@tass.be 149:5f4cb161cec3 83 uint16_t pico_tcp_checksum(struct pico_frame *f);
tass 68:0847e35d08a6 84 uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f);
tass picotcp@tass.be 149:5f4cb161cec3 85 #ifdef PICO_SUPPORT_IPV6
tass picotcp@tass.be 149:5f4cb161cec3 86 uint16_t pico_tcp_checksum_ipv6(struct pico_frame *f);
tass picotcp@tass.be 149:5f4cb161cec3 87 #endif
tass 70:cd218dd180e5 88 uint16_t pico_tcp_overhead(struct pico_socket *s);
tass 68:0847e35d08a6 89 int pico_tcp_output(struct pico_socket *s, int loop_score);
tass 68:0847e35d08a6 90 int pico_tcp_queue_in_is_empty(struct pico_socket *s);
tass 68:0847e35d08a6 91 int pico_tcp_reply_rst(struct pico_frame *f);
tass 68:0847e35d08a6 92 void pico_tcp_cleanup_queues(struct pico_socket *sck);
tass 76:938a140caf12 93 void pico_tcp_notify_closing(struct pico_socket *sck);
tass picotcp@tass.be 149:5f4cb161cec3 94 void pico_tcp_flags_update(struct pico_frame *f, struct pico_socket *s);
tass picotcp@tass.be 149:5f4cb161cec3 95 int pico_tcp_set_bufsize_in(struct pico_socket *s, uint32_t value);
tass picotcp@tass.be 149:5f4cb161cec3 96 int pico_tcp_set_bufsize_out(struct pico_socket *s, uint32_t value);
tass picotcp@tass.be 149:5f4cb161cec3 97 int pico_tcp_get_bufsize_in(struct pico_socket *s, uint32_t *value);
tass picotcp@tass.be 149:5f4cb161cec3 98 int pico_tcp_get_bufsize_out(struct pico_socket *s, uint32_t *value);
tass 152:a3d286bf94e5 99 int pico_tcp_set_keepalive_probes(struct pico_socket *s, uint32_t value);
tass 152:a3d286bf94e5 100 int pico_tcp_set_keepalive_intvl(struct pico_socket *s, uint32_t value);
tass 152:a3d286bf94e5 101 int pico_tcp_set_keepalive_time(struct pico_socket *s, uint32_t value);
tass 152:a3d286bf94e5 102 int pico_tcp_set_linger(struct pico_socket *s, uint32_t value);
tass 152:a3d286bf94e5 103 uint16_t pico_tcp_get_socket_mss(struct pico_socket *s);
tass picotcp@tass.be 149:5f4cb161cec3 104 int pico_tcp_check_listen_close(struct pico_socket *s);
tass 68:0847e35d08a6 105
tass 68:0847e35d08a6 106 #endif