Giter VIP home page Giter VIP logo

lib_xtcp's Introduction

TCP/IP Library

Overview

A library providing two alternative TCP/UDP/IP protocol stacks for XMOS devices. This library connects to the XMOS Ethernet library to provide layer-3 traffic over Ethernet via MII or RGMII.

Features

  • TCP and UDP connection handling
  • DHCP, IP4LL, ICMP, IGMP support
  • Low level, event based interface for efficient memory usage
  • Supports IPv4 only, not IPv6

Stacks

This library provides two different TCP/IP stack implementations ported to the xCORE architecture.

uIP stack

The first stack ported is the uIP (micro IP) stack. The uIP stack has been designed to have a minimal resource footprint. As a result, it has limited performance and does not provide support for TCP windowing.

lwIP stack

The second stack ported is the lwIP (lightweight IP) stack. The lwIP stack requires more resources than uIP, but is designed to provide better throughput and also has support for TCP windowing.

Typical Resource Usage

.. resusage::

  * - configuration: UIP
    - globals: xtcp_ipconfig_t ipconfig = {
               { 0, 0, 0, 0 },
               { 0, 0, 0, 0 },
               { 0, 0, 0, 0 }
               };
               char mac_addr[6] = {0};
    - locals: interface mii_if i_mii; xtcp_if i_xtcp[1];
    - fn: xtcp_uip(i_xtcp, 1, i_mii,
                   null, null, null,
                   null, 0, mac_addr, null, ipconfig);
    - pins: 0
    - ports: 0
  * - configuration: LWIP
    - globals: xtcp_ipconfig_t ipconfig = {
               { 0, 0, 0, 0 },
               { 0, 0, 0, 0 },
               { 0, 0, 0, 0 }
               };
               char mac_addr[6] = {0};
    - locals: interface mii_if i_mii; xtcp_if i_xtcp[1];
    - fn: xtcp_lwip(i_xtcp, 1, i_mii,
                   null, null, null,
                   null, 0, mac_addr, null, ipconfig);
    - pins: 0
    - ports: 0
    - target: XCORE-200-EXPLORER


Software version and dependencies

.. libdeps::

Related application notes

The following application notes use this library:

  • AN00121 - Using the XMOS TCP/IP library

lib_xtcp's People

Contributors

djpwilk avatar henkmuller avatar krisjacobs avatar mlippett avatar samchesney avatar vinithmundhra avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lib_xtcp's Issues

static IP on slicekit GP XL216

Hi,

somehow I can't set static IP in the application. I have tried the same code with the latest released version 4.0.2 and app works fine.

I don't know what else should I change so that app uses static IP ?
Application passes to to uip.c file static IP address set in the main file.
Since there's no dhcp server on the network, it always gets the local IP 169/254.

Thank you

Sascha

lib_random

As both lib_xtcp and lib_crypto need access to a random number generator, it could be useful to export that functionality to a separate library (possible lib_random).

At the moment lib_xtcp has a copy of random.h and random.xc in its directory (under lib_xtcp/xtcp_lwip/xcore).

Library incorrectly pads small packets

In xcoredev.xc, lines 100-103 it incorrectly uses 64 bytes as the minimum packet size and pads:

    if (len < 64)  {
      for (int i=len;i<64;i++)
        (uip_buf32, unsigned char[])[i] = 0;
      len=64;
    }

This should be 60, as the CRC will be automatically added to make the size up to the minimum frame size of 64 bytes.

xtcp polling performance

Hi there,
with the latest and greatest code, we get okay performance with lib_xtcp. However, the throughput leaves a bit to be desired.

I believe this is in part due to the length of the polling loop in xtcp(). Clearly, it's greatly improved from the previous revision, which is good, but it could still use a little help.

To that end, added a timer in the polling loop to see where the time is spent, and the results are:

Op Time for this op (uS) Cumulative time (uS)
xtcp_service_clients .75 .75
xtcp_check_connection_poll 3.96 4.71
uip_xtcp_checkstate .35 5.06
xtcp_process_udp_acks .81 5.87
start of next loop (i.e. time to drop through the select statement) .26 6.13

At 100MBit, an average packet of 1000 byts takes 80 uS on the wire. with a polling interval of 6 uS, this is maybe not a terrible ratio.

However, at 1000MBit, that same packet takes only 8uS, in which case the library when under load is spending a significant amount of time in xtcp_check_connection_poll.

Obviously, for smaller packets, the problem is much worse. (i.e. a 100 byte packet is only 0.8uS on the wire whereas the polling interval could be 10 times longer!)

Is there anything that can be done to improve performance here? It would be great if we could make this thing event driven rather than polled.

BTW, I checked this both when idle, and when the ethernet is under load at with ping -f and the timings are very consistent.

ipconfig may not be word aligned

xC compiler doesn't word align local arrays on the stack at the moment. While this may or may not change in the future, uip_server_init is casting char[4] in ipconfig that's passed to int*, which is not very good code. Suggest using memcmp or a for loop.

if (ipconfig != NULL && (*((int*)ipconfig->ipaddr) != 0)) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.