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:
Tue Oct 01 08:31:20 2013 +0000
Revision:
76:938a140caf12
Parent:
74:c146c4e346c4
Child:
131:4758606c9316
Issue #34 updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 68:0847e35d08a6 1 /*********************************************************************
tass 68:0847e35d08a6 2 PicoTCP. Copyright (c) 2012 TASS Belgium NV. Some rights reserved.
tass 68:0847e35d08a6 3 See LICENSE and COPYING for usage.
tass 68:0847e35d08a6 4
tass 68:0847e35d08a6 5 .
tass 68:0847e35d08a6 6
tass 68:0847e35d08a6 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 68:0847e35d08a6 17 struct pico_trans trans;
tass 68:0847e35d08a6 18 uint32_t seq;
tass 68:0847e35d08a6 19 uint32_t ack;
tass 68:0847e35d08a6 20 uint8_t len;
tass 68:0847e35d08a6 21 uint8_t flags;
tass 68:0847e35d08a6 22 uint16_t rwnd;
tass 68:0847e35d08a6 23 uint16_t crc;
tass 68:0847e35d08a6 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 68:0847e35d08a6 29 struct pico_ip4 src;
tass 68:0847e35d08a6 30 struct pico_ip4 dst;
tass 68:0847e35d08a6 31 uint16_t tcp_len;
tass 68:0847e35d08a6 32 uint8_t res;
tass 68:0847e35d08a6 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 68:0847e35d08a6 70
tass 68:0847e35d08a6 71
tass 68:0847e35d08a6 72 struct __attribute__((packed)) pico_tcp_option
tass 68:0847e35d08a6 73 {
tass 68:0847e35d08a6 74 uint8_t kind;
tass 68:0847e35d08a6 75 uint8_t len;
tass 68:0847e35d08a6 76 #if 0
tass 68:0847e35d08a6 77 union {
tass 68:0847e35d08a6 78 uint16_t mss;
tass 68:0847e35d08a6 79 uint8_t wshift;
tass 68:0847e35d08a6 80 struct {
tass 68:0847e35d08a6 81 uint32_t tsval;
tass 68:0847e35d08a6 82 uint32_t tsecr;
tass 68:0847e35d08a6 83 } timestamp;
tass 68:0847e35d08a6 84 } data;
tass 68:0847e35d08a6 85 #endif
tass 68:0847e35d08a6 86 };
tass 68:0847e35d08a6 87
tass 68:0847e35d08a6 88 struct pico_socket *pico_tcp_open(void);
tass 70:cd218dd180e5 89 uint32_t pico_tcp_read(struct pico_socket *s, void *buf, uint32_t len);
tass 68:0847e35d08a6 90 int pico_tcp_initconn(struct pico_socket *s);
tass 68:0847e35d08a6 91 int pico_tcp_input(struct pico_socket *s, struct pico_frame *f);
tass 68:0847e35d08a6 92 uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f);
tass 70:cd218dd180e5 93 uint16_t pico_tcp_overhead(struct pico_socket *s);
tass 68:0847e35d08a6 94 int pico_tcp_output(struct pico_socket *s, int loop_score);
tass 68:0847e35d08a6 95 int pico_tcp_queue_in_is_empty(struct pico_socket *s);
tass 68:0847e35d08a6 96 int pico_tcp_reply_rst(struct pico_frame *f);
tass 68:0847e35d08a6 97 void pico_tcp_cleanup_queues(struct pico_socket *sck);
tass 76:938a140caf12 98 void pico_tcp_notify_closing(struct pico_socket *sck);
tass 68:0847e35d08a6 99
tass 68:0847e35d08a6 100 #endif