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.
modules/pico_tcp.h@131:4758606c9316, 2013-12-16 (annotated)
- Committer:
- TASS Belgium NV
- Date:
- Mon Dec 16 11:25:54 2013 +0100
- Revision:
- 131:4758606c9316
- Parent:
- 76:938a140caf12
- Child:
- 133:5b075f5e141a
Syncronized with master branch
Who changed what in which revision?
User | Revision | Line number | New 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 | 68:0847e35d08a6 | 74 | |
tass | 68:0847e35d08a6 | 75 | |
tass | 68:0847e35d08a6 | 76 | struct __attribute__((packed)) pico_tcp_option |
tass | 68:0847e35d08a6 | 77 | { |
TASS Belgium NV |
131:4758606c9316 | 78 | uint8_t kind; |
TASS Belgium NV |
131:4758606c9316 | 79 | uint8_t len; |
tass | 68:0847e35d08a6 | 80 | #if 0 |
TASS Belgium NV |
131:4758606c9316 | 81 | union { |
TASS Belgium NV |
131:4758606c9316 | 82 | uint16_t mss; |
TASS Belgium NV |
131:4758606c9316 | 83 | uint8_t wshift; |
TASS Belgium NV |
131:4758606c9316 | 84 | struct { |
TASS Belgium NV |
131:4758606c9316 | 85 | uint32_t tsval; |
TASS Belgium NV |
131:4758606c9316 | 86 | uint32_t tsecr; |
TASS Belgium NV |
131:4758606c9316 | 87 | } timestamp; |
TASS Belgium NV |
131:4758606c9316 | 88 | } data; |
tass | 68:0847e35d08a6 | 89 | #endif |
tass | 68:0847e35d08a6 | 90 | }; |
tass | 68:0847e35d08a6 | 91 | |
tass | 68:0847e35d08a6 | 92 | struct pico_socket *pico_tcp_open(void); |
tass | 70:cd218dd180e5 | 93 | uint32_t pico_tcp_read(struct pico_socket *s, void *buf, uint32_t len); |
tass | 68:0847e35d08a6 | 94 | int pico_tcp_initconn(struct pico_socket *s); |
tass | 68:0847e35d08a6 | 95 | int pico_tcp_input(struct pico_socket *s, struct pico_frame *f); |
tass | 68:0847e35d08a6 | 96 | uint16_t pico_tcp_checksum_ipv4(struct pico_frame *f); |
tass | 70:cd218dd180e5 | 97 | uint16_t pico_tcp_overhead(struct pico_socket *s); |
tass | 68:0847e35d08a6 | 98 | int pico_tcp_output(struct pico_socket *s, int loop_score); |
tass | 68:0847e35d08a6 | 99 | int pico_tcp_queue_in_is_empty(struct pico_socket *s); |
tass | 68:0847e35d08a6 | 100 | int pico_tcp_reply_rst(struct pico_frame *f); |
tass | 68:0847e35d08a6 | 101 | void pico_tcp_cleanup_queues(struct pico_socket *sck); |
tass | 76:938a140caf12 | 102 | void pico_tcp_notify_closing(struct pico_socket *sck); |
TASS Belgium NV |
131:4758606c9316 | 103 | void transport_flags_update(struct pico_frame *, struct pico_socket *); |
tass | 68:0847e35d08a6 | 104 | |
tass | 68:0847e35d08a6 | 105 | #endif |