Extend XTCP/uIP for use with two interfaces

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Extend XTCP/uIP for use with two interfaces

Post 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.


User avatar
Thomas
Experienced Member
Posts: 66
Joined: Fri Feb 05, 2010 12:34 pm

Post 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
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

Good idea, although im short on ressoruces (cores, channels and memory as well), so Ill check if that might work
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post 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.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post 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.
User avatar
Thomas
Experienced Member
Posts: 66
Joined: Fri Feb 05, 2010 12:34 pm

Post 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.
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post 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.
cccuser
Junior Member
Posts: 7
Joined: Wed Aug 11, 2021 7:28 pm

Post by cccuser »

on same topic is there a sample that shows how to use the xtcp library to have multiple udp mcast connections
Post Reply