{"id":13439772,"url":"https://github.com/tass-belgium/picotcp","last_synced_at":"2025-04-08T01:36:36.558Z","repository":{"id":7034037,"uuid":"8309253","full_name":"tass-belgium/picotcp","owner":"tass-belgium","description":"PicoTCP is a free TCP/IP stack implementation","archived":false,"fork":false,"pushed_at":"2023-10-20T18:18:08.000Z","size":32334,"stargazers_count":1237,"open_issues_count":109,"forks_count":226,"subscribers_count":131,"default_branch":"master","last_synced_at":"2025-04-01T00:35:25.724Z","etag":null,"topics":["c","modular","tcpip"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tass-belgium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-02-20T08:43:50.000Z","updated_at":"2025-03-31T02:41:52.000Z","dependencies_parsed_at":"2024-01-14T09:14:29.463Z","dependency_job_id":"a2fe61f0-bad5-44f3-a5b2-22d05fee7122","html_url":"https://github.com/tass-belgium/picotcp","commit_stats":{"total_commits":2933,"total_committers":71,"mean_commits":"41.309859154929576","dds":0.705762018411183,"last_synced_commit":"46120abecc9fb79f7dfb2cc8192341a42e40fc8b"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tass-belgium%2Fpicotcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tass-belgium%2Fpicotcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tass-belgium%2Fpicotcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tass-belgium%2Fpicotcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tass-belgium","download_url":"https://codeload.github.com/tass-belgium/picotcp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","modular","tcpip"],"created_at":"2024-07-31T03:01:16.975Z","updated_at":"2025-04-08T01:36:36.541Z","avatar_url":"https://github.com/tass-belgium.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# picoTCP\n\n---------------\n\nWelcome to the one and only \u003cfont color=ff00f0\u003epicoTCP repository\u003c/font\u003e. \n\npicoTCP 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/)*.\n\nThis code is released under the terms of GNU GPL v2 and GNU GPL v3. Some rights reserved.\nOther licenses may apply at the sole discretion of the copyright holders.\n\nLearn 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).\n\nFor more information 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/).\n\nWondering about picoTCP's code quality? Check [our TiCS score](http://162.13.112.57:42506/tiobeweb/TICS/TqiDashboard.html#axes=Project()\u0026metric=tqi\u0026sel=Project(PicoTCP_rel))\n\n---------------\n\n## Continuous integration\n\nFunctional tests: \n[![Jenkins autotest](http://162.13.84.104:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_autotest)](http://162.13.84.104:8080/job/picoTCP_Rel/job/PicoTCP_rel_autotest) -\nUnit tests      : \n[![Jenkins unit tests](http://162.13.84.104:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_unit_tests)](http://162.13.84.104:8080/job/picoTCP_Rel/job/PicoTCP_rel_unit_tests) -\nRFC compliance  :\n[![Jenkins RFC Compliance](http://162.13.84.104:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_RF_mbed)](http://162.13.84.104:8080/job/picoTCP_Rel/job/PicoTCP_rel_RF_mbed) -\nTICS quality    :\n[![Jenkins TICS](http://162.13.84.104:8080/buildStatus/icon?job=picoTCP_Rel/PicoTCP_rel_TICS)](http://162.13.84.104:8080/job/picoTCP_Rel/job/PicoTCP_rel_TICS/)\nCoverity Scan Build status:\n[![Coverity Scan Build Status](https://scan.coverity.com/projects/7944/badge.svg)](https://scan.coverity.com/projects/7944)\n\n---------------\n\n## It runs on (pretty much) everything\n\nBy keeping interfaces simple, the porting effort to new platforms and OSses are very low. To give you an indication: porting to a new platform can be done in 3 days or less, a new OS in a single day and if you really go crazy, you can do an initial port in a single evening. Different platforms, mean different compilers, that’s why we continuously compile our stack with a bunch of them. The following list shows some of the currently supported platforms, device drivers and compilers.\n\n###  PicoTCP has been used with\n\n**Platforms picoTCP runs on**:\nARM Cortex-M series (ST Micro STM, NXP LPC, TI Stellaris, Freescale K64F),\nARM ARM9-series (ST Micro STR9),\nTexas Instruments (MSP430),\nMicrochip (PIC24, PIC32),\nAtmel (AVR 8bit),\nLinux (User space (TUN/TAP), Kernel space),\nWindows (User space (TAP))\n\n**Network devices picoTCP has worked with**:\nBCM43362 (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)\n\n**(RT)OSes picoTCP has been integrated into**:\nNo OS / Bare metal, FreeRTOS, mbed-RTOS, Frosted, linux / POSIX, MS DOS, MS Windows\n\n**Libraries picoTCP has been integrated with**:\nwolfSSL, mbedTLS, Mongoose RESTful library, MicroPython\n\n**Compilers picoTCP compiles under**:\nGCC, Clang, TCC, ARM-RCVT, IAR, XC-16, XC-32, MSP-GCC, AVR-GCC\n\nUnfortunately 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.\nIf 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 picotcp@altran.com.\n\nYour favorite not in the list? Check out the wiki for information and examples on how to port picoTCP to a new platform!\n\n---------------\n\n## Highly configurable and modular design\n\nFeatures are developed as modules in picoTCP, allowing you to pick the features you want in your application. This results in the smallest possible stack that remains compliant with the internet standards. The schematic below provides an overview of all implemented protocols.\n\n![modular](https://s1.postimg.org/139xbnv7lb/image.png)\n\n---------------\n\n\n## Simple example\n\n### Preparations\nThis 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.\n\n```bash\nsudo apt-get install git check vde2 libvdeplug2-dev libpcap0.8-dev openvpn wireshark\ngit clone https://github.com/tass-belgium/picotcp\ncd picotcp\nmake TAP=1\ncd ..\n```\n\n### The code\n\nThen make a new directory, e.g. `example`, and create a file with the following content : \n[//]: # (The code below is pulled through our CI - please leave the code extractor comments intact!)\n[//]: # (code extractor start)\n```C\n#include \u003ctime.h\u003e\n#include \u003cpico_stack.h\u003e\n#include \u003cpico_ipv4.h\u003e\n#include \u003cpico_icmp4.h\u003e\n#include \u003cpico_dev_tap.h\u003e\n\n#define NUM_PING 10\n\nstatic int finished = 0;\n\n/* gets called when the ping receives a reply, or encounters a problem */\nvoid cb_ping(struct pico_icmp4_stats *s)\n{\n    char host[30];\n    pico_ipv4_to_string(host, s-\u003edst.addr);\n    if (s-\u003eerr == 0) {\n        /* if all is well, print some pretty info */\n        printf(\"%lu bytes from %s: icmp_req=%lu ttl=%lu time=%lu ms\\n\", s-\u003esize,\n                host, s-\u003eseq, s-\u003ettl, (long unsigned int)s-\u003etime);\n        if (s-\u003eseq \u003e= NUM_PING)\n            finished = 1;\n    } else {\n        /* if something went wrong, print it and signal we want to stop */\n        printf(\"PING %lu to %s: Error %d\\n\", s-\u003eseq, host, s-\u003eerr);\n        finished = 1;\n    }\n}\n\n\nint main(void){\n    int id;\n    struct pico_ip4 ipaddr, netmask;\n    struct pico_device* dev;\n\n    /* initialise the stack. Super important if you don't want ugly stuff like\n     * segfaults and such! */\n    pico_stack_init();\n\n    /* create the tap device */\n    dev = pico_tap_create(\"tap0\");\n    if (!dev)\n        return -1;\n\n    /* assign the IP address to the tap interface */\n    pico_string_to_ipv4(\"192.168.5.4\", \u0026ipaddr.addr);\n    pico_string_to_ipv4(\"255.255.255.0\", \u0026netmask.addr);\n    pico_ipv4_link_add(dev, ipaddr, netmask);\n\n    printf(\"starting ping\\n\");\n    id = pico_icmp4_ping(\"192.168.5.5\", NUM_PING, 1000, 10000, 64, cb_ping);\n\n    if (id == -1)\n        return -1;\n\n    /* keep running stack ticks to have picoTCP do its network magic. Note that\n     * you can do other stuff here as well, or sleep a little. This will impact\n     * your network performance, but everything should keep working (provided\n     * you don't go overboard with the delays). */\n    while (finished != 1)\n    {\n        usleep(1000);\n        pico_stack_tick();\n    }\n\n    printf(\"finished !\\n\");\n    return 0;\n}\n\n```\n\n[//]: # (code extractor stop)\n\n### Building and running\n\nNow we can compile this and link it, by running \n```bash\ngcc -c -o main.o -I../picotcp/build/include main.c\ngcc -o main.elf main.o ../picotcp/build/lib/libpicotcp.a\n```\n\nNext 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`\n```bash\nsudo tunctl -u \u003cusername\u003e\nsudo ifconfig tap0 192.168.5.5\n```\n\nNow, you should be able to run `./main.elf`, and see output like \n```\nProtocol ethernet registered (layer: 2).\nProtocol ipv4 registered (layer: 3).\nProtocol ipv6 registered (layer: 3).\nProtocol icmp4 registered (layer: 4).\nProtocol icmp6 registered (layer: 4).\nProtocol igmp registered (layer: 4).\nProtocol udp registered (layer: 4).\nProtocol tcp registered (layer: 4).\nDevice tap0 created.\nAssigned ipv4 192.168.5.4 to device tap0\nstarting ping\n64 bytes from 192.168.5.5: icmp_req=1 ttl=64 time=5 ms\n64 bytes from 192.168.5.5: icmp_req=2 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=3 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=4 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=5 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=6 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=7 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=8 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=9 ttl=64 time=0 ms\n64 bytes from 192.168.5.5: icmp_req=10 ttl=64 time=0 ms\nfinished !\n```\n\nWhile the application is running, you can also run\n```\nping 192.168.5.4\n```\nto send pings in the other direction.\n\n### Investigating what happened\n\nRun 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.\n\nNote, 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.\n\nNow 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.\n\n\nThis is just a very quick overview, more info can be found in our [wiki](https://github.com/tass-belgium/picotcp/wiki).\n\n---------------\n\n## Contributors\n\nContributors are very welcome. Report a bug, suggest a way to improve our documentation, or write some new code.\n\nNote 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.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftass-belgium%2Fpicotcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftass-belgium%2Fpicotcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftass-belgium%2Fpicotcp/lists"}