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 picotcp@tass.be
Date:
Thu Jan 16 10:13:37 2014 +0100
Revision:
133:5b075f5e141a
Parent:
131:4758606c9316
Child:
149:5f4cb161cec3
Update from master branch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 68:0847e35d08a6 1 /*********************************************************************
TASS Belgium NV 131:4758606c9316 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. 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 68:0847e35d08a6 8 #ifndef _INCLUDE_PICO_TCP
tass 68:0847e35d08a6 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 68:0847e35d08a6 16 struct __attribute__((packed)) 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 68:0847e35d08a6 27 struct __attribute__((packed)) 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 #define PICO_TCP_DEFAULT_MSS 1444
tass 68:0847e35d08a6 41
tass 68:0847e35d08a6 42
tass 68:0847e35d08a6 43
tass 68:0847e35d08a6 44 /* TCP options */
tass 68:0847e35d08a6 45 #define PICO_TCP_OPTION_END 0x00
tass 70:cd218dd180e5 46 #define PICO_TCPOPTLEN_END 1u
tass 68:0847e35d08a6 47 #define PICO_TCP_OPTION_NOOP 0x01
tass 68:0847e35d08a6 48 #define PICO_TCPOPTLEN_NOOP 1
tass 68:0847e35d08a6 49 #define PICO_TCP_OPTION_MSS 0x02
tass 68:0847e35d08a6 50 #define PICO_TCPOPTLEN_MSS 4
tass 68:0847e35d08a6 51 #define PICO_TCP_OPTION_WS 0x03
tass 70:cd218dd180e5 52 #define PICO_TCPOPTLEN_WS 3u
tass 68:0847e35d08a6 53 #define PICO_TCP_OPTION_SACK_OK 0x04
tass 68:0847e35d08a6 54 #define PICO_TCPOPTLEN_SACK_OK 2
tass 68:0847e35d08a6 55 #define PICO_TCP_OPTION_SACK 0x05
tass 68:0847e35d08a6 56 #define PICO_TCPOPTLEN_SACK 2 /* Plus the block */
tass 68:0847e35d08a6 57 #define PICO_TCP_OPTION_TIMESTAMP 0x08
tass 70:cd218dd180e5 58 #define PICO_TCPOPTLEN_TIMESTAMP 10u
tass 68:0847e35d08a6 59
tass 68:0847e35d08a6 60 /* TCP flags */
tass 68:0847e35d08a6 61 #define PICO_TCP_FIN 0x01
tass 68:0847e35d08a6 62 #define PICO_TCP_SYN 0x02
tass 68:0847e35d08a6 63 #define PICO_TCP_RST 0x04
tass 68:0847e35d08a6 64 #define PICO_TCP_PSH 0x08
tass 68:0847e35d08a6 65 #define PICO_TCP_ACK 0x10
tass 70:cd218dd180e5 66 #define PICO_TCP_URG 0x20u
tass 70:cd218dd180e5 67 #define PICO_TCP_ECN 0x40u
tass 70:cd218dd180e5 68 #define PICO_TCP_CWR 0x80u
tass 68:0847e35d08a6 69
TASS Belgium NV 131:4758606c9316 70 #define PICO_TCP_SYNACK (PICO_TCP_SYN | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 71 #define PICO_TCP_PSHACK (PICO_TCP_PSH | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 72 #define PICO_TCP_FINACK (PICO_TCP_FIN | PICO_TCP_ACK)
TASS Belgium NV 131:4758606c9316 73 #define PICO_TCP_FINPSHACK (PICO_TCP_FIN | PICO_TCP_PSH | PICO_TCP_ACK)
tass picotcp@tass.be 133:5b075f5e141a 74 #define PICO_TCP_RSTACK (PICO_TCP_RST | PICO_TCP_ACK)
tass 68:0847e35d08a6 75
tass 68:0847e35d08a6 76
tass 68:0847e35d08a6 77 struct __attribute__((packed)) pico_tcp_option
tass 68:0847e35d08a6 78 {
TASS Belgium NV 131:4758606c9316 79 uint8_t kind;
TASS Belgium NV 131:4758606c9316 80 uint8_t len;
tass 68:0847e35d08a6 81 #if 0
TASS Belgium NV 131:4758606c9316 82 union {
TASS Belgium NV 131:4758606c9316 83 uint16_t mss;
TASS Belgium NV 131:4758606c9316 84 uint8_t wshift;
TASS Belgium NV 131:4758606c9316 85 struct {
TASS Belgium NV 131:4758606c9316 86 uint32_t tsval;
TASS Belgium NV 131:4758606c9316 87 uint32_t tsecr;
TASS Belgium NV 131:4758606c9316 88 } timestamp;
TASS Belgium NV 131:4758606c9316 89 } data;
tass 68:0847e35d08a6 90 #endif
tass 68:0847e35d08a6 91 };
tass 68:0847e35d08a6 92
tass 68:0847e35d08a6 93 struct pico_socket *pico_tcp_open(void);
tass 70:cd218dd180e5 94 uint32_t pico_tcp_read(struct pico_socket *s, void *buf, uint32_t len);
tass 68:0847e35d08a6 95 int pico_tcp_initconn(struct pico_socket *s);
tass 68:0847e35d08a6 96 int pico_tcp_input(struct pico_socket *s, struct pico_frame *f);
tass 68:0847e35d08a6 97 uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f);
tass 70:cd218dd180e5 98 uint16_t pico_tcp_overhead(struct pico_socket *s);
tass 68:0847e35d08a6 99 int pico_tcp_output(struct pico_socket *s, int loop_score);
tass 68:0847e35d08a6 100 int pico_tcp_queue_in_is_empty(struct pico_socket *s);
tass 68:0847e35d08a6 101 int pico_tcp_reply_rst(struct pico_frame *f);
tass 68:0847e35d08a6 102 void pico_tcp_cleanup_queues(struct pico_socket *sck);
tass 76:938a140caf12 103 void pico_tcp_notify_closing(struct pico_socket *sck);
TASS Belgium NV 131:4758606c9316 104 void transport_flags_update(struct pico_frame *, struct pico_socket *);
tass 68:0847e35d08a6 105
tass 68:0847e35d08a6 106 #endif