Page 1 of 1

Extend XTCP/uIP for use with two interfaces

Posted: Wed Nov 16, 2016 11:21 am
by DemoniacMilk
Hello,

lib_xtcp is based on uIP and supporting a single interface only.

As I am building an ethernet bridge
[tab=30]eth network A - xcore - serial interface - [a lot of stuff] - serial interface - xcore - eth network B
with a web based configuration interface, i'd like to be able to access an xcores configuration from both ethernet networks. This requires access to the tcp stack via the serial interface and ethernet.

Unfortunately I dont know where to start.

The first idea was to adjust xtcp_process_incoming_packet() in xtcp() by adding a parameter that is used to store the source interface for a packet within the uIP stack. In xcoredev_send(), where packets are transmitted, the transmit interface is selected based on this parameter.

This might work if only a single packet is transmitted whenever a packet is received. But TCP might be sending retransmits after a timeout, keep-alives or multiple packets depending on the receivers RWin-size, so I think I have to store the interface for each connection. I cannot find any global state for connections tho.

What I found is "pending_event[MAX_XTCP_CLIENTS]", "notified[MAX_XTCP_CLIENTS]" and some more arrays using MAX_XTCP_CLIENTS as their index but that doesnt seem very handy.

Is there any existing approach adding multiple interfaces to the xtcp stack? If not, do you have an idea for an approach that doesnt require rewriting most of the library?

EDIT:
I found

Code: Select all

typedef struct xtcpd_state_t {
  unsigned int linknum;
  xtcp_connection_t conn;
  xtcp_server_state_t s;
} xtcpd_state_t;
and will experiment with that.

Re: Extend XTCP/uIP for use with two interfaces

Posted: Wed Nov 23, 2016 10:14 am
by Thomas
For this topology
eth network A - xcore - serial interface - [a lot of stuff] - serial interface - xcore - eth network B

you could have two instances of xtcp.
I.e.
eth network A - xcore - xtcp A - serial interface A - [a lot of stuff] - serial interface B -xtcp B - xcore - eth network B

In this case the serial interface tasks could be connected just like the "Application" (udp_reflect) in this appnote:
https://www.xmos.com/download/private/A ... rc1%29.pdf

Re: Extend XTCP/uIP for use with two interfaces

Posted: Wed Nov 23, 2016 7:30 pm
by DemoniacMilk
Good idea, although im short on ressoruces (cores, channels and memory as well), so Ill check if that might work

Re: Extend XTCP/uIP for use with two interfaces

Posted: Thu Nov 24, 2016 10:58 am
by DemoniacMilk
Now that I thought about this a bit more and read the ressource you linke I have to admit: I have absolutely no idea how this may help me.

Re: Extend XTCP/uIP for use with two interfaces

Posted: Tue Nov 29, 2016 3:38 pm
by DemoniacMilk
Hm I still dont know how to.

Do you mind adding some additional information?

I would really like to not distinguish between the network/hardware interfaces at a higher level, so my webserver for example should just get the date off a "black box" and put them back in, no matter what interface the data is coming from/going to.

Thought about creating two xtcp threads, one to be used with the ethernet interface and one to be used with the serial interface, both connnected to the http handler / webserver. But I dont see how i could connect both to the webserver or to the lower level uIP stack, that is absolutely not designed to distinguish two different hardware interfaces.

I also cannot write a new IP / TCP stack, as thats way too much for a thesis.

There is also just one point for data to get in ( xtcp() ) and just one to get out ( xcoredev_send() ) so I thought I might "just" add information on the source interface of a connection and send any answers to the respective interface. But I cant wrap my head around th uIP and xtcp stack, its just way too much for me to understand (especially without any comments).

Im really lost :(

EDIT: I could have the webserver accessible from EITHER network a OR network B (pass either ethernet or serial interfaces) but thats not too handy. Ill stick to that for now tho.

Re: Extend XTCP/uIP for use with two interfaces

Posted: Wed Dec 07, 2016 10:52 am
by Thomas
I don't understand why you have trouble to create this:
eth network A - xcore - xtcp A - serial interface A - [a lot of stuff] - serial interface B -xtcp B - xcore - eth network B

It's like creating two instances of https://www.xmos.com/support/appnotes/AN00121

You said that you are building an ethernet bridge.
Please provide more details on the Product that you're developing.

A bridge (switch) works on Layer 2: https://en.wikipedia.org/wiki/Bridging_(networking)
But TCP/IP is a layer 3 protocol.
On layer 3, a router is used to connect different networks.
Can you not just use a router for your purpose?

lib_xtcp is designed for Endstations that have a single Ethernet port.
That's why I'm suggesting one instance of xtcp per Ethernet port.
Then add a task between to two instances to implement the routing logic that you desire.

Re: Extend XTCP/uIP for use with two interfaces

Posted: Wed Dec 07, 2016 10:54 pm
by DemoniacMilk
The bridge is basically just grabbing all ethernet packets and forwards them to a serial interface (serial interface does the same vice versa). Both interfaces are operating based on packets. So its one ethernet port and one serial interface and all packets are being forwarded to the other interfaces.

The only exception are IP and ARP packets. These packets will be forwarded to the stack and webserver as well. The webserver provides a configuration interface to the user.

AN00121 that was linked by you is directly communicating with the TCP stack, but that should be covered by the webserver? How may I connect the two TCP/IP instances to the same webserver/without running two webserver instances as well? Im not even sure what the routing task should be doing in this case, as the tcp stack both grabs/sends packets using the respective interfaces functions (so i can easily run two tasks and assign one interface to each). I just dont know how I may combine this with the webserver.

Re: Extend XTCP/uIP for use with two interfaces

Posted: Thu Aug 12, 2021 5:33 am
by cccuser
on same topic is there a sample that shows how to use the xtcp library to have multiple udp mcast connections