NameDateSize

..28-Jul-202015

.gitignoreH A D25-Jul-2019206

.travis.ymlH A D25-Jul-2019610

CONTRIBUTING.mdH A D25-Jul-2019928

COPYINGH A D25-Jul-2019288

docs/H25-Jul-20194

include/H25-Jul-201918

LICENSE.GPLv2H A D25-Jul-201917.7 KiB

LICENSE.GPLv3H A D25-Jul-201934.3 KiB

MakefileH A D25-Jul-201914.7 KiB

Makefile.watcomH A D25-Jul-201911.9 KiB

mkdeps.shH A D25-Jul-2019720

modcheck.pyH A D25-Jul-20192 KiB

MODTREEH A D25-Jul-2019334

modules/H25-Jul-201998

README.mdH A D25-Jul-20199.5 KiB

RFC/H25-Jul-201999

rules/H25-Jul-201936

stack/H25-Jul-201910

test/H25-Jul-201922

uncrustify.cfgH A D25-Jul-201969.3 KiB

README.md

1# picoTCP
2
3---------------
4
5Welcome to the one and only <font color=ff00f0>picoTCP repository</font>. 
6
7picoTCP is a small-footprint, modular TCP/IP stack designed for embedded systems and the Internet of Things. It's actively being developed by *[Altran Intelligent Systems](http://intelligent-systems.altran.com/)*. Textual information about picoTCP, you can find on the [about page of our website](http://picotcp.com/about).
8
9This code is released under the terms of GNU GPL v2 only. Some rights reserved.
10Other licenses may apply at the sole discretion of the copyright holders.
11
12Learn how to use picoTCP in your project by going through the **Getting Started guide** on our [GitHub wiki](https://github.com/tass-belgium/picotcp/wiki).
13
14For more information visit the [picoTCP website](http://www.picotcp.com), send us an email or contact us on [Twitter](https://twitter.com/picotcp), [Facebook](https://www.facebook.com/picoTCP) or [Reddit](http://www.reddit.com/r/picotcp/).
15
16Wondering about picoTCP's code quality? Check [our TiCS score](http://tics.picotcp.com:42506/tiobeweb/TICS/TqiDashboard.html#axes=Project%28%29&metric=tqi&sel=Project%28PicoTCP_rel%29)
17
18
19---------------
20
21## Continuous integration
22
23Functional tests: 
24[![Jenkins autotest](http://jenkins.picotcp.com:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_autotest)](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_autotest) -
25Unit tests      : 
26[![Jenkins unit tests](http://jenkins.picotcp.com:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_unit_tests)](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_unit_tests) -
27RFC compliance  :
28[![Jenkins RFC Compliance](http://jenkins.picotcp.com:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_RF_mbed)](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_RF_mbed) -
29TICS quality    :
30[![Jenkins TICS](http://jenkins.picotcp.com:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_TICS)](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_TICS/)
31Coverity Scan Build status:
32[![Coverity Scan Build Status](https://scan.coverity.com/projects/7944/badge.svg)](https://scan.coverity.com/projects/7944)
33
34---------------
35
36## Simple example
37
38### Preparations
39This example uses Ubuntu 14.04. It works on other linux distibutions as well, though you may need to change some package names. See [setting up the environment](https://github.com/tass-belgium/picotcp/wiki/Setting-up-the-environment#prerequisite-packages) for some more info.
40
41```bash
42sudo apt-get install git check vde2 libvdeplug2-dev libpcap0.8-dev openvpn wireshark
43git clone https://github.com/tass-belgium/picotcp
44cd picotcp
45make TAP=1
46cd ..
47```
48
49### The code
50
51Then make a new directory, e.g. `example`, and create a file with the following content : 
52[//]: # (The code below is pulled through our CI - please leave the code extractor comments intact!)
53[//]: # (code extractor start)
54```C
55#include <time.h>
56#include <pico_stack.h>
57#include <pico_ipv4.h>
58#include <pico_icmp4.h>
59#include <pico_dev_tap.h>
60
61#define NUM_PING 10
62
63static int finished = 0;
64
65/* gets called when the ping receives a reply, or encounters a problem */
66void cb_ping(struct pico_icmp4_stats *s)
67{
68    char host[30];
69    pico_ipv4_to_string(host, s->dst.addr);
70    if (s->err == 0) {
71        /* if all is well, print some pretty info */
72        printf("%lu bytes from %s: icmp_req=%lu ttl=%lu time=%lu ms\n", s->size,
73                host, s->seq, s->ttl, (long unsigned int)s->time);
74        if (s->seq >= NUM_PING)
75            finished = 1;
76    } else {
77        /* if something went wrong, print it and signal we want to stop */
78        printf("PING %lu to %s: Error %d\n", s->seq, host, s->err);
79        finished = 1;
80    }
81}
82
83
84int main(void){
85    int id;
86    struct pico_ip4 ipaddr, netmask;
87    struct pico_device* dev;
88
89    /* initialise the stack. Super important if you don't want ugly stuff like
90     * segfaults and such! */
91    pico_stack_init();
92
93    /* create the tap device */
94    dev = pico_tap_create("tap0");
95    if (!dev)
96        return -1;
97
98    /* assign the IP address to the tap interface */
99    pico_string_to_ipv4("192.168.5.4", &ipaddr.addr);
100    pico_string_to_ipv4("255.255.255.0", &netmask.addr);
101    pico_ipv4_link_add(dev, ipaddr, netmask);
102
103    printf("starting ping\n");
104    id = pico_icmp4_ping("192.168.5.5", NUM_PING, 1000, 10000, 64, cb_ping);
105
106    if (id == -1)
107        return -1;
108
109    /* keep running stack ticks to have picoTCP do its network magic. Note that
110     * you can do other stuff here as well, or sleep a little. This will impact
111     * your network performance, but everything should keep working (provided
112     * you don't go overboard with the delays). */
113    while (finished != 1)
114    {
115        usleep(1000);
116        pico_stack_tick();
117    }
118
119    printf("finished !\n");
120    return 0;
121}
122
123```
124
125[//]: # (code extractor stop)
126
127### Building and running
128
129Now we can compile this and link it, by running 
130```bash
131gcc -c -o main.o -I../picotcp/build/include main.c
132gcc -o main.elf main.o ../picotcp/build/lib/libpicotcp.a
133```
134
135Next we'll create a persistent tap device - a virtual network port. You don't need to repeat this each time, the device will exist until you reboot, or until you go `sudo tunctl -d tap0`
136```bash
137sudo tunctl -u <username>
138sudo ifconfig tap0 192.168.5.5
139```
140
141Now, you should be able to run `./main.elf`, and see output like 
142```
143Protocol ethernet registered (layer: 2).
144Protocol ipv4 registered (layer: 3).
145Protocol ipv6 registered (layer: 3).
146Protocol icmp4 registered (layer: 4).
147Protocol icmp6 registered (layer: 4).
148Protocol igmp registered (layer: 4).
149Protocol udp registered (layer: 4).
150Protocol tcp registered (layer: 4).
151Device tap0 created.
152Assigned ipv4 192.168.5.4 to device tap0
153starting ping
15464 bytes from 192.168.5.5: icmp_req=1 ttl=64 time=5 ms
15564 bytes from 192.168.5.5: icmp_req=2 ttl=64 time=0 ms
15664 bytes from 192.168.5.5: icmp_req=3 ttl=64 time=0 ms
15764 bytes from 192.168.5.5: icmp_req=4 ttl=64 time=0 ms
15864 bytes from 192.168.5.5: icmp_req=5 ttl=64 time=0 ms
15964 bytes from 192.168.5.5: icmp_req=6 ttl=64 time=0 ms
16064 bytes from 192.168.5.5: icmp_req=7 ttl=64 time=0 ms
16164 bytes from 192.168.5.5: icmp_req=8 ttl=64 time=0 ms
16264 bytes from 192.168.5.5: icmp_req=9 ttl=64 time=0 ms
16364 bytes from 192.168.5.5: icmp_req=10 ttl=64 time=0 ms
164finished !
165```
166
167While the application is running, you can also run
168```
169ping 192.168.5.4
170```
171to send pings in the other direction.
172
173### Investigating what happened
174
175Run wireshark, and sniff the tap0 interface. Then run the `./main.elf` again, and see what happens. You should see an ARP request from picoTCP to Linux, and a reply. After that you should see the ping requests and replies going back and forth.
176
177Note, sometimes you may see lots of other stuff, IPv6 router sollicitations, various broadcasts, mDNS, DNS-SD, etc - this is your when your Linux notices the new network interface is up, and starts all sorts of discoveries. With the persistent TAP device, this usually only happens the first time you start the application. Start a new wireshark capture, and start the application again, it should be much cleaner now.
178
179Now you could make some changes to the `main.c` file, and experiment a bit! Keep some statistics of your pings (max, min, avg time). Open a UDP socket, send some stuff to a netcat instance on your linux. Or build a rudimentary port scanner, see what ports are open on your machine.
180
181
182This is just a very quick overview, more info can be found in our [wiki](https://github.com/tass-belgium/picotcp/wiki).
183
184---------------
185
186## Contributors
187
188Contributors are very welcome. Report a bug, suggest a way to improve our documentation, or write some new code.
189
190Note however that, before accepting your code, we would ask you to sign our [Contributors License Agreement](https://docs.google.com/forms/d/1-z6lsT75l6ZIrgHGEWrWdHylJ6xxpjc7FwGfL2ilDFU/viewform). Your code remains under your copyright, and will always be available under GPLv2 and GPLv3. However, this CLA enables us to use picoTCP (including code from external contributors like you) under other licenses, including our commercial license. By doing commercial projects, we can keep investing in the quality and features of picoTCP.
191
192---------------
193
194## PicoTCP has been used with
195
196**Platforms picoTCP runs on**:
197ARM Cortex-M series (ST Micro STM, NXP LPC, TI Stellaris, Freescale K64F),
198ARM ARM9-series (ST Micro STR9),
199Texas Instruments (MSP430),
200Microchip (PIC24, PIC32),
201Atmel (AVR 8bit),
202Linux (User space (TUN/TAP), Kernel space),
203Windows (User space (TAP))
204
205**Network devices picoTCP has worked with**:
206BCM43362 (IEEE 802.11), MRF24WG (IEEE 802.11), LPC Ethernet ENET/EMAC (IEEE 802.3), Stellaris Ethernet (IEEE 802.3), STM32 Ethernet (IEEE 802.3), Wiznet W5100 (IEEE 802.3), USB CDC-ECM (CDC1.2), PPP, Virtual drivers ( TUN/TAP, VDE, Libpcap)
207
208**(RT)OSes picoTCP has been integrated into**:
209No OS / Bare metal, FreeRTOS, mbed-RTOS, Frosted, linux / POSIX, MS DOS, MS Windows
210
211**Libraries picoTCP has been integrated with**:
212wolfSSL, mbedTLS, Mongoose RESTful library, MicroPython
213
214**Compilers picoTCP compiles under**:
215GCC, Clang, TCC, ARM-RCVT, IAR, XC-16, XC-32, MSP-GCC, AVR-GCC
216
217Unfortunately we can't release all the code, a.o. because some parts depend on code or binaries that aren't GPL compatible, some parts were developed under a commercial contract, and some consist of very rough proof-of-concept code.
218If you want to know more about the availability under the commercial license, or the possibility of using our expert services for porting or driver development, feel free to contact us at info@picotcp.com.
219
220Your favorite not in the list? Check out the wiki for information and examples on how to port picoTCP to a new platform!
221